mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-07 09:01:13 -05:00
refactor: remove sinon (#42337)
This commit is contained in:
committed by
GitHub
parent
7d1e9af9df
commit
802273cf8a
@@ -5,7 +5,7 @@ import {
|
||||
setAccessTokenToResponse,
|
||||
removeCookies
|
||||
} from './getSetAccessToken';
|
||||
import { mockReq, mockRes } from 'sinon-express-mock';
|
||||
import { mockReq, mockRes } from '../boot_tests/challenge.test';
|
||||
import jwt from 'jsonwebtoken';
|
||||
|
||||
describe('getSetAccessToken', () => {
|
||||
@@ -130,7 +130,8 @@ describe('getSetAccessToken', () => {
|
||||
|
||||
setAccessTokenToResponse({ accessToken }, req, res, validJWTSecret);
|
||||
|
||||
expect(res.cookie.getCall(0).args).toEqual([
|
||||
expect(res.cookie).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
'jwt_access_token',
|
||||
expectedJWT,
|
||||
{
|
||||
@@ -138,7 +139,7 @@ describe('getSetAccessToken', () => {
|
||||
domain,
|
||||
maxAge: accessToken.ttl
|
||||
}
|
||||
]);
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -152,16 +153,18 @@ describe('getSetAccessToken', () => {
|
||||
|
||||
removeCookies(req, res);
|
||||
|
||||
expect(res.clearCookie.getCall(0).args).toEqual([
|
||||
expect(res.clearCookie).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
'jwt_access_token',
|
||||
jwtOptions
|
||||
]);
|
||||
expect(res.clearCookie.getCall(1).args).toEqual([
|
||||
);
|
||||
expect(res.clearCookie).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
'access_token',
|
||||
jwtOptions
|
||||
]);
|
||||
expect(res.clearCookie.getCall(2).args).toEqual(['userId', jwtOptions]);
|
||||
expect(res.clearCookie.getCall(3).args).toEqual(['_csrf', jwtOptions]);
|
||||
);
|
||||
expect(res.clearCookie).toHaveBeenNthCalledWith(3, 'userId', jwtOptions);
|
||||
expect(res.clearCookie).toHaveBeenNthCalledWith(4, '_csrf', jwtOptions);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user