Skip to content

Commit

Permalink
Fix test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joerger committed Jan 14, 2025
1 parent c3ad836 commit 740e2ac
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions web/packages/teleport/src/lib/useMfa.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
MfaChallengeResponse,
} from 'teleport/services/mfa';

import { useMfa } from './useMfa';
import { MfaCanceledError, useMfa } from './useMfa';

const mockChallenge: MfaAuthenticateChallenge = {
webauthnPublicKey: {} as PublicKeyCredentialRequestOptions,
Expand Down Expand Up @@ -234,15 +234,16 @@ describe('useMfa', () => {

mfa.current.cancelAttempt();

await expect(respPromise).rejects.toThrow(
new Error('User canceled MFA attempt')
);
await expect(respPromise).rejects.toThrow(new MfaCanceledError());

// If the user cancels the MFA attempt and closes the dialog, the mfa status
// should be 'success', or else the dialog would remain open to display the error.
// This error is meant to be handled by the caller.
await waitFor(() => {
expect(mfa.current.attempt.status).toEqual('success');
expect(mfa.current.attempt.status).toEqual('error');
});
expect(
mfa.current.attempt.status === 'error' && mfa.current.attempt.error
).toEqual(new MfaCanceledError());
});
});

0 comments on commit 740e2ac

Please sign in to comment.