Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
denysoblohin-okta committed Jul 10, 2023
1 parent ee42998 commit bf6aa04
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions test/spec/idx/remediators/SelectAuthenticator.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import { SelectAuthenticatorAuthenticate } from '../../../../lib/idx/remediators';
import { SelectAuthenticatorAuthenticate, SelectAuthenticatorEnroll } from '../../../../lib/idx/remediators';
import {
SelectAuthenticatorEnrollRemediationFactory,
SelectAuthenticatorAuthenticateRemediationFactory,
AuthenticatorValueFactory,
PhoneAuthenticatorOptionFactory,
EmailAuthenticatorOptionFactory,
IdxContextFactory,
PhoneAuthenticatorFactory,
EmailAuthenticatorFactory,
} from '@okta/test.support/idx';

describe('remediators/Base/SelectAuthenticator', () => {
describe('remediators/SelectAuthenticatorEnroll', () => {
describe('canRemediate', () => {
it('retuns false if matched authenticator is already the current one', () => {
const currentAuthenticator = PhoneAuthenticatorFactory.build();
const currentAuthenticator = EmailAuthenticatorFactory.build();
const remediation = SelectAuthenticatorEnrollRemediationFactory.build({
value: [
AuthenticatorValueFactory.build({
options: [
PhoneAuthenticatorOptionFactory.params({
EmailAuthenticatorOptionFactory.params({
_authenticator: currentAuthenticator,
}).build(),
]
Expand All @@ -30,6 +33,36 @@ describe('remediators/Base/SelectAuthenticator', () => {
const authenticators = [
currentAuthenticator,
];
const r = new SelectAuthenticatorEnroll(remediation, { authenticators });
expect(r.canRemediate(context)).toBe(false);
expect(r.canRemediate()).toBe(true);
});
});
});

describe('remediators/SelectAuthenticatorAuthenticate', () => {
describe('canRemediate', () => {
it('retuns false if matched authenticator is already the current one', () => {
const currentAuthenticatorEnrollment = PhoneAuthenticatorFactory.build();
const remediation = SelectAuthenticatorAuthenticateRemediationFactory.build({
value: [
AuthenticatorValueFactory.build({
options: [
PhoneAuthenticatorOptionFactory.params({
_authenticator: currentAuthenticatorEnrollment,
}).build(),
]
}),
]
});
const context = IdxContextFactory.build({
currentAuthenticatorEnrollment: {
value: currentAuthenticatorEnrollment
}
});
const authenticators = [
currentAuthenticatorEnrollment,
];
const r = new SelectAuthenticatorAuthenticate(remediation, { authenticators });
expect(r.canRemediate(context)).toBe(false);
expect(r.canRemediate()).toBe(true);
Expand Down

0 comments on commit bf6aa04

Please sign in to comment.