Formatting and Unit Tests

This commit is contained in:
Scott Kiener 2025-07-17 15:32:08 -04:00
parent 7341f0a88e
commit d5ab55644f
4 changed files with 36 additions and 74 deletions

View file

@ -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) {

View file

@ -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);
});
});
});

View file

@ -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,

View file

@ -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,