// Components import confirmation from "@/layouts/confirmation/confirmation.vue"; // Supporting Files import { shallowMount } from "@vue/test-utils"; import { nextTick } from "vue"; import { getMountOptions } from "@/helpers/unit-test-helper.js"; import store from "@/store"; // Mock our module for promises. jest.mock("@/helpers/layout-helper.js", () => ({ settleAllPromises: jest.fn(), })); beforeEach(() => { jest.restoreAllMocks(); jest.clearAllMocks(); store.getters = { order: { schedule: { date: "2019-01-01", startTime: "09:00", endTime: "10:00", routeCode: "000", }, lineItems: { glassParts: [ { partNumber: "ABC123", }, ], supportingItems: [], }, serviceLocation: { address: "", address2: null, city: "", state: "AZ", appointmentType: "Inshop", zipCode: "12345", zipCodeCtu: "01234", provider: { providerNumber: "123", address: { streetAddress: "test1", city: "test", state: "AZ", zipCode: "12345", zipCodeCtu: "01234", }, }, }, damage: { isRepair: false, }, referralNumber: "1234567", }, payment: { isInsurance: true, }, lineItems: { glassParts: [], supportingItems: [], }, }; }); afterEach(() => { store.getters = {}; jest.restoreAllMocks(); jest.clearAllMocks(); }); describe("confirmation.vue", () => { test("arePagePrerequisitesValid should be true ", async () => { //Arrange const { wrapper } = setupMocks(); //Act let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); await nextTick(); //Assert expect(arePagePrerequisitesValid).toBe(true); }); }); function setupMocks() { const wrapper = shallowMount( confirmation, getMountOptions({ router: { navigate: jest.fn(), navigate: jest.fn(), navigateWithSaving: jest.fn(), navigateWithoutSaving: jest.fn(), }, }) ); return { wrapper }; }