CSR-416 Add tests

This commit is contained in:
Katie 2022-05-25 16:27:50 -04:00
parent c648512029
commit 50c2b787e0

View file

@ -666,24 +666,48 @@ describe("vehicle-damage.vue", () => {
}) })
describe("hide back button", () => { describe("hide back button", () => {
test.only("if claim registration is delayed => should hide back button", () => { test("if claim registration is delayed => should hide back button", () => {
// Arrange // Arrange
const { wrapper } = setupMocks({}); const { wrapper } = setupMocks({
cookieHelper.getFunnelCookie = jest.spyOn(cookieHelper, "getFunnelCookie").mockReturnValue({ funnelCookie: {
HasDelayedClaimRegistration: true HasDelayedClaimRegistration: true
}
}); });
// Assert // Assert
expect(wrapper.vm.shouldHideBackButton()).toBe(true); expect(wrapper.vm.shouldHideBackButton).toBe(true);
}); });
test.todo("if claim is verified => should hide back button") test("if claim is verified => should hide back button", () => {
}); // Arrange
const { wrapper } = setupMocks({
mountOptionsMockData: {
router: { navigateAfterSave: jest.fn(), },
actionList: [{ actionName: storeActions.GET_PARTS_OR_QUESTIONS, data: {}, },],
store: {
getters: {
vehicle: {},
payment: { insuranceCoverage: { isVerified: true } },
},
},
},
})
// Assert
expect(wrapper.vm.shouldHideBackButton).toBe(true);
})
test("if claim isn't verified yet => allow user to go back", () => {
// Arrange
const { wrapper } = setupMocks({});
// Assert
expect(wrapper.vm.shouldHideBackButton).toBeFalsy();
})
});
}); });
function setupMocks({ pageHeaderWidgetHeaderText, mountOptionsMockData }) { function setupMocks({ pageHeaderWidgetHeaderText, mountOptionsMockData, funnelCookie = {} }) {
var pageHeaderWidgetHeaderTextDefault = {}; var pageHeaderWidgetHeaderTextDefault = {};
var mountOptionsMockDataDefault = { var mountOptionsMockDataDefault = {
router: { router: {
@ -740,7 +764,7 @@ function setupMocks({ pageHeaderWidgetHeaderText, mountOptionsMockData }) {
settleAllPromises.mockImplementation(() => apiPromise); settleAllPromises.mockImplementation(() => apiPromise);
fetchCmsContentForPage.mockImplementation(() => Promise.resolve()); fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
cookieHelper.getFunnelCookie = jest.spyOn(cookieHelper, "getFunnelCookie").mockReturnValue({}); cookieHelper.getFunnelCookie = jest.spyOn(cookieHelper, "getFunnelCookie").mockReturnValue(funnelCookie);
//Mock damage initialize methods //Mock damage initialize methods
damageLocationQuestion.methods = { damageLocationQuestion.methods = {