From 8c7e1953a96f5911fa91a46b37eee2cf49415566 Mon Sep 17 00:00:00 2001 From: Bryan Mauger Date: Fri, 20 Oct 2023 10:11:15 -0400 Subject: [PATCH] Update unit test. --- src/layouts/vehicle/vehicle.spec.js | 38 ++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/src/layouts/vehicle/vehicle.spec.js b/src/layouts/vehicle/vehicle.spec.js index 56b46292d..e8671b7a8 100644 --- a/src/layouts/vehicle/vehicle.spec.js +++ b/src/layouts/vehicle/vehicle.spec.js @@ -5,17 +5,25 @@ import vehicle from "@/layouts/vehicle/vehicle.vue"; import { shallowMount } from "@vue/test-utils"; import { nextTick } from "vue"; import { getMountOptions } from "@/helpers/unit-test-helper.js"; +import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; +import baseMixin from "../../mixins/base-mixin"; // Mock our module for promises. jest.mock("@/helpers/layout-helper.js", () => ({ settleAllPromises: jest.fn(), })); +// Mock fetchCmsContentForPage +jest.mock("@/helpers/cms-content-helper", () => ({ + fetchCmsContentForPage: jest.fn(), +})); + describe("vehicle.vue", () => { test("arePagePrerequisitesValid should be true ", async () => { //Arrange const { wrapper } = setupMocks(); + //Act let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); await nextTick(); @@ -40,17 +48,25 @@ describe("vehicle.vue", () => { }); function setupMocks() { - const wrapper = shallowMount( - vehicle, - getMountOptions({ - router: { - navigate: jest.fn(), - navigate: jest.fn(), - navigateWithSaving: jest.fn(), - navigateWithoutSaving: jest.fn(), - }, - }) - ); + + const mountOptions = getMountOptions({ + router: { + navigate: jest.fn(), + navigate: jest.fn(), + navigateWithSaving: jest.fn(), + navigateWithoutSaving: jest.fn(), + }, + }); + + //Mock props + const mockMixin = { + methods: { + getCmsContent: jest.fn(), + }, + }; + + mountOptions.mixins = [mockMixin]; + const wrapper = shallowMount(vehicle, mountOptions); return { wrapper }; }