it('sets a jwt access token cookie in the response', () => { const req = mockReq(); const res = mockRes(); const expectedJWT = jwt.sign({ accessToken }, validJWTSecret); setAccessTokenToResponse({ accessToken }, req, res, validJWTSecret); expect(res.cookie.getCall(0).args).toEqual([ 'jwt_access_token', expectedJWT, { signed: false, domain: 'localhost', maxAge: accessToken.ttl } ]); });
it('removes four cookies set in the lifetime of an authenticated session', () => { // expect.assertions(4); const req = mockReq(); const res = mockRes(); removeCookies(req, res); expect(res.clearCookie.getCall(0).args).toEqual([ 'jwt_access_token', { signed: false, domain: 'localhost' } ]); expect(res.clearCookie.getCall(1).args).toEqual([ 'access_token', { signed: false, domain: 'localhost' } ]); expect(res.clearCookie.getCall(2).args).toEqual([ 'userId', { signed: false, domain: 'localhost' } ]); expect(res.clearCookie.getCall(3).args).toEqual([ '_csrf', { signed: false, domain: 'localhost' } ]); });