Merge pull request #1915 from Safelite/feature/Digital/CSR-2087

csr-2087
This commit is contained in:
hiteshkumar87 2024-07-22 17:38:02 +05:30 committed by GitHub
commit 77b85b6ade
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 11 deletions

View file

@ -215,23 +215,17 @@ describe("estimate.vue", () => {
describe("estimate.vue", () => {
test("should call forwardButtonAction if isLeadGen is true and form is valid", async () => {
// update store with isLeadGen as true
store.getters = {
isLeadGen: true,
leadGenEstimate: {
vinSelection: "decline",
},
};
store.commit(storeMutations.UPDATE_IS_LEAD_GEN, true);
store.commit(storeMutations.UPDATE_LEAD_GEN_VIN_SELECTION, "decline");
// Set up the component
const { wrapper } = setupMocks({});
baseMixin.methods.isFormValid = jest.fn().mockReturnValue(true);
wrapper.vm.forwardButtonAction = jest.fn();
const nextFunction = jest.fn((c) => {
c(wrapper.vm);
});
// Call the method that contains the if-else logic
await estimate.beforeRouteEnter.call(
wrapper.vm,
@ -239,9 +233,13 @@ describe("estimate.vue", () => {
undefined,
nextFunction
);
await nextTick();
await wrapper.vm.$nextTick();
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 });
settleAllPromises.mockImplementation(() => apiPromise);
fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
baseMixin.methods.isFormValid = jest.fn().mockReturnValue(true);
const mountOptions = getMountOptions({
...mountOptionsMockData,
mixins: [baseMixin, mockMixin],

View file

@ -705,6 +705,10 @@ describe("quote.vue", () => {
);
await nextTick();
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.isFormValid = jest.fn().mockReturnValue(true);
mountOptions.global.mocks["$store"] = store;
mountOptions["attachTo"] = document.body;
const wrapper = shallowMount(quote, mountOptions);