Update unit test.
This commit is contained in:
parent
61c2c039cc
commit
8c7e1953a9
1 changed files with 27 additions and 11 deletions
|
|
@ -5,17 +5,25 @@ import vehicle from "@/layouts/vehicle/vehicle.vue";
|
||||||
import { shallowMount } from "@vue/test-utils";
|
import { shallowMount } from "@vue/test-utils";
|
||||||
import { nextTick } from "vue";
|
import { nextTick } from "vue";
|
||||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
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.
|
// Mock our module for promises.
|
||||||
jest.mock("@/helpers/layout-helper.js", () => ({
|
jest.mock("@/helpers/layout-helper.js", () => ({
|
||||||
settleAllPromises: jest.fn(),
|
settleAllPromises: jest.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// Mock fetchCmsContentForPage
|
||||||
|
jest.mock("@/helpers/cms-content-helper", () => ({
|
||||||
|
fetchCmsContentForPage: jest.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
describe("vehicle.vue", () => {
|
describe("vehicle.vue", () => {
|
||||||
test("arePagePrerequisitesValid should be true ", async () => {
|
test("arePagePrerequisitesValid should be true ", async () => {
|
||||||
//Arrange
|
//Arrange
|
||||||
const { wrapper } = setupMocks();
|
const { wrapper } = setupMocks();
|
||||||
|
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
||||||
await nextTick();
|
await nextTick();
|
||||||
|
|
@ -40,17 +48,25 @@ describe("vehicle.vue", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
function setupMocks() {
|
function setupMocks() {
|
||||||
const wrapper = shallowMount(
|
|
||||||
vehicle,
|
const mountOptions = getMountOptions({
|
||||||
getMountOptions({
|
router: {
|
||||||
router: {
|
navigate: jest.fn(),
|
||||||
navigate: jest.fn(),
|
navigate: jest.fn(),
|
||||||
navigate: jest.fn(),
|
navigateWithSaving: jest.fn(),
|
||||||
navigateWithSaving: jest.fn(),
|
navigateWithoutSaving: jest.fn(),
|
||||||
navigateWithoutSaving: jest.fn(),
|
},
|
||||||
},
|
});
|
||||||
})
|
|
||||||
);
|
//Mock props
|
||||||
|
const mockMixin = {
|
||||||
|
methods: {
|
||||||
|
getCmsContent: jest.fn(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
mountOptions.mixins = [mockMixin];
|
||||||
|
const wrapper = shallowMount(vehicle, mountOptions);
|
||||||
|
|
||||||
return { wrapper };
|
return { wrapper };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue