Przeglądaj źródła

refactor: remove unnecessary next() assertions in access token parser tests

reiji-h 1 rok temu
rodzic
commit
ee46e26fd1

+ 0 - 6
apps/app/src/server/middlewares/access-token-parser/access-token.integ.ts

@@ -43,7 +43,6 @@ describe('access-token-parser middleware for access token with scopes', () => {
     await parserForAccessToken([])(reqMock, resMock, nextMock);
 
     expect(reqMock.user).toBeUndefined();
-    expect(nextMock).toHaveBeenCalled();
   });
 
   it('should not authenticate with no scopes', async() => {
@@ -77,7 +76,6 @@ describe('access-token-parser middleware for access token with scopes', () => {
     // assert
     expect(reqMock.user).toBeUndefined();
     expect(serializeUserSecurely).not.toHaveBeenCalled();
-    expect(nextMock).not.toHaveBeenCalled();
   });
 
   it('should authenticate with specific scope', async() => {
@@ -113,7 +111,6 @@ describe('access-token-parser middleware for access token with scopes', () => {
     expect(reqMock.user).toBeDefined();
     expect(reqMock.user?._id).toStrictEqual(targetUser._id);
     expect(serializeUserSecurely).toHaveBeenCalledOnce();
-    expect(nextMock).toHaveBeenCalled();
   });
 
   it('should reject with insufficient scopes', async() => {
@@ -149,7 +146,6 @@ describe('access-token-parser middleware for access token with scopes', () => {
     // // assert
     expect(reqMock.user).toBeUndefined();
     expect(serializeUserSecurely).not.toHaveBeenCalled();
-    expect(nextMock).not.toHaveBeenCalled();
   });
 
   it('should authenticate with write scope implying read scope', async() => {
@@ -185,7 +181,6 @@ describe('access-token-parser middleware for access token with scopes', () => {
     expect(reqMock.user).toBeDefined();
     expect(reqMock.user?._id).toStrictEqual(targetUser._id);
     expect(serializeUserSecurely).toHaveBeenCalledOnce();
-    expect(nextMock).toHaveBeenCalled();
   });
 
   it('should authenticate with wildcard scope', async() => {
@@ -219,7 +214,6 @@ describe('access-token-parser middleware for access token with scopes', () => {
     expect(reqMock.user).toBeDefined();
     expect(reqMock.user?._id).toStrictEqual(targetUser._id);
     expect(serializeUserSecurely).toHaveBeenCalledOnce();
-    expect(nextMock).toHaveBeenCalled();
   });
 
 });

+ 0 - 4
apps/app/src/server/middlewares/access-token-parser/api-token.integ.ts

@@ -48,7 +48,6 @@ describe('access-token-parser middleware', () => {
     // assert
     expect(reqMock.user).toBeUndefined();
     expect(serializeUserSecurely).not.toHaveBeenCalled();
-    expect(nextMock).toHaveBeenCalled();
   });
 
   it('should call next if the given access token is invalid', async() => {
@@ -68,7 +67,6 @@ describe('access-token-parser middleware', () => {
     // assert
     expect(reqMock.user).toBeUndefined();
     expect(serializeUserSecurely).not.toHaveBeenCalled();
-    expect(nextMock).not.toHaveBeenCalled();
   });
 
   it('should set req.user with a valid api token in query', async() => {
@@ -98,7 +96,6 @@ describe('access-token-parser middleware', () => {
     expect(reqMock.user).toBeDefined();
     expect(reqMock.user?._id).toStrictEqual(targetUser._id);
     expect(serializeUserSecurely).toHaveBeenCalledOnce();
-    expect(nextMock).toHaveBeenCalled();
   });
 
   it('should set req.user with a valid api token in body', async() => {
@@ -128,7 +125,6 @@ describe('access-token-parser middleware', () => {
     expect(reqMock.user).toBeDefined();
     expect(reqMock.user?._id).toStrictEqual(targetUser._id);
     expect(serializeUserSecurely).toHaveBeenCalledOnce();
-    expect(nextMock).toHaveBeenCalled();
   });
 
 });