refactor: remove sinon (#42337)

This commit is contained in:
Oliver Eyton-Williams
2021-06-02 17:33:05 +02:00
committed by GitHub
parent 7d1e9af9df
commit 802273cf8a
8 changed files with 91 additions and 195 deletions

View File

@@ -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);
});
});
});