start of unit testing for coverage statement
This commit is contained in:
parent
a933503b04
commit
7310d43c1a
1 changed files with 115 additions and 0 deletions
115
src/layouts/coverage-statement/coverage-statement.spec.js
Normal file
115
src/layouts/coverage-statement/coverage-statement.spec.js
Normal file
|
|
@ -0,0 +1,115 @@
|
||||||
|
// Components
|
||||||
|
import coverageStatement from "@/layouts/coverage-statement/coverage-statement.vue";
|
||||||
|
|
||||||
|
// Supporting Files
|
||||||
|
import { shallowMount } from "@vue/test-utils";
|
||||||
|
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||||
|
import { useMainStore } from "@/store";
|
||||||
|
import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin";
|
||||||
|
import baseFormMixin from "@/mixins/base-form-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("coverage-statement.vue", () => {
|
||||||
|
describe("display correct coverage statement", () => {
|
||||||
|
test("If damage is Repair, display NonADASRepairNextSteps statement", async () => {
|
||||||
|
// Arrange
|
||||||
|
useMainStore().pageData = jest.fn();
|
||||||
|
useMainStore().lineItems = { glassParts: null};
|
||||||
|
useMainStore().order.damage.isRepair = true;
|
||||||
|
|
||||||
|
const { wrapper, cmsContent } = setupMocks({});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Act
|
||||||
|
coverageStatement.beforeRouteEnter.call(
|
||||||
|
wrapper.vm,
|
||||||
|
{ query: { issPage: "coverage-statement" } },
|
||||||
|
undefined,
|
||||||
|
(c) => c(wrapper.vm)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper).toBeVisible();
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function setupMocks({
|
||||||
|
cmsWidgetName = "CMS widget name goes here",
|
||||||
|
mountOptionsMockData = {
|
||||||
|
router: {
|
||||||
|
navigate: jest.fn(),
|
||||||
|
},
|
||||||
|
actionList: [
|
||||||
|
{
|
||||||
|
actionName: "getPartsOrQuestions",
|
||||||
|
data: {},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
route: {
|
||||||
|
query: {
|
||||||
|
issPage: "coverage-statement",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
computedSwitcher: [
|
||||||
|
{
|
||||||
|
glassLocation: "Windshield",
|
||||||
|
glassName: "Single",
|
||||||
|
answerData: {
|
||||||
|
answerResult: "FW04848",
|
||||||
|
answeredQuestions: [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
questionsData: {
|
||||||
|
get() {
|
||||||
|
return this.computedSwitcher;
|
||||||
|
},
|
||||||
|
set(val) {
|
||||||
|
this.computedSwitcher = val;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}) {
|
||||||
|
|
||||||
|
useMainStore().getPartsOrQuestions = jest.fn(() => {
|
||||||
|
return {
|
||||||
|
data: {
|
||||||
|
partsOrQuestions: [],
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const mountOptions = getMountOptions({
|
||||||
|
...mountOptionsMockData,
|
||||||
|
mixins: [baseFormMixin, vehicleQuestionsMixin],
|
||||||
|
});
|
||||||
|
mountOptions["attachTo"] = document.body;
|
||||||
|
|
||||||
|
const wrapper = shallowMount(coverageStatement, mountOptions);
|
||||||
|
|
||||||
|
//Mock CMS content
|
||||||
|
const cmsContent = {
|
||||||
|
Name: cmsWidgetName,
|
||||||
|
};
|
||||||
|
|
||||||
|
return { wrapper, cmsContent };
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in a new issue