Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
denysoblohin-okta committed Oct 8, 2021
1 parent 743e427 commit 1b98d17
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/unit/callback.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,34 @@ describe('callback', () => {
});
});

it('handles a callback with custom handler', async () => {
await bootstrap({
routes: {
loginCallback: {
afterCallback: '/profile',
handler: (_req, _res, next) => {
next();
}
}
}
});
mockToken();
return new Promise((resolve, reject) => {
agent
.get('/authorization-code/callback')
.query({ state, code: 'foo' })
.set('Accept', 'application/json')
.expect(302)
.end(function(err, res){
if (err) return reject(err);
expect(res.headers.location).toBe('/profile');
expect(mocks.authenticate).toHaveBeenCalledWith(expect.any(Object), expect.any(Object));
expect(mocks.validateIdToken).toHaveBeenCalledWith({ id_token: idToken }, nonce, 'token', undefined);
resolve()
});
});
});

it('respects the "timeout" option when making a call to /token', async () => {
jest.useFakeTimers();
const timeout = 30000; // should be greater than test timeout
Expand Down

0 comments on commit 1b98d17

Please sign in to comment.