csr-2087
estimate and quote page unit test
This commit is contained in:
parent
f89581abab
commit
883b7b0916
2 changed files with 14 additions and 11 deletions
|
|
@ -215,23 +215,17 @@ describe("estimate.vue", () => {
|
||||||
|
|
||||||
describe("estimate.vue", () => {
|
describe("estimate.vue", () => {
|
||||||
test("should call forwardButtonAction if isLeadGen is true and form is valid", async () => {
|
test("should call forwardButtonAction if isLeadGen is true and form is valid", async () => {
|
||||||
// update store with isLeadGen as true
|
store.commit(storeMutations.UPDATE_IS_LEAD_GEN, true);
|
||||||
store.getters = {
|
store.commit(storeMutations.UPDATE_LEAD_GEN_VIN_SELECTION, "decline");
|
||||||
isLeadGen: true,
|
|
||||||
leadGenEstimate: {
|
|
||||||
vinSelection: "decline",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// Set up the component
|
// Set up the component
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
baseMixin.methods.isFormValid = jest.fn().mockReturnValue(true);
|
|
||||||
wrapper.vm.forwardButtonAction = jest.fn();
|
wrapper.vm.forwardButtonAction = jest.fn();
|
||||||
|
|
||||||
const nextFunction = jest.fn((c) => {
|
const nextFunction = jest.fn((c) => {
|
||||||
c(wrapper.vm);
|
c(wrapper.vm);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Call the method that contains the if-else logic
|
// Call the method that contains the if-else logic
|
||||||
await estimate.beforeRouteEnter.call(
|
await estimate.beforeRouteEnter.call(
|
||||||
wrapper.vm,
|
wrapper.vm,
|
||||||
|
|
@ -239,9 +233,13 @@ describe("estimate.vue", () => {
|
||||||
undefined,
|
undefined,
|
||||||
nextFunction
|
nextFunction
|
||||||
);
|
);
|
||||||
await nextTick();
|
await wrapper.vm.$nextTick();
|
||||||
|
|
||||||
expect(nextFunction).toHaveBeenCalled();
|
expect(nextFunction).toHaveBeenCalled();
|
||||||
|
expect(baseMixin.methods.isFormValid).toHaveBeenCalled();
|
||||||
|
expect(baseMixin.methods.isFormValid()).toBe(true);
|
||||||
|
await wrapper.vm.$nextTick();
|
||||||
|
expect(wrapper.vm.forwardButtonAction).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -287,7 +285,7 @@ function setupMocks({
|
||||||
const apiPromise = Promise.resolve({ cmsContent });
|
const apiPromise = Promise.resolve({ cmsContent });
|
||||||
settleAllPromises.mockImplementation(() => apiPromise);
|
settleAllPromises.mockImplementation(() => apiPromise);
|
||||||
fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
|
fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
|
||||||
|
baseMixin.methods.isFormValid = jest.fn().mockReturnValue(true);
|
||||||
const mountOptions = getMountOptions({
|
const mountOptions = getMountOptions({
|
||||||
...mountOptionsMockData,
|
...mountOptionsMockData,
|
||||||
mixins: [baseMixin, mockMixin],
|
mixins: [baseMixin, mockMixin],
|
||||||
|
|
|
||||||
|
|
@ -705,6 +705,10 @@ describe("quote.vue", () => {
|
||||||
);
|
);
|
||||||
await nextTick();
|
await nextTick();
|
||||||
expect(nextFunction).toHaveBeenCalled();
|
expect(nextFunction).toHaveBeenCalled();
|
||||||
|
expect(baseMixin.methods.isFormValid).toHaveBeenCalled();
|
||||||
|
expect(baseMixin.methods.isFormValid()).toBe(true);
|
||||||
|
await wrapper.vm.$nextTick();
|
||||||
|
expect(wrapper.vm.forwardButtonAction).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -714,6 +718,7 @@ function setupMocks({ customMountOptions }) {
|
||||||
});
|
});
|
||||||
|
|
||||||
baseMixin.methods.hideFmgLoadingModal = jest.fn();
|
baseMixin.methods.hideFmgLoadingModal = jest.fn();
|
||||||
|
baseMixin.methods.isFormValid = jest.fn().mockReturnValue(true);
|
||||||
mountOptions.global.mocks["$store"] = store;
|
mountOptions.global.mocks["$store"] = store;
|
||||||
mountOptions["attachTo"] = document.body;
|
mountOptions["attachTo"] = document.body;
|
||||||
const wrapper = shallowMount(quote, mountOptions);
|
const wrapper = shallowMount(quote, mountOptions);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue