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", () => {
test.only("if claim registration is delayed => should hide back button", () => {
test("if claim registration is delayed => should hide back button", () => {
// Arrange
const { wrapper } = setupMocks({});
cookieHelper.getFunnelCookie = jest.spyOn(cookieHelper, "getFunnelCookie").mockReturnValue({
HasDelayedClaimRegistration: true
const { wrapper } = setupMocks({
funnelCookie: {
HasDelayedClaimRegistration: true
}
});
// 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 mountOptionsMockDataDefault = {
router: {
@ -740,7 +764,7 @@ function setupMocks({ pageHeaderWidgetHeaderText, mountOptionsMockData }) {
settleAllPromises.mockImplementation(() => apiPromise);
fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
cookieHelper.getFunnelCookie = jest.spyOn(cookieHelper, "getFunnelCookie").mockReturnValue({});
cookieHelper.getFunnelCookie = jest.spyOn(cookieHelper, "getFunnelCookie").mockReturnValue(funnelCookie);
//Mock damage initialize methods
damageLocationQuestion.methods = {