This commit is contained in:
Kulbhushan Kaushik 2022-12-05 14:51:22 -05:00
parent 3efb2f6e15
commit b770d9c078
2 changed files with 12 additions and 6 deletions

View file

@ -61,7 +61,7 @@ const basePartResponse = {
}; };
describe("vehicle-parts.vue", () => { describe("vehicle-parts.vue", () => {
test("Set cms content called on load", async (done) => { test("Set cms content called on load", async () => {
//Arrange //Arrange
useMainStore().pageData = jest.fn(); useMainStore().pageData = jest.fn();
useMainStore().pageData.mockReturnValue(basePartResponse); useMainStore().pageData.mockReturnValue(basePartResponse);
@ -95,7 +95,6 @@ describe("vehicle-parts.vue", () => {
//Assert //Assert
apiPromise.finally(() => { apiPromise.finally(() => {
expect(wrapper.vm.setCmsContent).toHaveBeenCalled(); expect(wrapper.vm.setCmsContent).toHaveBeenCalled();
done();
}); });
}); });
@ -104,6 +103,7 @@ describe("vehicle-parts.vue", () => {
useMainStore().pageData = jest.fn(); useMainStore().pageData = jest.fn();
useMainStore().pageData.mockReturnValue(basePartResponse); useMainStore().pageData.mockReturnValue(basePartResponse);
useMainStore().lineItems = { glassParts: null }; useMainStore().lineItems = { glassParts: null };
useMainStore().damage.isRepair = false;
const { wrapper } = setupMocks({ const { wrapper } = setupMocks({
mountOptionsMockData: { mountOptionsMockData: {
@ -202,7 +202,7 @@ describe("vehicle-parts.vue", () => {
//Assert //Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith( expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_BACK_WITH_PART_QUESTIONS, navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS,
wrapper.vm.$route wrapper.vm.$route
); );
}); });
@ -234,7 +234,7 @@ describe("vehicle-parts.vue", () => {
//Assert //Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith( expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS, navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS,
wrapper.vm.$route wrapper.vm.$route
); );
}); });
@ -371,6 +371,7 @@ describe("vehicle-parts.vue", () => {
(c) => c(wrapper.vm) (c) => c(wrapper.vm)
); );
await wrapper.vm.forwardButtonAction(); await wrapper.vm.forwardButtonAction();
//Assert //Assert
@ -401,11 +402,16 @@ function setupMocks({ pageHeaderWidgetHeaderText = {}, mountOptionsMockData = {}
}, },
}; };
const store = useMainStore();
let actionResult = [];
store.getCapabilityQuestions.mockImplementation(() => Promise.resolve({data: actionResult,}));
const apiPromise = Promise.resolve(apiResponses); const apiPromise = Promise.resolve(apiResponses);
settleAllPromises.mockImplementation(() => apiPromise); settleAllPromises.mockImplementation(() => apiPromise);
fetchCmsContentForPage.mockImplementation(() => Promise.resolve()); fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
const mountOptions = getMountOptions(mountOptionsMockData); const mountOptions = getMountOptions(mountOptionsMockData);
const wrapper = shallowMount(vehicleParts, mountOptions); const wrapper = shallowMount(vehicleParts, mountOptions);

View file

@ -405,7 +405,7 @@ export default {
// mimic part-questions page data for consistency // mimic part-questions page data for consistency
for (let partOrQuestion of partsOrQuestions) { for (let partOrQuestion of partsOrQuestions) {
if (this.hasCapabilityQuestions([partOrQuestion])) { if (this.hasCapabilityQuestions([partOrQuestion])) {
let capabilityQuestionsForGlassLocation = (await this.mainStore.getCapabilityQuestions(this.mainStore.vehicle.carId, partOrQuestion.parts[0].partNumber)).data; let capabilityQuestionsForGlassLocation = (await useMainStore().getCapabilityQuestions(useMainStore().vehicle.carId, partOrQuestion.parts[0].partNumber)).data;
capabilityQuestionsForGlassLocation.forEach((question) => { capabilityQuestionsForGlassLocation.forEach((question) => {
question.answers = question.answers.map((answer) => { question.answers = question.answers.map((answer) => {
@ -432,7 +432,7 @@ export default {
const collectedGlassParts = this.reducedGlassPartsArray(partsOrQuestions); const collectedGlassParts = this.reducedGlassPartsArray(partsOrQuestions);
// save to store lineItems.glassParts // save to store lineItems.glassParts
self.mainStore.updateGlassParts(collectedGlassParts); useMainStore().updateGlassParts(collectedGlassParts);
self.$router.navigate(self.navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,self.$route); self.$router.navigate(self.navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,self.$route);
} }