CSR-120: refactoring
This commit is contained in:
parent
fa711e22d0
commit
75f3391423
2 changed files with 11 additions and 21 deletions
|
|
@ -1,13 +1,14 @@
|
||||||
import { shallowMount, enableAutoUnmount } from '@vue/test-utils';
|
import { shallowMount, enableAutoUnmount } from '@vue/test-utils';
|
||||||
import vehicleBanner from './vehicle-banner';
|
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', () => {
|
describe('vehicleBanner', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions({
|
const mountOptions = getMountOptions({
|
||||||
actionList: [
|
actionList: [
|
||||||
{
|
{
|
||||||
actionName: "lookupVehicleByYmms",
|
actionName: storeActions.LOOKUP_VEHICLE_BY_YMMS,
|
||||||
data: [
|
data: [
|
||||||
{
|
{
|
||||||
CarId: "CR00068434"
|
CarId: "CR00068434"
|
||||||
|
|
@ -15,7 +16,7 @@ describe('vehicleBanner', () => {
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
actionName: "lookupVehicleByVin",
|
actionName: storeActions.LOOKUP_VEHICLE_BY_VIN,
|
||||||
data: [
|
data: [
|
||||||
{
|
{
|
||||||
CarId: "CR00068434"
|
CarId: "CR00068434"
|
||||||
|
|
@ -23,7 +24,7 @@ describe('vehicleBanner', () => {
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
actionName: "getEvoxImage",
|
actionName: storeActions.GET_EVOX_IMAGE,
|
||||||
data: {
|
data: {
|
||||||
imgSrc: "https://s3.amazonaws.com/safelite-lab-vehicle-images/Evox/8963_cc0320_032_UG_white_2014_Ford_Focus_18029225538399034889.jpg"
|
imgSrc: "https://s3.amazonaws.com/safelite-lab-vehicle-images/Evox/8963_cc0320_032_UG_white_2014_Ford_Focus_18029225538399034889.jpg"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,34 +52,23 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getCarIdWithYmms(ymms) { // retrieve carId with YMMS object
|
getCarIdWithYmms(ymms) { // retrieve carId with YMMS object
|
||||||
console.log('ymms: ', ymms)
|
|
||||||
this.dispatchNonBlockingStoreAction(this.storeActions.LOOKUP_VEHICLE_BY_YMMS, ymms).then((response) => {
|
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;
|
const carId = response.data[0].CarId;
|
||||||
console.log('carId: ', carId);
|
|
||||||
this.getVehicleImage(carId)
|
this.getVehicleImage(carId)
|
||||||
}).catch(error => {
|
|
||||||
console.debug(`An error has occurred: ${error}`);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getCarIdWithVin(vin) { // retrieve carId with VIN string
|
getCarIdWithVin(vin) { // retrieve carId with VIN string
|
||||||
this.dispatchNonBlockingStoreAction(this.storeActions.LOOKUP_VEHICLE_BY_VIN, vin).then((response) => {
|
this.dispatchNonBlockingStoreAction(this.storeActions.LOOKUP_VEHICLE_BY_VIN, vin).then((response) => {
|
||||||
console.log('response2: ', response);
|
|
||||||
const carId = response.data[0].CarId;
|
const carId = response.data[0].CarId;
|
||||||
console.log('carId: ', carId);
|
|
||||||
this.getVehicleImage(carId)
|
this.getVehicleImage(carId)
|
||||||
}).catch(error => {
|
|
||||||
console.debug(`An error has occurred: ${error}`);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
async getVehicleImage(carId) { // look up evox with carId
|
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});
|
this.dispatchNonBlockingStoreAction(this.storeActions.GET_EVOX_IMAGE, {relativeUrl: "https://mockey.qa.sagaws.net/service/evox-image?carId=" + carId}).then((response) => {
|
||||||
if (evoxResponse.data && evoxResponse.data.imgSrc) {
|
if (response.data && response.data.imgSrc) {
|
||||||
this.vehicleImageSrc = evoxResponse.data.imgSrc;
|
this.vehicleImageSrc = response.data.imgSrc;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue