From 14541d110c0ddcd0216eb76e4ea6ba4a61dfcdbf Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Thu, 16 Mar 2023 16:00:08 -0400 Subject: [PATCH] Updates for emitting contains military zip --- .../service-location/service-location.spec.js | 12 ++++++---- .../service-location/service-location.vue | 22 +++++++------------ .../service-zip-modal-question.vue | 3 +++ 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/layouts/service-location/service-location.spec.js b/src/layouts/service-location/service-location.spec.js index 0653e91f0..b48fa2f06 100644 --- a/src/layouts/service-location/service-location.spec.js +++ b/src/layouts/service-location/service-location.spec.js @@ -319,11 +319,15 @@ describe("service-location.vue", () => { state: "OH", }; - // Assert - wrapper.setData({ zipCode: newServiceZipCodeQuestion.zipCode }); - wrapper.vm.$nextTick(() => { - expect(wrapper.vm.zipContainsMilitaryBase).toBe(true); + const serviceZipCodeComponent = wrapper.findComponent({ + ref: "serviceZipCodeQuestion", }); + + // Act + serviceZipCodeComponent.vm.$emit("updated-contains-military-base", true); + + // Assert + expect(wrapper.vm.zipContainsMilitaryBase).toBe(true); }); }); diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index 58f440708..732b0f0b1 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -10,7 +10,8 @@ :mobileFeePart="mobileFeePart" @updated-mobile-fee-part="setMobileFeePart" linkWidgetName="ServiceZipLinkWidget" - modalWidgetName="ServiceZipModalWidget" /> + modalWidgetName="ServiceZipModalWidget" + @updated-contains-military-base="setContainsMilitaryBase" /> @@ -141,9 +142,6 @@ export default { this.isVehicleProtected = newValue.isVehicleProtected; }, }, - shouldDisableForwardAction() { - return this.zipContainsMilitaryBase; - }, }, methods: { arePagePrerequisitesValid() { @@ -158,6 +156,11 @@ export default { this.mobileFeePart = mobileFeePart; } }, + setContainsMilitaryBase(val) { + if (this.zipContainsMilitaryBase !== val) { + this.zipContainsMilitaryBase = val; + } + }, getServiceAddressFromStore() { return store.getters.order.serviceLocation.address; }, @@ -187,15 +190,6 @@ export default { navigateToHeritageFunnel({ loadingModal: this.$refs.loadingModal }); }, }, - watch: { - zipCode(current, previous) { - if (current !== previous) { - baseMixin.methods.getZipCodeData(current).then((r) => { - this.zipContainsMilitaryBase = r.containsMilitaryBase; - }); - } - }, - }, components: { alert, serviceZipModalQuestion, diff --git a/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.vue b/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.vue index 0d2c35000..1b665b5d5 100644 --- a/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.vue +++ b/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.vue @@ -44,6 +44,7 @@ import { getPricedMobileFeePart } from "@/layouts/service-location/helpers/servi export default { name: "service-zip-modal-question", emits: ["update:modelValue", "updated-mobile-fee-part"], + emits: ["updated-contains-military-base"], data() { return { internalModel: this.copyModel(this.modelValue), @@ -160,6 +161,8 @@ export default { // Update the page level model this.$emit("update:modelValue", this.internalModel); + this.$emit("updated-contains-military-base", zipCodeData.containsMilitaryBase); + this.closeModal(); } },