From d5ab55644f32004e5ed72332c9907b57c3ff21c1 Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Thu, 17 Jul 2025 15:32:08 -0400 Subject: [PATCH] Formatting and Unit Tests --- src/layouts/schedule/schedule.vue | 7 +-- .../service-location-helper.spec.js | 40 +---------------- .../shop-list-button/shop-list-button.vue | 19 ++++---- .../shop-question/shop-question-popup.vue | 44 +++++++++---------- 4 files changed, 36 insertions(+), 74 deletions(-) diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index 87357744a..5d07867ec 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -1148,16 +1148,17 @@ export default { onShopSelected(shopQuestionPopUpData) { this.shopProviderData = shopQuestionPopUpData.shopProviderData; this.setServiceabilityDetails(shopQuestionPopUpData.serviceabilityDetails); - this.selectedProvider = this.shopProviderData.shopProviders.find(shopProvider => { + this.selectedProvider = this.shopProviderData.shopProviders.find((shopProvider) => { return shopProvider.providerNumber === shopQuestionPopUpData.selectedProviderNumber; - }) + }); // No zipCodeData comes back if zip was not changed if (shopQuestionPopUpData.zipCodeData) { this.zipCode = shopQuestionPopUpData.zipCodeData.zipCode; this.state = shopQuestionPopUpData.zipCodeData.state; this.zipCodeCtu = shopQuestionPopUpData.zipCodeData.zipCodeCtu; - this.zipContainsMilitaryBase = shopQuestionPopUpData.zipCodeData.containsMilitaryBase; + this.zipContainsMilitaryBase = + shopQuestionPopUpData.zipCodeData.containsMilitaryBase; } }, async getMoreScheduleData(startDate, endDate) { diff --git a/src/layouts/service-location/helpers/service-location-helper/service-location-helper.spec.js b/src/layouts/service-location/helpers/service-location-helper/service-location-helper.spec.js index 06f34f125..6b21b2a96 100644 --- a/src/layouts/service-location/helpers/service-location-helper/service-location-helper.spec.js +++ b/src/layouts/service-location/helpers/service-location-helper/service-location-helper.spec.js @@ -1,8 +1,4 @@ -import { - getPricedMobileFeePart, - getServiceabilityDetails, - getAvailabilityRating, -} from "./service-location-helper"; +import { getPricedMobileFeePart, getServiceabilityDetails } from "./service-location-helper"; import { storeActions } from "@/constants/store-actions"; jest.mock("@/store", () => ({ @@ -320,38 +316,4 @@ describe("service-location-helper.js", () => { expect(result).toEqual(expected); }); }); - - describe("getAvailabilityRating", () => { - it("Should return a 'high' rating", async () => { - // Arrange - const providerNumber = "0000001"; - const expected = "high"; - // Act - const result = await getAvailabilityRating( - "2023-06-30", - "2023-07-06", - "Inshop", - providerNumber - ); - - // Assert - expect(result).toEqual(expected); - }); - - it("Should return a 'low' rating", async () => { - // Arrange - const providerNumber = "0000000"; - const expected = "low"; - // Act - const result = await getAvailabilityRating( - "2023-06-30", - "2023-07-06", - "Inshop", - providerNumber - ); - - // Assert - expect(result).toEqual(expected); - }); - }); }); diff --git a/src/layouts/service-location/shop-question/shop-list-button/shop-list-button.vue b/src/layouts/service-location/shop-question/shop-list-button/shop-list-button.vue index f44a4156a..ece95aea6 100644 --- a/src/layouts/service-location/shop-question/shop-list-button/shop-list-button.vue +++ b/src/layouts/service-location/shop-question/shop-list-button/shop-list-button.vue @@ -66,10 +66,14 @@ export default { const shopAppointmentType = this.additionalButtonData.shopAppointmentType; - this.getAvailabilityRating(formattedStartDate, formattedEndDate, shopAppointmentType, this.value) - .then((data) => { - this.availabilityRating = data; - }); + this.getAvailabilityRating( + formattedStartDate, + formattedEndDate, + shopAppointmentType, + this.value + ).then((data) => { + this.availabilityRating = data; + }); } }, data() { @@ -106,12 +110,7 @@ export default { displayLoader() { this.isLoaderDisplayed = true; }, - async getAvailabilityRating( - startDate, - endDate, - shopAppointmentType, - providerNumber - ) { + async getAvailabilityRating(startDate, endDate, shopAppointmentType, providerNumber) { // For a given shop provider number and date range, get the appointment time slots available const shopTimeSlots = await this.dispatchStoreActionWithLogging( this.storeActions.GET_SHOP_TIME_SLOTS, diff --git a/src/layouts/service-location/shop-question/shop-question-popup.vue b/src/layouts/service-location/shop-question/shop-question-popup.vue index 84b6f3d3a..e2a30c5c6 100644 --- a/src/layouts/service-location/shop-question/shop-question-popup.vue +++ b/src/layouts/service-location/shop-question/shop-question-popup.vue @@ -166,24 +166,25 @@ export default { ); }, answers() { - const updatedProvidersToDisplay = this.shopProviders.slice(0, this.numberOfShopsToDisplay); - return updatedProvidersToDisplay.map( - (shopProvider) => { - const streetAddress = this.toTitleCase(shopProvider.address.streetAddress); - const city = this.toTitleCase(shopProvider.address.city); - const state = shopProvider.address.state; - const zipCode = shopProvider.address.zipCode; - const distanceInMiles = Math.round(shopProvider.distanceInMiles * 2) / 2; - - return { - buttonLabel: city, - buttonLabelSubCopy: `${distanceInMiles} mi`, - buttonBodyCopy: `${streetAddress}, ${city}, ${state} ${zipCode}`, - additionalButtonData: this.additionalButtonData, - value: shopProvider.providerNumber, - }; - } + const updatedProvidersToDisplay = this.shopProviders.slice( + 0, + this.numberOfShopsToDisplay ); + return updatedProvidersToDisplay.map((shopProvider) => { + const streetAddress = this.toTitleCase(shopProvider.address.streetAddress); + const city = this.toTitleCase(shopProvider.address.city); + const state = shopProvider.address.state; + const zipCode = shopProvider.address.zipCode; + const distanceInMiles = Math.round(shopProvider.distanceInMiles * 2) / 2; + + return { + buttonLabel: city, + buttonLabelSubCopy: `${distanceInMiles} mi`, + buttonBodyCopy: `${streetAddress}, ${city}, ${state} ${zipCode}`, + additionalButtonData: this.additionalButtonData, + value: shopProvider.providerNumber, + }; + }); }, }, methods: { @@ -245,7 +246,7 @@ export default { ); }, closeModal() { - this.modal.closeModal(); + this.modal.closeModal(); }, async onSearchZip(event) { event.preventDefault(); @@ -303,13 +304,12 @@ export default { serviceabilityDetails: serviceabilityDetails.data, zipCodeData: this.zipCodeData, shopProviderData: this.localShopProviderData, - selectedProviderNumber: this.localSelectedProviderNumber - } + selectedProviderNumber: this.localSelectedProviderNumber, + }; this.$emit("shop-selected", shopQuestionPopUpData); this.closeModal(); - - } + }, }, components: { modal,