SSR-305
update welcome-vue and unit test case
This commit is contained in:
parent
1d400fe55c
commit
8589ad2583
2 changed files with 17 additions and 13 deletions
|
|
@ -8,26 +8,28 @@ import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
|||
import baseMixin from "@/mixins/base-mixin.js";
|
||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||
import { applicationConfig } from "@/constants/application-config";
|
||||
|
||||
// Mock our module for promises.
|
||||
jest.mock("@/helpers/layout-helper.js", () => ({
|
||||
settleAllPromises: jest.fn(),
|
||||
settleAllPromises: jest.fn(),
|
||||
}));
|
||||
|
||||
// Mock fetchCmsContentForPage
|
||||
jest.mock("@/helpers/cms-content-helper", () => ({
|
||||
fetchCmsContentForPage: jest.fn(),
|
||||
fetchCmsContentForPage: jest.fn()
|
||||
}));
|
||||
|
||||
|
||||
describe("welcome-page.vue", () => {
|
||||
test("Should render welcomePage sub-components (policyNumber, policyZipCode, dateOfLoss, damageCause etc.)", async () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
// Arrange
|
||||
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
|
||||
// Act
|
||||
const policyNumber = wrapper.findComponent({ ref: "policyNumber" });
|
||||
const dateOfLoss = wrapper.findComponent({ ref: "dateOfLoss" });
|
||||
const damageCause = wrapper.findComponent({ ref: "damageCause" });
|
||||
const damageCause = wrapper.findComponent({ ref: "damageCause" });
|
||||
const damageCity = wrapper.findComponent({ ref: "damageCity" });
|
||||
const state = wrapper.findComponent({ ref: "state" });
|
||||
const glassOnlyDamage = wrapper.findComponent({ ref: "glassOnlyDamage" });
|
||||
|
|
@ -39,8 +41,8 @@ describe("welcome-page.vue", () => {
|
|||
expect(policyNumber.exists()).toBe(true);
|
||||
expect(dateOfLoss.exists()).toBe(true);
|
||||
expect(damageCause.exists()).toBe(true);
|
||||
expect(damageCity.exists()).toBe(true);
|
||||
expect(state.exists()).toBe(true);
|
||||
expect(damageCity.exists()).toBe(false);
|
||||
expect(state.exists()).toBe(false);
|
||||
expect(glassOnlyDamage.exists()).toBe(true);
|
||||
expect(phoneNumber.exists()).toBe(true);
|
||||
expect(email.exists()).toBe(true);
|
||||
|
|
@ -68,12 +70,14 @@ function setupMocks({
|
|||
|
||||
},
|
||||
};
|
||||
|
||||
//const $root = 'some test value or jasmine spy'
|
||||
mountOptionsMockData = {
|
||||
...mountOptionsMockData,
|
||||
router: {
|
||||
navigate: jest.fn(),
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
||||
const apiPromise = Promise.resolve(apiResponses);
|
||||
|
|
@ -86,7 +90,7 @@ function setupMocks({
|
|||
const wrapper = shallowMount(welcomePage, mountOptions);
|
||||
|
||||
wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent;
|
||||
|
||||
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => "");
|
||||
return { wrapper, apiPromise };
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -324,10 +324,10 @@
|
|||
},
|
||||
},
|
||||
displayDamageCityQuestion(){
|
||||
return !!this.$root.cmsContentByWidget.DamageCityQuestion;
|
||||
return !!this.getCmsContent("DamageCityQuestion","QuestionText");
|
||||
},
|
||||
displayDamageStateQuestion(){
|
||||
return !!this.$root.cmsContentByWidget.DamageStateQuestion;
|
||||
displayDamageStateQuestion(){
|
||||
return !!this.getCmsContent("DamageStateQuestion","QuestionText");
|
||||
},
|
||||
},
|
||||
components: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue