Joachim Van Herwegen a47f5236ef feat: Full rework of account management
Complete rewrite of the account management and related systems.
Makes the architecture more modular,
allowing for easier extensions and configurations.
2023-10-06 11:04:40 +02:00

34 lines
1.1 KiB
TypeScript

import type { Interaction } from '../../../../../src/identity/interaction/InteractionHandler';
import { CancelOidcHandler } from '../../../../../src/identity/interaction/oidc/CancelOidcHandler';
describe('A CancelOidcHandler', (): void => {
let oidcInteraction: Interaction;
let handler: CancelOidcHandler;
beforeEach(async(): Promise<void> => {
oidcInteraction = {
lastSubmission: { login: { accountId: 'id' }},
persist: jest.fn(),
session: {
cookie: 'cookie',
},
returnTo: 'returnTo',
} as any;
handler = new CancelOidcHandler();
});
it('finishes the interaction with an error.', async(): Promise<void> => {
await expect(handler.handle({ oidcInteraction } as any)).rejects.toThrow(expect.objectContaining({
statusCode: 302,
location: 'returnTo',
}));
expect(oidcInteraction.persist).toHaveBeenCalledTimes(1);
expect(oidcInteraction.result).toEqual({
error: 'access_denied',
// eslint-disable-next-line @typescript-eslint/naming-convention
error_description: 'User cancelled the interaction.',
});
});
});