diff --git a/src/layouts/service-location/service-location.spec.js b/src/layouts/service-location/service-location.spec.js index 1e19c00f7..f83cdc624 100644 --- a/src/layouts/service-location/service-location.spec.js +++ b/src/layouts/service-location/service-location.spec.js @@ -101,6 +101,59 @@ describe("service-location.vue", () => { expect(arePagePrerequisitesValid).toBe(false); }); }); + + describe("updating service zip", () => { + test("resets mobile location when service zip code is updated", () => { + // Arrange + const { wrapper } = setupMocks({}); + const newZip = "61606"; + + // Act + wrapper.vm.$refs.mobileLocationModalQuestions.resetComponent = jest.fn(); + wrapper.vm.resetMobileLocation(newZip); + + // Assert + expect(wrapper.vm.mobileLocationQuestions.serviceZipCode).toBe(newZip); + }); + + test("updates service zip code serviceZipCodeQuestion when resetServiceZipCode is called", () => { + // Arrange + const { wrapper } = setupMocks({}); + const newServiceZipCodeQuestion = { + zipCode: "61606", + state: "IL", + isServiceable: true, + }; + + // Act + wrapper.vm.$refs.mobileLocationModalQuestions.resetComponent = jest.fn(); + wrapper.vm.resetServiceZipCode(newServiceZipCodeQuestion); + + // Assert + expect(wrapper.vm.serviceZipCodeQuestion).toStrictEqual(newServiceZipCodeQuestion); + }); + + test("resets mobile location in watch for serviceZipCodeQuestion", async () => { + // Arrange + const { wrapper } = setupMocks({}); + const newServiceZipCodeQuestion = { + zipCode: "61606", + state: "IL", + isServiceable: true, + }; + + // Act + wrapper.vm.$refs.mobileLocationModalQuestions.resetComponent = jest.fn(); + wrapper.vm.serviceZipCodeQuestion = newServiceZipCodeQuestion; + + await wrapper.vm.$nextTick(); + + // Assert + expect(wrapper.vm.mobileLocationQuestions.serviceZipCode).toStrictEqual( + newServiceZipCodeQuestion.zipCode + ); + }); + }); }); function setupMocks({ mountOptionsMockData = {} }) {