CSR-710 Add/edit tests

This commit is contained in:
Katie 2022-07-11 16:46:26 -04:00
parent c7b7e25dfd
commit ea207aac90
2 changed files with 31 additions and 2 deletions

View file

@ -21,7 +21,8 @@ describe("cookies", () => {
ReferralDate: testReferralDate,
ReferralCorrelationId: testReferralCorrelationId,
ShouldResetState: testShouldResetState,
DidHeritageFunnelUpdateLast: testDidHeritageFunnelUpdateLast
DidHeritageFunnelUpdateLast: testDidHeritageFunnelUpdateLast,
SuppressConceptFunnel: true
}
setupCookies({ funnelCookieValue: JSON.stringify(testCookieValue) });

View file

@ -328,7 +328,7 @@ describe("navigateToHeritageFunnel", () => {
// Assert
expect(saveOrderFunction).toHaveBeenCalled();
// Should alway save before we navigate to heritage
// Should save before we navigate to heritage by default
const saveOrderFunctionCallOrder = saveOrderFunction.mock.invocationCallOrder[0];
const routerNavigateFunctionCallOrder = router.navigateToExternalUrl.mock.invocationCallOrder[0];
expect(saveOrderFunctionCallOrder).toBeLessThan(routerNavigateFunctionCallOrder);
@ -367,4 +367,32 @@ describe("navigateToHeritageFunnel", () => {
})
);
});
test("should not save order, but should still navigate", async () => {
// Arrange
const mockReferralNumber = "2";
const mockCorrelationId = "55";
const mockReferralDate = "2022";
const mockOrderInfo = getMockOrderInfo(mockReferralNumber, mockCorrelationId, mockReferralDate);
const mockData = {
actionList: [{
actionName: storeActions.SAVE_ORDER,
data: mockOrderInfo,
}]
}
setupMocksForJsFiles(mockData);
const saveOrderFunction = jest.spyOn(orderHelper, "saveOrder");
router.navigateToExternalUrl = jest.fn();
// Act
await navigateToHeritageFunnel(false);
// Assert
expect(saveOrderFunction).not.toHaveBeenCalled();
expect(router.navigateToExternalUrl).toHaveBeenCalled();
saveOrderFunction.mockRestore();
});
});