CSR-120: refactoring

This commit is contained in:
Adam Caouette 2021-11-23 10:32:40 -05:00
parent fa711e22d0
commit 75f3391423
2 changed files with 11 additions and 21 deletions

View file

@ -1,13 +1,14 @@
import { shallowMount, enableAutoUnmount } from '@vue/test-utils';
import vehicleBanner from './vehicle-banner';
import { getMountOptions } from "@/helpers/unit-test-helper.js"
import { getMountOptions } from "@/helpers/unit-test-helper.js";
import { storeActions } from "@/constants/store-actions";
describe('vehicleBanner', () => {
// Arrange
const mountOptions = getMountOptions({
actionList: [
{
actionName: "lookupVehicleByYmms",
actionName: storeActions.LOOKUP_VEHICLE_BY_YMMS,
data: [
{
CarId: "CR00068434"
@ -15,7 +16,7 @@ describe('vehicleBanner', () => {
]
},
{
actionName: "lookupVehicleByVin",
actionName: storeActions.LOOKUP_VEHICLE_BY_VIN,
data: [
{
CarId: "CR00068434"
@ -23,7 +24,7 @@ describe('vehicleBanner', () => {
]
},
{
actionName: "getEvoxImage",
actionName: storeActions.GET_EVOX_IMAGE,
data: {
imgSrc: "https://s3.amazonaws.com/safelite-lab-vehicle-images/Evox/8963_cc0320_032_UG_white_2014_Ford_Focus_18029225538399034889.jpg"
}

View file

@ -52,34 +52,23 @@ export default {
},
methods: {
getCarIdWithYmms(ymms) { // retrieve carId with YMMS object
console.log('ymms: ', ymms)
this.dispatchNonBlockingStoreAction(this.storeActions.LOOKUP_VEHICLE_BY_YMMS, ymms).then((response) => {
console.log('response1: ', response);
console.log('response1.data: ', response.data);
console.log('response1.data[0]: ', response.data[0]);
console.log('response1.data[0].CarId: ', response.data[0].CarId);
const carId = response.data[0].CarId;
console.log('carId: ', carId);
this.getVehicleImage(carId)
}).catch(error => {
console.debug(`An error has occurred: ${error}`);
});
},
getCarIdWithVin(vin) { // retrieve carId with VIN string
this.dispatchNonBlockingStoreAction(this.storeActions.LOOKUP_VEHICLE_BY_VIN, vin).then((response) => {
console.log('response2: ', response);
const carId = response.data[0].CarId;
console.log('carId: ', carId);
this.getVehicleImage(carId)
}).catch(error => {
console.debug(`An error has occurred: ${error}`);
});
},
async getVehicleImage(carId) { // look up evox with carId
const evoxResponse = await this.dispatchNonBlockingStoreAction(this.storeActions.GET_EVOX_IMAGE, {relativeUrl: "https://mockey.qa.sagaws.net/service/evox-image?carId=" + carId});
if (evoxResponse.data && evoxResponse.data.imgSrc) {
this.vehicleImageSrc = evoxResponse.data.imgSrc;
}
getVehicleImage(carId) { // look up evox with carId
this.dispatchNonBlockingStoreAction(this.storeActions.GET_EVOX_IMAGE, {relativeUrl: "https://mockey.qa.sagaws.net/service/evox-image?carId=" + carId}).then((response) => {
if (response.data && response.data.imgSrc) {
this.vehicleImageSrc = response.data.imgSrc;
}
});
}
}
}