import globalMethods from "@/global-methods"; import { mutations, state, actions, getters } from "@/store"; import { storeMutations } from "@/constants/store-mutations"; import { storeActions } from "@/constants/store-actions"; import { experimentTriggers } from "@/constants/experiments"; import { fmgPageValues } from "@/router/router-constants/fmgPage-values"; // Mock global method globalMethods.callHttpClient = jest.fn(); describe("Mutations", () => { it("Updates vehicle year in state", () => { // Arrange const storeState = state; // Act mutations.updateYear(storeState, "2019"); // Assert expect(storeState.order.vehicle.year).toEqual("2019"); }); it("Updates vehicle make in state", () => { // Arrange const storeState = state; // Act mutations.updateMake(storeState, "Acura"); // Assert expect(storeState.order.vehicle.make).toEqual("Acura"); }); it("Updates vehicle model in state", () => { // Arrange const storeState = state; // Act mutations.updateModel(storeState, "ILX"); // Assert expect(storeState.order.vehicle.model).toEqual("ILX"); }); it("Updates vehicle style in state", () => { // Arrange const storeState = state; // Act mutations.updateStyle(storeState, "4 DOOR SEDAN"); // Assert expect(storeState.order.vehicle.style).toEqual("4 DOOR SEDAN"); }); it("Updates vehicle carId in state", () => { // Arrange const storeState = state; // Act mutations.updateCarId(storeState, "C0000001"); // Assert expect(storeState.order.vehicle.carId).toEqual("C0000001"); }); it("Updates vehicle vehicle category in state", () => { // Arrange const storeState = state; // Act mutations.updateVehicleCategory(storeState, "CAR"); // Assert expect(storeState.order.vehicle.category).toEqual("CAR"); }); it("Remove item to eventBus in state", () => { // Arrange const storeState = state; const event = { category: "CategoryOne", subCategory: "SubCategoryOne" }; // Act / Assert mutations.addEventToBus(storeState, event); expect(storeState.applicationUser.eventBus).toEqual([event]); // Act / Assert mutations.removeEventFromBus(storeState, event); expect(storeState.applicationUser.eventBus).toEqual([]); }); it("Adds item to eventBus in state", () => { // Arrange const storeState = state; // Act mutations.addEventToBus(storeState, { EventOne: "ValueOne" }); // Assert expect(storeState.applicationUser.eventBus).toEqual([{ EventOne: "ValueOne" }]); }); it("resetVehicleState, should set fields to null", () => { // Arrange const storeState = state; mutations.updateYear(storeState, "2019"); mutations.updateMake(storeState, "Acura"); mutations.updateModel(storeState, "ILX"); mutations.updateStyle(storeState, "4 DOOR SEDAN"); mutations.updateCarId(storeState, "C0000001"); mutations.updateVehicleCategory(storeState, "CAR"); // Expect expect(storeState.order.vehicle.year).toEqual("2019"); expect(storeState.order.vehicle.make).toEqual("Acura"); expect(storeState.order.vehicle.model).toEqual("ILX"); expect(storeState.order.vehicle.style).toEqual("4 DOOR SEDAN"); expect(storeState.order.vehicle.carId).toEqual("C0000001"); expect(storeState.order.vehicle.category).toEqual("CAR"); // Act mutations.resetVehicleState(storeState); // Expect expect(storeState.order.vehicle.year).toEqual(null); expect(storeState.order.vehicle.make).toEqual(null); expect(storeState.order.vehicle.model).toEqual(null); expect(storeState.order.vehicle.style).toEqual(null); expect(storeState.order.vehicle.carId).toEqual(null); expect(storeState.order.vehicle.category).toEqual(null); }); it("resetDamageState, should set fields to null", () => { // Arrange const storeState = state; storeState.order.damage = { isRepair: true, numberOfChips: 2, glassToReplace: [{ location: "Rear", name: "Stationary" }], }; // Expect expect(storeState.order.damage.isRepair).toEqual(true); expect(storeState.order.damage.numberOfChips).toEqual(2); expect(storeState.order.damage.glassToReplace).toStrictEqual([ { location: "Rear", name: "Stationary" }, ]); // Act mutations.resetDamageState(storeState); // Expect expect(storeState.order.damage.isRepair).toEqual(null); expect(storeState.order.damage.numberOfChips).toEqual(null); expect(storeState.order.damage.glassToReplace).toEqual(null); }); it("Updates number of chips in state", () => { // Arrange const storeState = state; // Act mutations.updateNumberOfChips(storeState, "1"); // Assert expect(storeState.order.damage.numberOfChips).toEqual("1"); }); it("Updates glass to replace in state", () => { // Arrange const storeState = state; // Act mutations.updateGlassToReplace(storeState, ["Windshield"]); // Assert expect(storeState.order.damage.glassToReplace).toEqual(["Windshield"]); }); it("Updates Parts in state", () => { // Arrange const storeState = state; // Act mutations.updateGlassParts(storeState, { "Windshield-Single": "PARTNUM101" }); // Assert expect(storeState.order.lineItems.glassParts).toEqual({ "Windshield-Single": "PARTNUM101", }); }); it("Updates page data in state", () => { // Arrange const storeState = state; // Act mutations.updatePageData(storeState, { page: "vehicle-year", data: {} }); // Assert expect(storeState.applicationUser.pageData["vehicle-year"]).toEqual({}); }); it("updateStateWithSessonInformation, should set session information in state", () => { // Arrange const storeState = state; // Act mutations.updateStateWithOrderInformation(storeState, { order: { referralNumber: 123, referralDate: new Date().toUTCString(), referralCorrelationId: "xxx-xxx-xxx", vehicle: { year: "2019", make: "Acura", model: "ILX", style: "4 DOOR SEDAN", carId: "C0000001", category: "CAR", registration: {}, }, damage: { glassToReplace: ["Windshield"], isRepair: false, numberOfChips: 0, }, lineItems: { glassParts: null, }, payment: { insuranceCoverage: { isVerified: false, }, isInsurance: false, }, parts: [], accountNumber: "123456789", insuranceInfo: {}, serviceLocation: {}, customer: {}, }, applicationUser: { experiments: [ { universeName: "Concept Funnel Test With Rules", universeId: 463, testName: "Concept Dev Test", testId: 392, variationName: "Concept Test Variation", variationId: 1133, isActive: false, isExposed: true, userPartitionNumber: 84, assignmentId: 12211739, settings: { someKey: "false", sampleSetting: "Hi, my name is Vidya", }, }, ], }, }); // Assert expect(storeState.order.referralNumber).toEqual(123); expect(storeState.order.referralCorrelationId).toEqual("xxx-xxx-xxx"); expect(storeState.order.vehicle.year).toEqual("2019"); expect(storeState.order.vehicle.make).toEqual("Acura"); expect(storeState.order.vehicle.model).toEqual("ILX"); }); it("updateInsuranceVerifiedStatus, should set isVerified flag", () => { // Arrange const storeState = state; // Act mutations.updateInsuranceVerifiedStatus(storeState, true); // Assert expect(storeState.order.payment.insuranceCoverage.isVerified).toEqual(true); }); it("updateExperiments, should set experiments", () => { // Arrange const storeState = state; const mockExperimentsList = [ { universeName: "XYZ", settings: { ExperimentSetting: "ExperimentValue", }, }, ]; // Act mutations.updateExperiments(storeState, mockExperimentsList); // Assert expect(storeState.applicationUser.experiments).toEqual(mockExperimentsList); }); it("updateTriggeredSiteEntry, should set triggeredSiteEntry", () => { // Arrange const storeState = state; // Act mutations.updateTriggeredSiteEntry(storeState, true); // Assert expect(storeState.applicationUser.triggeredSiteEntry).toEqual(true); }); it("updateServiceLocation, should set serviceLocation in state", () => { // Arrange const storeState = state; const serviceLocation = { address: "123 Test Lane", city: "Columbus", zipCode: "43212", state: "OH", zipCodeCtu: "01820", }; // Act mutations.updateServiceLocation(storeState, serviceLocation); // Assert expect(storeState.order.serviceLocation.address).toEqual("123 Test Lane"); expect(storeState.order.serviceLocation.city).toEqual("Columbus"); expect(storeState.order.serviceLocation.zipCode).toEqual("43212"); expect(storeState.order.serviceLocation.state).toEqual("OH"); expect(storeState.order.serviceLocation.zipCodeCtu).toEqual("01820"); }); }); describe("Actions", () => { it("getVehicleYears action, should return years array", async () => { // Arrange const context = state; // Act globalMethods.callHttpClient.mockImplementation(() => { return Promise.resolve({ data: [2023, 2022, 2021] }); }); // Assert const response = await actions.getVehicleYears(context); expect(response.data).toEqual([2023, 2022, 2021]); }); it("lookupVehicleByYmms action, should return car data", async () => { // Arrange const context = state; // Act globalMethods.callHttpClient.mockImplementation(() => { return Promise.resolve({ data: { carId: "C00000001" } }); }); // Assert const response = await actions.lookupVehicleByYmms( context, "2019", "Acura", "ILX", "4 DOOR SEDAN" ); expect(response.data).toEqual({ carId: "C00000001" }); }); it("lookupVehicleByVin action, should return car data", async () => { // Arrange const context = state; // Act globalMethods.callHttpClient.mockImplementation(() => { return Promise.resolve({ data: { carId: "C0000001" } }); }); // Assert const response = await actions.lookupVehicleByVin(context, "12345678901234567"); expect(response.data).toEqual({ carId: "C0000001" }); }); it("lookupVinByPlate action, should return car data", async () => { // Arrange const context = state; // Act globalMethods.callHttpClient.mockImplementation(() => { return Promise.resolve({ data: { carId: "C00000001" } }); }); // Assert const response = await actions.lookupVinByPlate(context, "12345678901234567"); expect(response.data).toEqual({ carId: "C00000001" }); }); it("getVehicleMakes action, should return makes list", async () => { // Arrange const context = state; // Act globalMethods.callHttpClient.mockImplementation(() => { return Promise.resolve({ data: ["Acura", "Honda"] }); }); // Assert const response = await actions.getVehicleMakes(context, "2019"); expect(response.data).toEqual(["Acura", "Honda"]); }); it("getVehicleModels action, should return models list", async () => { // Arrange const context = state; // Act globalMethods.callHttpClient.mockImplementation(() => { return Promise.resolve({ data: ["ILX", "RDX"] }); }); // Assert const response = await actions.getVehicleModels(context, "2019", "Acura"); expect(response.data).toEqual(["ILX", "RDX"]); }); it("getVehicleStyles action, should return models list", async () => { // Arrange const context = state; // Act globalMethods.callHttpClient.mockImplementation(() => { return Promise.resolve({ data: { style: "4 DOOR SEDAN" } }); }); // Assert const response = await actions.getVehicleStyles(context, "2019", "Acura", "ILX"); expect(response.data).toEqual({ style: "4 DOOR SEDAN" }); }); it("setVehicle action, should get vehicle data and set carId and vehicle category", async () => { // Arrange const context = state; const commit = jest.fn(); context.commit = commit; // Act globalMethods.callHttpClient.mockImplementation(() => { return Promise.resolve({ data: { carId: "C00000000", category: "CAR" } }); }); // Assert const response = await actions.setVehicle(context, "C00000000"); expect(commit).toBeCalledWith(storeMutations.UPDATE_CAR_ID, "C00000000"); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_CATEGORY, "CAR"); expect(response.data).toEqual({ carId: "C00000000", category: "CAR" }); }); it("getDamageOptions action", async () => { // Arrange const context = state; // Act globalMethods.callHttpClient.mockImplementation(() => { return Promise.resolve({ data: ["Windshield", "DriversFrontDoor"] }); }); const response = await actions.getDamageOptions(context, "C00000000"); // Assert expect(response.data).toEqual(["Windshield", "DriversFrontDoor"]); }); it("validateZip action", async () => { // Arrange const context = state; // Act globalMethods.callHttpClient.mockImplementation(() => { return Promise.resolve({ data: { isValid: true, isServiceable: true, state: "OH", zipCodeCtu: "01820", }, }); }); const response = await actions.validateZip(context, "43212"); // Assert expect(response.data).toEqual({ isValid: true, isServiceable: true, state: "OH", zipCodeCtu: "01820", }); }); it("resetDamageAndDependencies action", async () => { // Arrange const context = state; const commit = jest.fn(); context.commit = commit; // Act await actions.resetDamageAndDependencies(context); expect(commit).toBeCalledWith(storeMutations.RESET_DAMAGE_STATE); expect(commit).toBeCalledWith(storeMutations.RESET_GLASS_PARTS_STATE); }); it("resetRegistrationAndDependencies action", async () => { // Arrange const context = state; const commit = jest.fn(); context.commit = commit; // Act await actions.resetRegistrationAndDependencies(context); expect(commit).toBeCalledWith(storeMutations.RESET_REGISTRATION_STATE); expect(commit).toBeCalledWith(storeMutations.RESET_GLASS_PARTS_STATE); }); it("resetPartsAndDependencies action", async () => { // Arrange const context = state; const commit = jest.fn(); context.commit = commit; // Act await actions.resetPartsAndDependencies(context); expect(commit).toBeCalledWith(storeMutations.RESET_GLASS_PARTS_STATE); }); it("resetState action", async () => { // Arrange const context = state; const commit = jest.fn(); context.commit = commit; // Act await actions.resetState(context); expect(commit).toBeCalledWith(storeMutations.RESET_STATE); }); it("getRouteInfo action, returns route info", async () => { // Arrange const context = state; globalMethods.callHttpClient.mockImplementation(() => { return Promise.resolve({ data: { Widget: "Data" } }); }); // Act const response = await actions.getRouteInfo(context, "vehicle-year"); expect(response.data).toEqual({ Widget: "Data" }); }); it("getHomepageName action, returns homepage name", async () => { // Arrange const context = state; globalMethods.callHttpClient.mockImplementation(() => { return Promise.resolve({ data: { Name: "vehicle-year" } }); }); // Act const response = await actions.getHomepageName(context); expect(response.data).toEqual({ Name: "vehicle-year" }); }); it("getPageData action, returns page data", async () => { // Arrange const context = state; globalMethods.callHttpClient.mockImplementation(() => { return Promise.resolve({ data: { Results: [{ Widget: "Data" }] } }); }); // Act const response = await actions.getPageData(context, "vehicle-year"); expect(response.data).toEqual({ Results: [{ Widget: "Data" }] }); }); it("getEvoxImage action, returns image url", async () => { // Arrange const context = state; globalMethods.callHttpClient.mockImplementation(() => { return Promise.resolve({ data: { imageUrl: "https://test.com" } }); }); // Act const response = await actions.getEvoxImage(context, { relativeUrl: "https://relativeurl.com", }); expect(response.data).toEqual({ imageUrl: "https://test.com" }); }); it("saveSession action, returns order information", async () => { // Arrange const context = state; context.getters = { vehicle: { registration: {}, }, order: { damage: { numberOfChips: "2", partQuestionAnswers: {}, moldingQuestionAnswers: {}, capabilityQuestionAnswers: {}, }, }, damage: {}, applicationUser: { lastPageVisited: "test-page", crmCustomerId: "xxx-xxx-xxx", savedSessionId: "xxx-xxx-xxx", }, }; context.state = { order: { damage: { numberOfChips: "2", partQuestionAnswers: {}, moldingQuestionAnswers: {}, capabilityQuestionAnswers: {}, }, payment: { insuranceCoverage: { isVerified: false, }, isInsurance: false, }, serviceLocation: {}, customer: {}, lineItems: {}, }, }; globalMethods.callHttpClient.mockImplementation(() => { return Promise.resolve({ data: { referralNumber: 123 } }); }); // Act const response = await actions.saveSession(context); // Assert expect(response.data).toEqual({ referralNumber: 123 }); }); it("loadSession action, returns order information, calls mutation", async () => { // Arrange const context = state; globalMethods.callHttpClient.mockImplementation(() => { return Promise.resolve({ data: { referralNumber: 123, order: {} } }); }); const commit = jest.fn(); context.commit = commit; // Act const response = await actions.loadSession(context, { savedSessionId: "", }); // Assert expect(response.data).toEqual({ referralNumber: 123, order: {} }); expect(commit).toBeCalledWith(storeMutations.UPDATE_STATE_WITH_ORDER_INFORMATION, { referralNumber: 123, order: {}, }); }); it("loadSession: state doesn't have EON => do not reset state", async () => { // Arrange const context = state; globalMethods.callHttpClient.mockImplementation(() => { return Promise.resolve({ data: { eon: "123", order: {} } }); }); context.commit = jest.fn(); context.state = { order: {}, }; // Act const response = await actions.loadSession(context, { savedSessionId: "", }); // Assert expect(response.data.eon).toEqual("123"); expect(context.commit).not.toBeCalledWith(storeMutations.RESET_STATE); }); it("loadSession eon doesn't match eon in state => reset state", async () => { // Arrange const context = state; globalMethods.callHttpClient.mockImplementation(() => { return Promise.resolve({ data: { eon: "123", order: {} } }); }); context.commit = jest.fn(); context.state = { order: { eon: "456", }, }; // Act const response = await actions.loadSession(context, { savedSessionId: "", }); // Assert expect(response.data.eon).toEqual("123"); expect(context.commit).toBeCalledWith(storeMutations.RESET_STATE); }); it("updateStoreWithSaveSessionResponse, should call commit six times", () => { // Arrange const context = state; const commit = jest.fn(); context.commit = commit; // Act actions.updateStoreWithSaveSessionResponse(context, { referralNumber: "123", referralDate: new Date().toUTCString(), referralCorrelationId: "xxx-xxx-xxx", accountNumber: "167132", savedSessionId: "xxx-xxx-xxx", crmCustomerId: "xxx-xxx-xxx", }); // Assert expect(commit).toBeCalledWith(storeMutations.UPDATE_REFERRAL_NUMBER, "123"); expect(commit).toBeCalledWith( storeMutations.UPDATE_REFERRAL_DATE, new Date().toUTCString() ); expect(commit).toBeCalledWith(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, "xxx-xxx-xxx"); expect(commit).toBeCalledWith(storeMutations.UPDATE_PARENT_ACCT_NUMBER, "167132"); expect(commit).toBeCalledWith(storeMutations.UPDATE_SAVED_SESSION_ID, "xxx-xxx-xxx"); expect(commit).toBeCalledWith(storeMutations.UPDATE_CRM_CUSTOMER_ID, "xxx-xxx-xxx"); }); it("logPageView action, should return nothing", async () => { // Arrange const context = state; var pageEvent = { action: "", event: "ENTRY", }; // Act globalMethods.callHttpClient.mockImplementation(() => { return Promise.resolve({}); }); // Assert const response = await actions.logPageView(context, { userId: "userId", sessionKey: "sessionKey", pageName: "pageName", sessionId: "sessionId", pageEvent: pageEvent, shouldUseSessionId: false, }); expect(response).toEqual({}); }); it("logCustomEvent action, should return nothing", async () => { // Arrange const context = state; var customEvent = { category: "tstCat", action: "click", label: "damage", value: "psych", }; // Act globalMethods.callHttpClient.mockImplementation(() => { return Promise.resolve({}); }); // Assert const response = await actions.logCustomEvent(context, { userId: "userId", sessionKey: "sessionKey", pageName: "pageName", sessionId: "sessionId", customEvent: customEvent, shouldUseSessionId: false, }); expect(response).toEqual({}); }); it("initializeSession action, should return nothing", async () => { // Arrange const context = state; // Act globalMethods.callHttpClient.mockImplementation(() => { return Promise.resolve({}); }); // Assert const response = await actions.initializeSession(context, { userId: "userId", sessionId: "", userAgent: "", referrer: "", shouldUseSessionId: false, }); expect(response).toEqual({}); }); it("saveVin, should call mutation when CarId is different and selectedGlass is not available for vehicle", () => { // Arrange const context = state; context.state = { order: { vehicle: { vin: "YYYYY", }, }, }; const commit = jest.fn(); const dispatch = jest.fn(); context.commit = commit; context.dispatch = dispatch; // Act actions.saveVin(context, { isCarIdDifferent: true, isSelectedGlassAvailableForVehicle: false, vehicleInfo: { carId: "C010101", vin: "XXXXX" }, }); // Assert expect(dispatch).toBeCalledWith(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE, { carId: "C010101", vin: "XXXXX", }); }); it("saveEmail, should call mutation", () => { // Arrange const context = state; const commit = jest.fn(); context.commit = commit; // Act actions.saveEmail(context, "test@safelite.com"); // Assert expect(commit).toBeCalledWith( storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, "test@safelite.com" ); }); it("saveServiceLocation, should call mutation and save service address to state", () => { // Arrange const context = state; const commit = jest.fn(); context.commit = commit; const serviceLocation = { address: "123 Test Lane", city: "Columbus", zipCode: "43212", state: "OH", zipCodeCtu: "01820", }; // Act actions.saveServiceLocation(context, serviceLocation); // Assert expect(commit).toBeCalledWith(storeMutations.UPDATE_SERVICE_LOCATION, serviceLocation); expect(state.order.serviceLocation.address).toEqual("123 Test Lane"); expect(state.order.serviceLocation.city).toEqual("Columbus"); expect(state.order.serviceLocation.zipCode).toEqual("43212"); expect(state.order.serviceLocation.state).toEqual("OH"); expect(state.order.serviceLocation.zipCodeCtu).toEqual("01820"); }); it("saveGlassParts, should call mutation", () => { // Arrange const context = state; const commit = jest.fn(); context.commit = commit; // Act actions.saveGlassParts(context, { glassParts: {} }); // Assert expect(commit).toBeCalledWith(storeMutations.UPDATE_GLASS_PARTS, { glassParts: {} }); }); it("clearVin, should call mutation", () => { // Arrange const context = state; const commit = jest.fn(); context.commit = commit; // Act actions.clearVin(context); // Assert expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_VIN, null); }); it("saveVinLookup, should call mutation if vin is different", () => { // Arrange const context = state; const commit = jest.fn(); const dispatch = jest.fn(); context.commit = commit; context.dispatch = dispatch; // Act const payload = { isCarIdDifferent: true, isSelectedGlassAvailableForVehicle: false, vehicleInfo: { carId: "C010101", vin: "XXXXX", }, registrationInfo: { zipCode: "80020", }, serviceLocationInfo: { state: "CO", }, customerEmail: "test@safleite.com", }; actions.saveVinLookup(context, payload); // Assert expect(dispatch).toHaveBeenNthCalledWith( 1, storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES ); expect(dispatch).toHaveBeenNthCalledWith( 2, storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES ); expect(dispatch).toHaveBeenNthCalledWith( 3, storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES ); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE, payload.vehicleInfo); expect(commit).toBeCalledWith(storeMutations.UPDATE_REGISTRATION, payload.registrationInfo); }); it("saveRegistrationLicensePlateLookup, should call mutation if LP is different", () => { // Arrange const context = state; context.state = { order: { vehicle: { registration: { licensePlate: "ABC123", }, }, }, }; const commit = jest.fn(); const dispatch = jest.fn(); context.commit = commit; context.dispatch = dispatch; // Act const payload = { isCarIdDifferent: true, isSelectedGlassAvailableForVehicle: false, vehicleInfo: { carId: "C010101", vin: "XXXXX" }, registrationInfo: { zipCode: "80020", licensePlate: "ALQX35" }, serviceLocationInfo: { state: "CO" }, customerEmail: "test@safelite.com", }; actions.saveRegistrationLicensePlateLookup(context, payload); // Assert expect(dispatch).toHaveBeenNthCalledWith( 1, storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES ); expect(dispatch).toHaveBeenNthCalledWith( 2, storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES ); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE, payload.vehicleInfo); expect(commit).toBeCalledWith(storeMutations.UPDATE_REGISTRATION, payload.registrationInfo); }); it("saveRegistrationAddressLookup, should call mutation when address is different", () => { // Arrange const context = state; context.state = { order: { vehicle: { registration: { address: "123 Main St", }, }, }, }; const commit = jest.fn(); const dispatch = jest.fn(); context.commit = commit; context.dispatch = dispatch; // Act const payload = { isCarIdDifferent: true, isSelectedGlassAvailableForVehicle: false, vehicleInfo: { carId: "C010101", vin: "XXXXX" }, registrationInfo: { zipCode: "80020", address: "123 Marys Ave" }, serviceLocationInfo: { state: "CO" }, customerEmail: "test@safelite.com", }; actions.saveRegistrationAddressLookup(context, payload); // Assert expect(dispatch).toHaveBeenNthCalledWith( 1, storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES ); expect(dispatch).toHaveBeenNthCalledWith( 2, storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES ); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE, payload.vehicleInfo); expect(commit).toBeCalledWith(storeMutations.UPDATE_REGISTRATION, payload.registrationInfo); }); it("saveVehicleYear, should wipe out vehicle info if year changes", () => { // Arrange const context = state; context.state = { order: { vehicle: { year: "2015", }, }, }; const commit = jest.fn(); const dispatch = jest.fn(); context.commit = commit; context.dispatch = dispatch; // Act actions.saveVehicleYear(context, "2016"); // Assert expect(dispatch).toHaveBeenNthCalledWith( 1, storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES ); expect(dispatch).toHaveBeenNthCalledWith( 2, storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES ); expect(commit).toBeCalledWith(storeMutations.UPDATE_MAKE, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_MODEL, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_STYLE, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_CAR_ID, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_CATEGORY, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_VIN, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null); }); it("saveVehicleMake, should wipe out vehicle info if make changes", () => { // Arrange const context = state; context.state = { order: { vehicle: { make: "Honda", }, }, }; const commit = jest.fn(); const dispatch = jest.fn(); context.commit = commit; context.dispatch = dispatch; // Act actions.saveVehicleMake(context, "Toyota"); // Assert expect(dispatch).toHaveBeenNthCalledWith( 1, storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES ); expect(dispatch).toHaveBeenNthCalledWith( 2, storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES ); expect(commit).toBeCalledWith(storeMutations.UPDATE_MODEL, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_STYLE, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_CAR_ID, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_CATEGORY, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_VIN, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null); }); it("saveVehicle model, should wipe out vehicle info if model changes", () => { // Arrange const context = state; context.state = { order: { vehicle: { model: "Civic", }, }, }; const commit = jest.fn(); const dispatch = jest.fn(); context.commit = commit; context.dispatch = dispatch; // Act actions.saveVehicleModel(context, "Accord"); // Assert expect(dispatch).toHaveBeenNthCalledWith( 1, storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES ); expect(dispatch).toHaveBeenNthCalledWith( 2, storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES ); expect(commit).toBeCalledWith(storeMutations.UPDATE_STYLE, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_CAR_ID, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_CATEGORY, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_VIN, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null); }); it("saveVehicleStyle, should wipe out vehicle info if style changes", () => { // Arrange const context = state; context.state = { order: { vehicle: { style: "Sedan", }, }, }; const commit = jest.fn(); const dispatch = jest.fn(); context.commit = commit; context.dispatch = dispatch; // Act actions.saveVehicleStyle(context, "SUV"); // Assert expect(dispatch).toHaveBeenNthCalledWith( 1, storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES ); expect(dispatch).toHaveBeenNthCalledWith( 2, storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES ); expect(commit).toBeCalledWith(storeMutations.UPDATE_CAR_ID, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_CATEGORY, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_VIN, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_URL, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, null); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, null); }); it("saveVehicleDamage, should wipe out damage if different", () => { // Arrange const context = state; context.state = { order: { damage: { glassToReplace: [{ glassName: "Single", glassLocation: "Windshield" }], }, }, }; const commit = jest.fn(); const dispatch = jest.fn(); context.commit = commit; context.dispatch = dispatch; // Act const payload = { isWindshieldRepair: false, selectedGlassToReplace: [{ glassName: "Rear", glassLocation: "quarter" }], selectedWindshieldChipCount: 0, }; actions.saveVehicleDamage(context, payload); // Assert expect(dispatch).toHaveBeenNthCalledWith( 1, storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES ); expect(commit).toBeCalledWith(storeMutations.UPDATE_IS_REPAIR, payload.isWindshieldRepair); expect(commit).toBeCalledWith( storeMutations.UPDATE_NUMBER_OF_CHIPS, payload.isWindshieldRepair ? parseInt(payload.selectedWindshieldChipCount) : null ); expect(commit).toBeCalledWith( storeMutations.UPDATE_GLASS_TO_REPLACE, payload.selectedGlassToReplace ); }); describe("runExperimentsForTrigger", () => { beforeEach(() => { mutations.resetState(state); globalMethods.callHttpClient = jest.fn().mockReturnValue({ data: { experiments: [ { mockProperty: "mockValue", }, ], }, }); }); test("triggerEvent is SiteEntry => set triggeredSiteEntry to true in store", async () => { // Arrange const context = state; context.commit = jest .fn() .mockImplementation((storeMutation, value) => mutations[storeMutation](context, value) ); context.getters = { ...getters, applicationUser: getters.applicationUser(context), }; // Act await actions.runExperimentsForTrigger(context, { triggerEvent: experimentTriggers.SITE_ENTRY, }); // Assert expect(context.commit).toHaveBeenNthCalledWith( 1, storeMutations.UPDATE_TRIGGERED_SITE_ENTRY, true ); expect(context.getters.applicationUser.triggeredSiteEntry).toBe(true); expect(globalMethods.callHttpClient).toHaveBeenCalled(); expect(context.commit).toHaveBeenNthCalledWith(2, storeMutations.UPDATE_EXPERIMENTS, [ { mockProperty: "mockValue", }, ]); }); test("triggerEvent is not SiteEntry => triggeredSiteEntry is false in store", async () => { // Arrange const context = state; context.commit = jest .fn() .mockImplementation((storeMutation, value) => mutations[storeMutation](context, value) ); context.getters = { ...getters, applicationUser: getters.applicationUser(context), }; expect(context.commit).toHaveBeenCalledTimes(0); // Act await actions.runExperimentsForTrigger(context, { triggerEvent: "NotSiteEntry", }); // Assert expect(context.commit).not.toHaveBeenCalledWith( storeMutations.UPDATE_TRIGGERED_SITE_ENTRY, expect.any ); expect(context.getters.applicationUser.triggeredSiteEntry).toBe(false); expect(globalMethods.callHttpClient).toHaveBeenCalledTimes(1); expect(context.commit).toHaveBeenNthCalledWith(1, storeMutations.UPDATE_EXPERIMENTS, [ { mockProperty: "mockValue", }, ]); }); }); describe("savePartQuestionAnswers", () => { let context; beforeEach(() => { jest.clearAllMocks(); mutations.resetState(state); context = state; context.commit = jest .fn() .mockImplementation((storeMutation, value) => mutations[storeMutation](context, value) ); context.getters = { ...getters, damage: getters.damage(context), }; }); function testPartQuestionAnswerDependenciesHaveBeenReset( context, shouldPartQuestionAnswersBeReset ) { if (shouldPartQuestionAnswersBeReset) { expect(context.commit).toBeCalledWith(storeMutations.UPDATE_GLASS_PARTS, null); expect(context.commit).toBeCalledWith( storeMutations.UPDATE_MOLDING_QUESTION_ANSWERS, null ); expect(context.commit).toBeCalledWith( storeMutations.UPDATE_CAPABILITY_QUESTION_ANSWERS, null ); expect(context.commit).toBeCalledWith(storeMutations.UPDATE_PAGE_DATA, { page: fmgPageValues.VEHICLE_PARTS, data: null, }); expect(context.commit).toBeCalledWith(storeMutations.UPDATE_PAGE_DATA, { page: fmgPageValues.MOLDING_QUESTIONS, data: null, }); expect(context.commit).toBeCalledWith(storeMutations.UPDATE_PAGE_DATA, { page: fmgPageValues.CAPABILITY_QUESTIONS, data: null, }); } else { expect(context.commit).not.toBeCalledWith(storeMutations.UPDATE_GLASS_PARTS, null); expect(context.commit).not.toBeCalledWith( storeMutations.UPDATE_MOLDING_QUESTION_ANSWERS, null ); expect(context.commit).not.toBeCalledWith( storeMutations.UPDATE_CAPABILITY_QUESTION_ANSWERS, null ); expect(context.commit).not.toBeCalledWith(storeMutations.UPDATE_PAGE_DATA, { page: fmgPageValues.VEHICLE_PARTS, data: null, }); expect(context.commit).not.toBeCalledWith(storeMutations.UPDATE_PAGE_DATA, { page: fmgPageValues.MOLDING_QUESTIONS, data: null, }); expect(context.commit).not.toBeCalledWith(storeMutations.UPDATE_PAGE_DATA, { page: fmgPageValues.CAPABILITY_QUESTIONS, data: null, }); } expect(context.commit).toBeCalledWith( storeMutations.UPDATE_PART_QUESTION_ANSWERS, expect.anything() ); } test("there are no previous answers => resets necessary fields", async () => { // Arrange const previousPartQuestionAnswers = []; const currentPartQuestionAnswers = [ { result: "I'M A PART!" }, { result: "I'M A PART3!" }, { result: "I'M A PART2!" }, ]; actions.savePartQuestionAnswers(context, previousPartQuestionAnswers); jest.clearAllMocks(); // Act actions.savePartQuestionAnswers(context, currentPartQuestionAnswers); // Assert testPartQuestionAnswerDependenciesHaveBeenReset(context, true); }); test("previous answers does not match current answers => resets necessary fields", () => { // Arrange const previousPartQuestionAnswers = [ { result: "I'M A PART2!" }, { result: "I'M A PART4!" }, { result: "I'M A PART3!" }, ]; const currentPartQuestionAnswers = [ { result: "I'M A PART!" }, { result: "I'M A PART3!" }, { result: "I'M A PART2!" }, ]; actions.savePartQuestionAnswers(context, previousPartQuestionAnswers); jest.clearAllMocks(); // Act actions.savePartQuestionAnswers(context, currentPartQuestionAnswers); // Assert testPartQuestionAnswerDependenciesHaveBeenReset(context, true); }); test("previous answers match current answers => does not reset fields", () => { // Arrange const previousPartQuestionAnswers = [ { result: "I'M A PART2!" }, { result: "I'M A PART!" }, { result: "I'M A PART3!" }, ]; const currentPartQuestionAnswers = [ { result: "I'M A PART!" }, { result: "I'M A PART3!" }, { result: "I'M A PART2!" }, ]; actions.savePartQuestionAnswers(context, previousPartQuestionAnswers); jest.clearAllMocks(); // Act actions.savePartQuestionAnswers(context, currentPartQuestionAnswers); // Assert testPartQuestionAnswerDependenciesHaveBeenReset(context, false); }); test("previous answers have more questions/answers than current => resets fields", () => { // Arrange const previousPartQuestionAnswers = [ { result: "I'M A PART2!" }, { result: "I'M A PART!" }, { result: "I'M A PART3!" }, ]; const currentPartQuestionAnswers = [ { result: "I'M A PART!" }, { result: "I'M A PART3!" }, ]; actions.savePartQuestionAnswers(context, previousPartQuestionAnswers); jest.clearAllMocks(); // Act actions.savePartQuestionAnswers(context, currentPartQuestionAnswers); // Assert testPartQuestionAnswerDependenciesHaveBeenReset(context, true); }); test("current answers have more questions/answers than previous => resets fields", () => { // Arrange const previousPartQuestionAnswers = [ { result: "I'M A PART2!" }, { result: "I'M A PART3!" }, ]; const currentPartQuestionAnswers = [ { result: "I'M A PART!" }, { result: "I'M A PART3!" }, { result: "I'M A PART2!" }, ]; actions.savePartQuestionAnswers(context, previousPartQuestionAnswers); jest.clearAllMocks(); // Act actions.savePartQuestionAnswers(context, currentPartQuestionAnswers); // Assert testPartQuestionAnswerDependenciesHaveBeenReset(context, true); }); }); describe("resetMoldingAndCapabilityQuestionAnswersIfNeeded", () => { let context; beforeEach(() => { mutations.resetState(state); context = state; context.commit = jest .fn() .mockImplementation((storeMutation, value) => mutations[storeMutation](context, value) ); context.getters = { ...getters, pageData: getters.pageData(context), }; }); function testVehiclePartDependenciesHaveBeenReset(context, shouldAnswersBeReset) { if (shouldAnswersBeReset) { expect(context.commit).toBeCalledWith(storeMutations.UPDATE_GLASS_PARTS, null); expect(context.commit).toBeCalledWith( storeMutations.UPDATE_MOLDING_QUESTION_ANSWERS, null ); expect(context.commit).toBeCalledWith( storeMutations.UPDATE_CAPABILITY_QUESTION_ANSWERS, null ); expect(context.commit).toBeCalledWith(storeMutations.UPDATE_PAGE_DATA, { page: fmgPageValues.MOLDING_QUESTIONS, data: null, }); expect(context.commit).toBeCalledWith(storeMutations.UPDATE_PAGE_DATA, { page: fmgPageValues.CAPABILITY_QUESTIONS, data: null, }); } else { expect(context.commit).not.toBeCalledWith(storeMutations.UPDATE_GLASS_PARTS, null); expect(context.commit).not.toBeCalledWith( storeMutations.UPDATE_MOLDING_QUESTION_ANSWERS, null ); expect(context.commit).not.toBeCalledWith( storeMutations.UPDATE_CAPABILITY_QUESTION_ANSWERS, null ); expect(context.commit).not.toBeCalledWith(storeMutations.UPDATE_PAGE_DATA, { page: fmgPageValues.MOLDING_QUESTIONS, data: null, }); expect(context.commit).not.toBeCalledWith(storeMutations.UPDATE_PAGE_DATA, { page: fmgPageValues.CAPABILITY_QUESTIONS, data: null, }); } } test("there are no saved parts from molding or capability question pages => resets necessary fields", () => { // Arrange const previouslySelectedParts = {}; const currentlySelectedParts = [ { glassLocation: "Windshield", glassName: "Single", parts: [ { partNumber: "PART3" }, { partNumber: "PART1" }, { partNumber: "PART2" }, ], }, ]; mutations.updatePageData(context, { page: fmgPageValues.MOLDING_QUESTIONS, data: previouslySelectedParts, }); mutations.updatePageData(context, { page: fmgPageValues.CAPABILITY_QUESTIONS, data: previouslySelectedParts, }); // Act actions.resetMoldingAndCapabilityQuestionAnswersIfNeeded( context, currentlySelectedParts ); // Assert testVehiclePartDependenciesHaveBeenReset(context, true); }); describe("previously saved parts from molding-questions match selected parts => does not reset fields", () => { test("single glass location", () => { // Arrange const previouslySelectedParts = { partsOrQuestions: [ { glassLocation: "Windshield", glassName: "Single", parts: [ { partNumber: "PART1" }, { partNumber: "PART2" }, { partNumber: "PART3" }, ], }, ], }; const currentlySelectedParts = [ { glassLocation: "Windshield", glassName: "Single", parts: [ { partNumber: "PART3" }, { partNumber: "PART1" }, { partNumber: "PART2" }, ], }, ]; mutations.updatePageData(context, { page: fmgPageValues.MOLDING_QUESTIONS, data: previouslySelectedParts, }); // Act actions.resetMoldingAndCapabilityQuestionAnswersIfNeeded( context, currentlySelectedParts ); // Assert testVehiclePartDependenciesHaveBeenReset(context, false); }); test("multiple glass locations", () => { // Arrange const previouslySelectedParts = { partsOrQuestions: [ { glassLocation: "Windshield", glassName: "Single", parts: [ { partNumber: "PART1" }, { partNumber: "PART2" }, { partNumber: "PART3" }, ], }, { glassLocation: "Driver", glassName: "Front", parts: [{ partNumber: "PART5" }, { partNumber: "PART4" }], }, ], }; const currentlySelectedParts = [ { glassLocation: "Driver", glassName: "Front", parts: [{ partNumber: "PART4" }, { partNumber: "PART5" }], }, { glassLocation: "Windshield", glassName: "Single", parts: [ { partNumber: "PART3" }, { partNumber: "PART1" }, { partNumber: "PART2" }, ], }, ]; mutations.updatePageData(context, { page: fmgPageValues.MOLDING_QUESTIONS, data: previouslySelectedParts, }); // Act actions.resetMoldingAndCapabilityQuestionAnswersIfNeeded( context, currentlySelectedParts ); // Assert testVehiclePartDependenciesHaveBeenReset(context, false); }); }); describe("previously saved parts from capability-questions match selected parts and there are none from molding-questions => does not reset fields", () => { test("Single glass location", () => { // Arrange const previouslySelectedParts = { partsOrQuestions: [ { glassLocation: "Windshield", glassName: "Single", parts: [ { partNumber: "PART1" }, { partNumber: "PART2" }, { partNumber: "PART3" }, ], }, ], }; const currentlySelectedParts = [ { glassLocation: "Windshield", glassName: "Single", parts: [ { partNumber: "PART3" }, { partNumber: "PART1" }, { partNumber: "PART2" }, ], }, ]; mutations.updatePageData(context, { page: fmgPageValues.CAPABILITY_QUESTIONS, data: previouslySelectedParts, }); // Act actions.resetMoldingAndCapabilityQuestionAnswersIfNeeded( context, currentlySelectedParts ); // Assert testVehiclePartDependenciesHaveBeenReset(context, false); }); test("multiple glass locations", () => { // Arrange const previouslySelectedParts = { partsOrQuestions: [ { glassLocation: "Windshield", glassName: "Single", parts: [ { partNumber: "PART1" }, { partNumber: "PART2" }, { partNumber: "PART3" }, ], }, { glassLocation: "Driver", glassName: "Front", parts: [{ partNumber: "PART5" }, { partNumber: "PART4" }], }, ], }; const currentlySelectedParts = [ { glassLocation: "Driver", glassName: "Front", parts: [{ partNumber: "PART4" }, { partNumber: "PART5" }], }, { glassLocation: "Windshield", glassName: "Single", parts: [ { partNumber: "PART3" }, { partNumber: "PART1" }, { partNumber: "PART2" }, ], }, ]; mutations.updatePageData(context, { page: fmgPageValues.CAPABILITY_QUESTIONS, data: previouslySelectedParts, }); // Act actions.resetMoldingAndCapabilityQuestionAnswersIfNeeded( context, currentlySelectedParts ); // Assert testVehiclePartDependenciesHaveBeenReset(context, false); }); }); describe("previously saved parts from molding-questions do not match selected parts => resets necessary fields", () => { test("single glass location", () => { // Arrange const previouslySelectedParts = { partsOrQuestions: [ { glassLocation: "Windshield", glassName: "Single", parts: [ { partNumber: "PART1" }, { partNumber: "PART6" }, { partNumber: "PART3" }, ], }, ], }; const currentlySelectedParts = [ { glassLocation: "Windshield", glassName: "Single", parts: [ { partNumber: "PART3" }, { partNumber: "PART1" }, { partNumber: "PART2" }, ], }, ]; mutations.updatePageData(context, { page: fmgPageValues.MOLDING_QUESTIONS, data: previouslySelectedParts, }); // Act actions.resetMoldingAndCapabilityQuestionAnswersIfNeeded( context, currentlySelectedParts ); // Assert testVehiclePartDependenciesHaveBeenReset(context, true); }); test("multiple glass locations", () => { // Arrange const previouslySelectedParts = { partsOrQuestions: [ { glassLocation: "Windshield", glassName: "Single", parts: [ { partNumber: "PART1" }, { partNumber: "PART6" }, { partNumber: "PART3" }, ], }, { glassLocation: "Driver", glassName: "Front", parts: [{ partNumber: "PART5" }, { partNumber: "PART4" }], }, ], }; const currentlySelectedParts = [ { glassLocation: "Driver", glassName: "Front", parts: [{ partNumber: "PART4" }, { partNumber: "PART5" }], }, { glassLocation: "Windshield", glassName: "Single", parts: [ { partNumber: "PART3" }, { partNumber: "PART1" }, { partNumber: "PART2" }, ], }, ]; mutations.updatePageData(context, { page: fmgPageValues.MOLDING_QUESTIONS, data: previouslySelectedParts, }); // Act actions.resetMoldingAndCapabilityQuestionAnswersIfNeeded( context, currentlySelectedParts ); // Assert testVehiclePartDependenciesHaveBeenReset(context, true); }); }); describe("previously saved parts from capability-questions do not match selected parts => resets necessary fields", () => { test("single glass location", () => { // Arrange const previouslySelectedParts = { partsOrQuestions: [ { glassLocation: "Windshield", glassName: "Single", parts: [ { partNumber: "PART1" }, { partNumber: "PART6" }, { partNumber: "PART3" }, ], }, ], }; const currentlySelectedParts = [ { glassLocation: "Windshield", glassName: "Single", parts: [ { partNumber: "PART3" }, { partNumber: "PART1" }, { partNumber: "PART2" }, ], }, ]; mutations.updatePageData(context, { page: fmgPageValues.MOLDING_QUESTIONS, data: previouslySelectedParts, }); // Act actions.resetMoldingAndCapabilityQuestionAnswersIfNeeded( context, currentlySelectedParts ); // Assert testVehiclePartDependenciesHaveBeenReset(context, true); }); test("multiple glass locations", () => { // Arrange const previouslySelectedParts = { partsOrQuestions: [ { glassLocation: "Windshield", glassName: "Single", parts: [ { partNumber: "PART1" }, { partNumber: "PART6" }, { partNumber: "PART3" }, ], }, { glassLocation: "Driver", glassName: "Front", parts: [{ partNumber: "PART5" }, { partNumber: "PART4" }], }, ], }; const currentlySelectedParts = [ { glassLocation: "Driver", glassName: "Front", parts: [{ partNumber: "PART4" }, { partNumber: "PART5" }], }, { glassLocation: "Windshield", glassName: "Single", parts: [ { partNumber: "PART3" }, { partNumber: "PART1" }, { partNumber: "PART2" }, ], }, ]; mutations.updatePageData(context, { page: fmgPageValues.CAPABILITY_QUESTIONS, data: previouslySelectedParts, }); // Act actions.resetMoldingAndCapabilityQuestionAnswersIfNeeded( context, currentlySelectedParts ); // Assert testVehiclePartDependenciesHaveBeenReset(context, true); }); }); }); describe("saveMoldingQuestionAnswers", () => { let context; beforeEach(() => { jest.clearAllMocks(); mutations.resetState(state); context = state; context.commit = jest .fn() .mockImplementation((storeMutation, value) => mutations[storeMutation](context, value) ); context.getters = { ...getters, damage: getters.damage(context), }; }); function testMoldingQuestionAnswerDependenciesHaveBeenReset(context, shouldAnswersBeReset) { if (shouldAnswersBeReset) { expect(context.commit).toBeCalledWith(storeMutations.UPDATE_GLASS_PARTS, null); expect(context.commit).toBeCalledWith( storeMutations.UPDATE_CAPABILITY_QUESTION_ANSWERS, null ); expect(context.commit).toBeCalledWith(storeMutations.UPDATE_PAGE_DATA, { page: fmgPageValues.CAPABILITY_QUESTIONS, data: null, }); } else { expect(context.commit).not.toBeCalledWith(storeMutations.UPDATE_GLASS_PARTS, null); expect(context.commit).not.toBeCalledWith( storeMutations.UPDATE_CAPABILITY_QUESTION_ANSWERS, null ); expect(context.commit).not.toBeCalledWith(storeMutations.UPDATE_PAGE_DATA, { page: fmgPageValues.CAPABILITY_QUESTIONS, data: null, }); } } test("there are no previous answers => resets necessary fields", () => { // Arrange const previousMoldingQuestionAnswers = []; const currentMoldingQuestionAnswers = [ { partNum: "I'M A PART!" }, { partNum: "I'M A PART3!" }, { partNum: "I'M A PART2!" }, ]; actions.saveMoldingQuestionAnswers(context, previousMoldingQuestionAnswers); jest.clearAllMocks(); // Act actions.saveMoldingQuestionAnswers(context, currentMoldingQuestionAnswers); // Assert testMoldingQuestionAnswerDependenciesHaveBeenReset(context, true); }); test("previous answers match current answers => does not reset fields", () => { // Arrange const previousMoldingQuestionAnswers = [ { partNum: "I'M A PART2!" }, { partNum: "I'M A PART3!" }, { partNum: "I'M A PART!" }, ]; const currentMoldingQuestionAnswers = [ { partNum: "I'M A PART!" }, { partNum: "I'M A PART3!" }, { partNum: "I'M A PART2!" }, ]; actions.saveMoldingQuestionAnswers(context, previousMoldingQuestionAnswers); jest.clearAllMocks(); // Act actions.saveMoldingQuestionAnswers(context, currentMoldingQuestionAnswers); // Assert testMoldingQuestionAnswerDependenciesHaveBeenReset(context, false); }); test("previous answers do not match current answers => resets necessary fields", () => { // Arrange const previousMoldingQuestionAnswers = [ { partNum: "I'M A PART2!" }, { partNum: "I'M A PART4!" }, { partNum: "I'M A PART!" }, ]; const currentMoldingQuestionAnswers = [ { partNum: "I'M A PART!" }, { partNum: "I'M A PART3!" }, { partNum: "I'M A PART2!" }, ]; actions.saveMoldingQuestionAnswers(context, previousMoldingQuestionAnswers); jest.clearAllMocks(); // Act actions.saveMoldingQuestionAnswers(context, currentMoldingQuestionAnswers); // Assert testMoldingQuestionAnswerDependenciesHaveBeenReset(context, true); }); test("previous answers have more questions/answers than current => resets fields", () => { // Arrange const previousMoldingQuestionAnswers = [ { partNum: "I'M A PART2!" }, { partNum: "I'M A PART4!" }, { partNum: "I'M A PART!" }, ]; const currentMoldingQuestionAnswers = [{ partNum: "I'M A PART!" }]; actions.saveMoldingQuestionAnswers(context, previousMoldingQuestionAnswers); jest.clearAllMocks(); // Act actions.saveMoldingQuestionAnswers(context, currentMoldingQuestionAnswers); // Assert testMoldingQuestionAnswerDependenciesHaveBeenReset(context, true); }); test("current answers have more questions/answers than previous => resets fields", () => { // Arrange const previousMoldingQuestionAnswers = [ { partNum: "I'M A PART2!" }, { partNum: "I'M A PART!" }, ]; const currentMoldingQuestionAnswers = [ { partNum: "I'M A PART!" }, { partNum: "I'M A PART3!" }, { partNum: "I'M A PART2!" }, ]; actions.saveMoldingQuestionAnswers(context, previousMoldingQuestionAnswers); jest.clearAllMocks(); // Act actions.saveMoldingQuestionAnswers(context, currentMoldingQuestionAnswers); // Assert testMoldingQuestionAnswerDependenciesHaveBeenReset(context, true); }); }); describe("saveCapabilityQuestionAnswers", () => { let context; beforeEach(() => { jest.clearAllMocks(); mutations.resetState(state); context = state; context.commit = jest .fn() .mockImplementation((storeMutation, value) => mutations[storeMutation](context, value) ); context.getters = { ...getters, damage: getters.damage(context), }; }); function testCapabilityQuestionAnswerDependenciesHaveBeenReset( context, shouldAnswersBeReset ) { if (shouldAnswersBeReset) { expect(context.commit).toBeCalledWith(storeMutations.UPDATE_GLASS_PARTS, null); } else { expect(context.commit).not.toBeCalledWith(storeMutations.UPDATE_GLASS_PARTS, null); } } test("there are no previous answers => resets necessary fields", () => { // Arrange const previousCapabilityQuestionAnswers = []; const currentCapabilityQuestionAnswers = [ { result: "DYNAMIC" }, { result: "STATIC" }, { result: "UNKNOWN" }, ]; actions.saveCapabilityQuestionAnswers(context, previousCapabilityQuestionAnswers); jest.clearAllMocks(); // Act actions.saveCapabilityQuestionAnswers(context, currentCapabilityQuestionAnswers); // Assert testCapabilityQuestionAnswerDependenciesHaveBeenReset(context, true); }); test("previous answers match current answers => does not reset fields", () => { // Arrange const previousCapabilityQuestionAnswers = [ { result: "STATIC" }, { result: "DYNAMIC" }, { result: "UNKNOWN" }, ]; const currentCapabilityQuestionAnswers = [ { result: "DYNAMIC" }, { result: "STATIC" }, { result: "UNKNOWN" }, ]; actions.saveCapabilityQuestionAnswers(context, previousCapabilityQuestionAnswers); jest.clearAllMocks(); // Act actions.saveCapabilityQuestionAnswers(context, currentCapabilityQuestionAnswers); // Assert testCapabilityQuestionAnswerDependenciesHaveBeenReset(context, false); }); test("previous answers do not match current answers => resets necessary fields", () => { // Arrange const previousCapabilityQuestionAnswers = [ { result: "DYNAMIC" }, { result: "DYNAMIC" }, { result: "STATIC" }, ]; const currentCapabilityQuestionAnswers = [ { result: "STATIC" }, { result: "STATIC" }, { result: "DYNAMIC" }, ]; actions.saveCapabilityQuestionAnswers(context, previousCapabilityQuestionAnswers); jest.clearAllMocks(); // Act actions.saveCapabilityQuestionAnswers(context, currentCapabilityQuestionAnswers); // Assert testCapabilityQuestionAnswerDependenciesHaveBeenReset(context, true); }); test("previous answers have more questions/answers than current => resets fields", () => { // Arrange const previousCapabilityQuestionAnswers = [ { result: "STATIC" }, { result: "DYNAMIC" }, { result: "UNKNOWN" }, ]; const currentCapabilityQuestionAnswers = [{ result: "DYNAMIC" }]; actions.saveCapabilityQuestionAnswers(context, previousCapabilityQuestionAnswers); jest.clearAllMocks(); // Act actions.saveCapabilityQuestionAnswers(context, currentCapabilityQuestionAnswers); // Assert testCapabilityQuestionAnswerDependenciesHaveBeenReset(context, true); }); test("current answers have more questions/answers than previous => resets fields", () => { // Arrange const previousCapabilityQuestionAnswers = [{ result: "STATIC" }, { result: "UNKNOWN" }]; const currentCapabilityQuestionAnswers = [ { result: "DYNAMIC" }, { result: "STATIC" }, { result: "UNKNOWN" }, ]; actions.saveCapabilityQuestionAnswers(context, previousCapabilityQuestionAnswers); jest.clearAllMocks(); // Act actions.saveCapabilityQuestionAnswers(context, currentCapabilityQuestionAnswers); // Assert testCapabilityQuestionAnswerDependenciesHaveBeenReset(context, true); }); }); }); describe("Getters", () => { it("Vehicle getter, should return vehicle data", () => { // Arrange const storeState = state; // Act mutations.updateYear(storeState, "2019"); mutations.updateMake(storeState, "Acura"); mutations.updateModel(storeState, "ILX"); // Assert expect(getters.vehicle(storeState).year).toEqual("2019"); expect(getters.vehicle(storeState).make).toEqual("Acura"); expect(getters.vehicle(storeState).model).toEqual("ILX"); }); it("Get event bus item by event category and eventSubCategory", () => { // Arrange const storeState = state; const event = { category: "CategoryOne", subCategory: "SubCategoryOne", eventValue: "EventValueOne", }; // Act mutations.addEventToBus(storeState, event); // Assert //expect(storeState.applicationUser.eventBus).toEqual([event]); expect(getters.eventBusItem(storeState)(event.category, event.subCategory)).toEqual( event.eventValue ); }); it("Get event bus", () => { // Arrange const storeState = state; storeState.applicationUser.eventBus = []; const event = { category: "CategoryOne", subCategory: "SubCategoryOne", eventValue: "EventValueOne", }; // Act mutations.addEventToBus(storeState, event); // Assert expect(getters.eventBus(storeState)).toEqual([event]); }); it("Damage getter, should return damage data", () => { // Arrange const storeState = state; // Act mutations.updateGlassToReplace(storeState, ["Rear"]); // Assert expect(getters.damage(storeState).glassToReplace).toEqual(["Rear"]); }); it("lineItems getter, should return lineItem data", () => { // Arrange const storeState = state; // Act mutations.updateGlassParts(storeState, { "Rear-Stationary": "PART101" }); // Assert expect(getters.lineItems(storeState).glassParts).toEqual({ "Rear-Stationary": "PART101" }); }); it("PageData getter, should return page data for specific page", () => { // Arrange const storeState = state; // Act mutations.updatePageData(storeState, { page: "vehicle-year", data: {} }); // Assert expect(getters.pageData(storeState)("vehicle-year")).toEqual({}); }); it("Payment getter, should return payment data", () => { // Arrange const storeState = state; //Act mutations.updateInsuranceVerifiedStatus(storeState, true); //Assert expect(getters.payment(storeState).insuranceCoverage.isVerified).toEqual(true); }); describe("experimentOrder", () => { test("glassToReplace, glassParts, and otherParts are null > return correct experimentOrder values", () => { // Arrange const storeState = state; const mockStateValues = { funnelVehicleYear: 1000, funnelVehicleMake: "CarMake", funnelVehicleModel: "CarModel", funnelVehicleStyle: "SuperCoolStyle", funnelIsRepair: true, funnelNumberOfChips: 9999999, funnelCarId: "Gibberish", funnelServiceCity: "Columbus", funnelServiceState: "OH-IO", funnelServiceZipCode: 43215, funnelParentAccountNumber: "999999", funnelIsCoverageVerified: true, funnelGlassParts: null, funnelSupportingItems: null, funnelVaps: null, funnelGlassToReplace: null, }; //Act mutations.updateYear(storeState, mockStateValues.funnelVehicleYear); mutations.updateMake(storeState, mockStateValues.funnelVehicleMake); mutations.updateModel(storeState, mockStateValues.funnelVehicleModel); mutations.updateStyle(storeState, mockStateValues.funnelVehicleStyle); mutations.updateIsRepair(storeState, mockStateValues.funnelIsRepair); mutations.updateNumberOfChips(storeState, mockStateValues.funnelNumberOfChips); mutations.updateCarId(storeState, mockStateValues.funnelCarId); mutations.updateServiceLocation(storeState, { city: mockStateValues.funnelServiceCity, state: mockStateValues.funnelServiceState, zipCode: mockStateValues.funnelServiceZipCode, }); mutations.updateParentAcctNumber(storeState, mockStateValues.funnelParentAccountNumber); mutations.updateInsuranceVerifiedStatus( storeState, mockStateValues.funnelIsCoverageVerified ); mutations.updateGlassParts(storeState, mockStateValues.funnelGlassParts); mutations.updateSupportingItems(storeState, mockStateValues.funnelSupportingItems); mutations.updateVaps(storeState, mockStateValues.funnelVaps); mutations.updateGlassToReplace(storeState, mockStateValues.funnelGlassToReplace); //Assert expect(getters.experimentOrder(storeState)).toEqual({ funnelVehicleYear: mockStateValues.funnelVehicleYear, funnelVehicleMake: mockStateValues.funnelVehicleMake, funnelVehicleModel: mockStateValues.funnelVehicleModel, funnelVehicleStyle: mockStateValues.funnelVehicleStyle, funnelIsRepair: mockStateValues.funnelIsRepair, funnelNumberOfChips: mockStateValues.funnelNumberOfChips, funnelCarId: mockStateValues.funnelCarId, funnelServiceCity: mockStateValues.funnelServiceCity, funnelServiceState: mockStateValues.funnelServiceState, funnelServiceZipCode: mockStateValues.funnelServiceZipCode, funnelParentAccountNumber: mockStateValues.funnelParentAccountNumber, funnelIsCoverageVerified: mockStateValues.funnelIsCoverageVerified, funnelOrderPartNumbers: [], funnelOrderPartTypes: [], funnelHasRecalibrationPart: false, funnelSelectedMultiGlass: false, funnelSelectedWindshieldGlass: false, funnelSelectedBackGlass: false, funnelSelectedDriverSideGlass: false, funnelSelectedPassengerSideGlass: false, }); }); test("glassToReplace, glassParts, and otherParts are empty > return correct experimentOrder values", () => { // Arrange const storeState = state; const mockStateValues = { funnelVehicleYear: 1000, funnelVehicleMake: "CarMake", funnelVehicleModel: "CarModel", funnelVehicleStyle: "SuperCoolStyle", funnelIsRepair: true, funnelNumberOfChips: 9999999, funnelCarId: "Gibberish", funnelServiceCity: "Columbus", funnelServiceState: "OH-IO", funnelServiceZipCode: 43215, funnelParentAccountNumber: "999999", funnelIsCoverageVerified: true, funnelGlassParts: [], funnelOtherParts: [], funnelGlassToReplace: [], }; //Act mutations.updateYear(storeState, mockStateValues.funnelVehicleYear); mutations.updateMake(storeState, mockStateValues.funnelVehicleMake); mutations.updateModel(storeState, mockStateValues.funnelVehicleModel); mutations.updateStyle(storeState, mockStateValues.funnelVehicleStyle); mutations.updateIsRepair(storeState, mockStateValues.funnelIsRepair); mutations.updateNumberOfChips(storeState, mockStateValues.funnelNumberOfChips); mutations.updateCarId(storeState, mockStateValues.funnelCarId); mutations.updateServiceLocation(storeState, { city: mockStateValues.funnelServiceCity, state: mockStateValues.funnelServiceState, zipCode: mockStateValues.funnelServiceZipCode, }); mutations.updateParentAcctNumber(storeState, mockStateValues.funnelParentAccountNumber); mutations.updateInsuranceVerifiedStatus( storeState, mockStateValues.funnelIsCoverageVerified ); mutations.updateGlassParts(storeState, mockStateValues.funnelGlassParts); mutations.updateSupportingItems(storeState, mockStateValues.funnelSupportingItems); mutations.updateVaps(storeState, mockStateValues.funnelVaps); mutations.updateGlassToReplace(storeState, mockStateValues.funnelGlassToReplace); //Assert expect(getters.experimentOrder(storeState)).toEqual({ funnelVehicleYear: mockStateValues.funnelVehicleYear, funnelVehicleMake: mockStateValues.funnelVehicleMake, funnelVehicleModel: mockStateValues.funnelVehicleModel, funnelVehicleStyle: mockStateValues.funnelVehicleStyle, funnelIsRepair: mockStateValues.funnelIsRepair, funnelNumberOfChips: mockStateValues.funnelNumberOfChips, funnelCarId: mockStateValues.funnelCarId, funnelServiceCity: mockStateValues.funnelServiceCity, funnelServiceState: mockStateValues.funnelServiceState, funnelServiceZipCode: mockStateValues.funnelServiceZipCode, funnelParentAccountNumber: mockStateValues.funnelParentAccountNumber, funnelIsCoverageVerified: mockStateValues.funnelIsCoverageVerified, funnelOrderPartNumbers: [], funnelOrderPartTypes: [], funnelHasRecalibrationPart: false, funnelSelectedMultiGlass: false, funnelSelectedWindshieldGlass: false, funnelSelectedBackGlass: false, funnelSelectedDriverSideGlass: false, funnelSelectedPassengerSideGlass: false, }); }); test("Single windshield requiring recalibration is selected > return correct experimentOrder values", () => { // Arrange const storeState = state; const mockStateValues = { vehicleYear: 1000, vehicleMake: "CarMake", vehicleModel: "CarModel", vehicleStyle: "SuperCoolStyle", isRepair: false, numberOfChips: 0, carId: "Gibberish", serviceCity: "Columbus", serviceState: "OH-IO", serviceZipCode: 43215, parentAccountNumber: "999999", isCoverageVerified: false, glassParts: [ { partNumber: "WINDSHIELDPARTNUMBER", description: "This is a windshield", recalibrationType: "ADAS, maybe", requiresRecalibration: true, requiresCapabilityQuestions: false, }, ], otherParts: [], glassToReplace: [ { glassLocation: "Windshield", glassName: "Single", }, ], }; //Act mutations.updateYear(storeState, mockStateValues.vehicleYear); mutations.updateMake(storeState, mockStateValues.vehicleMake); mutations.updateModel(storeState, mockStateValues.vehicleModel); mutations.updateStyle(storeState, mockStateValues.vehicleStyle); mutations.updateIsRepair(storeState, mockStateValues.isRepair); mutations.updateNumberOfChips(storeState, mockStateValues.numberOfChips); mutations.updateCarId(storeState, mockStateValues.carId); mutations.updateServiceLocation(storeState, { city: mockStateValues.serviceCity, state: mockStateValues.serviceState, zipCode: mockStateValues.serviceZipCode, }); mutations.updateParentAcctNumber(storeState, mockStateValues.parentAccountNumber); mutations.updateInsuranceVerifiedStatus(storeState, mockStateValues.isCoverageVerified); mutations.updateGlassParts(storeState, mockStateValues.glassParts); mutations.updateSupportingItems(storeState, mockStateValues.funnelSupportingItems); mutations.updateVaps(storeState, mockStateValues.funnelVaps); mutations.updateGlassToReplace(storeState, mockStateValues.glassToReplace); //Assert expect(getters.experimentOrder(storeState)).toEqual({ funnelVehicleYear: mockStateValues.vehicleYear, funnelVehicleMake: mockStateValues.vehicleMake, funnelVehicleModel: mockStateValues.vehicleModel, funnelVehicleStyle: mockStateValues.vehicleStyle, funnelIsRepair: mockStateValues.isRepair, funnelNumberOfChips: mockStateValues.numberOfChips, funnelCarId: mockStateValues.carId, funnelServiceCity: mockStateValues.serviceCity, funnelServiceState: mockStateValues.serviceState, funnelServiceZipCode: mockStateValues.serviceZipCode, funnelParentAccountNumber: mockStateValues.parentAccountNumber, funnelIsCoverageVerified: mockStateValues.isCoverageVerified, funnelOrderPartNumbers: ["WINDSHIELDPARTNUMBER"], funnelOrderPartTypes: ["ADAS, maybe"], funnelHasRecalibrationPart: true, funnelSelectedMultiGlass: false, funnelSelectedWindshieldGlass: true, funnelSelectedBackGlass: false, funnelSelectedDriverSideGlass: false, funnelSelectedPassengerSideGlass: false, }); }); test("Select multiglass > return correct experimentOrder values", () => { // Arrange const storeState = state; const mockStateValues = { vehicleYear: 1000, vehicleMake: "CarMake", vehicleModel: "CarModel", vehicleStyle: "SuperCoolStyle", isRepair: false, numberOfChips: 0, carId: "Gibberish", serviceCity: "Columbus", serviceState: "OH-IO", serviceZipCode: 43215, parentAccountNumber: "999999", isCoverageVerified: false, glassParts: [ { partNumber: "BACKGLASS_PN", description: "This is a back glass", recalibrationType: null, requiresRecalibration: false, requiresCapabilityQuestions: false, }, { partNumber: "DRIVERGLASS_PN", description: "This is a driver side glass", recalibrationType: null, requiresRecalibration: false, requiresCapabilityQuestions: false, }, { partNumber: "PASSENGERGLASS_PN", description: "This is a passenger side glass", recalibrationType: null, requiresRecalibration: false, requiresCapabilityQuestions: false, }, ], otherParts: [], glassToReplace: [ { glassLocation: "Rear", glassName: "Stationary", }, { glassLocation: "Driver", glassName: "Front", }, { glassLocation: "Passenger", glassName: "Front", }, { glassLocation: "Passenger", glassName: "Quarter", }, ], }; //Act mutations.updateYear(storeState, mockStateValues.vehicleYear); mutations.updateMake(storeState, mockStateValues.vehicleMake); mutations.updateModel(storeState, mockStateValues.vehicleModel); mutations.updateStyle(storeState, mockStateValues.vehicleStyle); mutations.updateIsRepair(storeState, mockStateValues.isRepair); mutations.updateNumberOfChips(storeState, mockStateValues.numberOfChips); mutations.updateCarId(storeState, mockStateValues.carId); mutations.updateServiceLocation(storeState, { city: mockStateValues.serviceCity, state: mockStateValues.serviceState, zipCode: mockStateValues.serviceZipCode, }); mutations.updateParentAcctNumber(storeState, mockStateValues.parentAccountNumber); mutations.updateInsuranceVerifiedStatus(storeState, mockStateValues.isCoverageVerified); mutations.updateGlassParts(storeState, mockStateValues.glassParts); mutations.updateSupportingItems(storeState, mockStateValues.funnelSupportingItems); mutations.updateVaps(storeState, mockStateValues.funnelVaps); mutations.updateGlassToReplace(storeState, mockStateValues.glassToReplace); //Assert expect(getters.experimentOrder(storeState)).toEqual({ funnelVehicleYear: mockStateValues.vehicleYear, funnelVehicleMake: mockStateValues.vehicleMake, funnelVehicleModel: mockStateValues.vehicleModel, funnelVehicleStyle: mockStateValues.vehicleStyle, funnelIsRepair: mockStateValues.isRepair, funnelNumberOfChips: mockStateValues.numberOfChips, funnelCarId: mockStateValues.carId, funnelServiceCity: mockStateValues.serviceCity, funnelServiceState: mockStateValues.serviceState, funnelServiceZipCode: mockStateValues.serviceZipCode, funnelParentAccountNumber: mockStateValues.parentAccountNumber, funnelIsCoverageVerified: mockStateValues.isCoverageVerified, funnelOrderPartNumbers: ["BACKGLASS_PN", "DRIVERGLASS_PN", "PASSENGERGLASS_PN"], funnelOrderPartTypes: [], funnelHasRecalibrationPart: false, funnelSelectedMultiGlass: true, funnelSelectedWindshieldGlass: false, funnelSelectedBackGlass: true, funnelSelectedDriverSideGlass: true, funnelSelectedPassengerSideGlass: true, }); }); }); }); describe("isVinOptionalVehicle", () => { const testVehicles = [ ["2017", "acura", false], ["2017", "ford", false], ["2018", "ford", true], ["2018", "bmw", false], ["2017", "bmw", true], ["2016", "bmw", true], ["2016", "mercedes benz", true], ["2016", "volkswagen", true], ["2016", "audi", true], ["2016", "porsche", true], ]; test.each(testVehicles)( "%s %s should skip vin lookup is %s", async (year, make, expectedVinSkip) => { const context = state; context.state = { order: { vehicle: { year: year, make: make }, }, }; var vinOptionalResult = actions.isVinOptionalVehicle(context); expect(vinOptionalResult).toEqual(expectedVinSkip); } ); });