Skip to content

Commit

Permalink
BAU: test refactors to clarify resend mfa controller tests
Browse files Browse the repository at this point in the history
Hopefully this makes it a bit more obvious what the point of these tests are
  • Loading branch information
BeckaL committed May 22, 2024
1 parent bee67bc commit 801a2d5
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,22 @@ describe("resend mfa controller", () => {

beforeEach(() => {
fakeService = { sendNotification: sinon.fake.returns({ success: true }) };
req.path = PATH_NAMES.RESEND_MFA_CODE_ACCOUNT_CREATION;
});

it("should request new phone verification code from send notification service and if successful redirect to /enter-code view", async () => {
req.path = PATH_NAMES.RESEND_MFA_CODE_ACCOUNT_CREATION;

await resendMfaCodePost(fakeService)(req as Request, res as Response);

expect(res.redirect).to.have.been.calledWith(PATH_NAMES.CHECK_YOUR_PHONE);
expect(fakeService.sendNotification).to.have.been.calledOnce;
});

it("should request new phone verification code from send notification service and if successful redirect to /enter-code view", async () => {
it("should request new phone verification code with relevant registration journey type for account recovery journey", async () => {
req.session.user = {
email,
isAccountRecoveryJourney: true,
};
req.path = PATH_NAMES.RESEND_MFA_CODE_ACCOUNT_CREATION;
const expectedJourneyType = "ACCOUNT_RECOVERY";

await resendMfaCodePost(fakeService)(req as Request, res as Response);

Expand All @@ -76,16 +75,16 @@ describe("resend mfa controller", () => {
diPersistentSessionId,
"",
req,
"ACCOUNT_RECOVERY"
expectedJourneyType
);
});

it("should request new phone verification code from send notification service and if successful redirect to /enter-code view", async () => {
it("should request new phone verification code with relevant registration journey type for account creation journey", async () => {
req.session.user = {
email,
isAccountCreationJourney: true,
};
req.path = PATH_NAMES.RESEND_MFA_CODE_ACCOUNT_CREATION;
const expectedJourneyType = "REGISTRATION";

await resendMfaCodePost(fakeService)(req as Request, res as Response);

Expand All @@ -97,7 +96,7 @@ describe("resend mfa controller", () => {
diPersistentSessionId,
"",
req,
"REGISTRATION"
expectedJourneyType
);
});
});
Expand Down

0 comments on commit 801a2d5

Please sign in to comment.