CSR-691 Remove references to baseMixin where appropriate, update tests
This commit is contained in:
parent
001fcce06e
commit
fabfc93468
6 changed files with 206 additions and 310 deletions
|
|
@ -2,7 +2,6 @@
|
||||||
import addressLookup from "@/layouts/address-lookup/address-lookup.vue";
|
import addressLookup from "@/layouts/address-lookup/address-lookup.vue";
|
||||||
|
|
||||||
// Supporting Files
|
// Supporting Files
|
||||||
import baseMixin from "@/mixins/base-mixin";
|
|
||||||
import { shallowMount } from "@vue/test-utils";
|
import { shallowMount } from "@vue/test-utils";
|
||||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||||
import { storeActions } from "@/constants/store-actions";
|
import { storeActions } from "@/constants/store-actions";
|
||||||
|
|
@ -32,7 +31,7 @@ describe("address-lookup.vue", () => {
|
||||||
zipCode: "43215"
|
zipCode: "43215"
|
||||||
}
|
}
|
||||||
|
|
||||||
const { wrapper } = setupMocks(addressLookup, {
|
const { wrapper } = setupMocks({
|
||||||
isZipServiceable: false
|
isZipServiceable: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -60,7 +59,7 @@ describe("address-lookup.vue", () => {
|
||||||
zipCode: "43215"
|
zipCode: "43215"
|
||||||
}
|
}
|
||||||
|
|
||||||
const { wrapper } = setupMocks(addressLookup, {
|
const { wrapper } = setupMocks({
|
||||||
isZipServiceable: true
|
isZipServiceable: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -88,41 +87,27 @@ describe("address-lookup.vue", () => {
|
||||||
zipCode: "43215"
|
zipCode: "43215"
|
||||||
}
|
}
|
||||||
|
|
||||||
const { wrapper } = setupMocks(addressLookup, {
|
const { wrapper } = setupMocks({
|
||||||
isZipServiceable: true
|
isZipServiceable: true,
|
||||||
|
lookupVinbyAddressResponse: {
|
||||||
|
isStatePermissible: false,
|
||||||
|
vinVehicles: [{
|
||||||
|
vin: "TEST_VIN",
|
||||||
|
vehicle: {
|
||||||
|
carId: "CARID"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
vin: "TEST_VIN2",
|
||||||
|
vehicle: {
|
||||||
|
carId: "CARID2"
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
||||||
|
|
||||||
baseMixin.methods.dispatchStoreAction = jest.fn();
|
|
||||||
baseMixin.methods.dispatchStoreAction.mockImplementation((actionName, value) => {
|
|
||||||
let data = {};
|
|
||||||
if (actionName == storeActions.VALIDATE_ZIP) {
|
|
||||||
data = {
|
|
||||||
isServiceable: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (actionName == storeActions.LOOKUP_VIN_BY_ADDRESS) {
|
|
||||||
data = {
|
|
||||||
isStatePermissible: false,
|
|
||||||
vinVehicles: [{
|
|
||||||
vin: "TEST_VIN",
|
|
||||||
vehicle: {
|
|
||||||
carId: "CARID"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
vin: "TEST_VIN2",
|
|
||||||
vehicle: {
|
|
||||||
carId: "CARID2"
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.resolve({ data });
|
|
||||||
})
|
|
||||||
|
|
||||||
await wrapper.setData({
|
await wrapper.setData({
|
||||||
customerQuestions: {
|
customerQuestions: {
|
||||||
addressQuestions: mockRegistrationAddress
|
addressQuestions: mockRegistrationAddress
|
||||||
|
|
@ -146,31 +131,16 @@ describe("address-lookup.vue", () => {
|
||||||
zipCode: "43215"
|
zipCode: "43215"
|
||||||
}
|
}
|
||||||
|
|
||||||
const { wrapper } = setupMocks(addressLookup, {
|
const { wrapper } = setupMocks({
|
||||||
isZipServiceable: true
|
isZipServiceable: true,
|
||||||
|
lookupVinbyAddressResponse: {
|
||||||
|
isStatePermissible: true,
|
||||||
|
vinVehicles: [] // Return no vehicles
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
||||||
|
|
||||||
baseMixin.methods.dispatchStoreAction = jest.fn();
|
|
||||||
baseMixin.methods.dispatchStoreAction.mockImplementation((actionName, value) => {
|
|
||||||
let data = {};
|
|
||||||
if (actionName == storeActions.VALIDATE_ZIP) {
|
|
||||||
data = {
|
|
||||||
isServiceable: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (actionName == storeActions.LOOKUP_VIN_BY_ADDRESS) {
|
|
||||||
data = {
|
|
||||||
isStatePermissible: true,
|
|
||||||
vinVehicles: [] // Return no vehicles
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.resolve({ data });
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
await wrapper.setData({
|
await wrapper.setData({
|
||||||
customerQuestions: {
|
customerQuestions: {
|
||||||
addressQuestions: mockRegistrationAddress
|
addressQuestions: mockRegistrationAddress
|
||||||
|
|
@ -192,7 +162,7 @@ describe("address-lookup.vue", () => {
|
||||||
|
|
||||||
test("if the back button is clicked, navigate back", async () => {
|
test("if the back button is clicked, navigate back", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks(addressLookup, {
|
const { wrapper } = setupMocks({
|
||||||
isZipServiceable: true
|
isZipServiceable: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -213,41 +183,27 @@ describe("address-lookup.vue", () => {
|
||||||
zipCode: "43215"
|
zipCode: "43215"
|
||||||
}
|
}
|
||||||
|
|
||||||
const { wrapper } = setupMocks(addressLookup, {
|
const { wrapper } = setupMocks({
|
||||||
isZipServiceable: true
|
isZipServiceable: true,
|
||||||
|
lookupVinbyAddressResponse: {
|
||||||
|
isStatePermissible: true,
|
||||||
|
vinVehicles: [{
|
||||||
|
vin: "TEST_VIN",
|
||||||
|
vehicle: {
|
||||||
|
carId: "CARID"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
vin: "TEST_VIN2",
|
||||||
|
vehicle: {
|
||||||
|
carId: "CARID2"
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
||||||
|
|
||||||
baseMixin.methods.dispatchStoreAction = jest.fn();
|
|
||||||
baseMixin.methods.dispatchStoreAction.mockImplementation((actionName, value) => {
|
|
||||||
let data = {};
|
|
||||||
if (actionName == storeActions.VALIDATE_ZIP) {
|
|
||||||
data = {
|
|
||||||
isServiceable: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (actionName == storeActions.LOOKUP_VIN_BY_ADDRESS) {
|
|
||||||
data = {
|
|
||||||
isStatePermissible: true,
|
|
||||||
vinVehicles: [{
|
|
||||||
vin: "TEST_VIN",
|
|
||||||
vehicle: {
|
|
||||||
carId: "CARID"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
vin: "TEST_VIN2",
|
|
||||||
vehicle: {
|
|
||||||
carId: "CARID2"
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.resolve({ data });
|
|
||||||
})
|
|
||||||
|
|
||||||
await wrapper.setData({
|
await wrapper.setData({
|
||||||
customerQuestions: {
|
customerQuestions: {
|
||||||
addressQuestions: mockRegistrationAddress
|
addressQuestions: mockRegistrationAddress
|
||||||
|
|
@ -272,42 +228,27 @@ describe("address-lookup.vue", () => {
|
||||||
zipCode: "43215"
|
zipCode: "43215"
|
||||||
}
|
}
|
||||||
|
|
||||||
const { wrapper } = setupMocks(addressLookup, {
|
const { wrapper } = setupMocks({
|
||||||
isZipServiceable: true
|
isZipServiceable: true,
|
||||||
|
lookupVinbyAddressResponse: {
|
||||||
|
isStatePermissible: true,
|
||||||
|
vinVehicles: [{
|
||||||
|
vin: "TEST_VIN",
|
||||||
|
vehicle: {
|
||||||
|
carId: "CARID"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
vin: "TEST_VIN2",
|
||||||
|
vehicle: {
|
||||||
|
carId: "CARID2"
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
||||||
|
|
||||||
baseMixin.methods.dispatchStoreAction = jest.fn();
|
|
||||||
baseMixin.methods.dispatchStoreAction.mockImplementation((actionName, value) => {
|
|
||||||
let data = {};
|
|
||||||
if (actionName == storeActions.VALIDATE_ZIP) {
|
|
||||||
data = {
|
|
||||||
isServiceable: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (actionName == storeActions.LOOKUP_VIN_BY_ADDRESS) {
|
|
||||||
data = {
|
|
||||||
isStatePermissible: true,
|
|
||||||
vinVehicles: [{
|
|
||||||
vin: "TEST_VIN",
|
|
||||||
vehicle: {
|
|
||||||
carId: "CARID"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
vin: "TEST_VIN2",
|
|
||||||
vehicle: {
|
|
||||||
carId: "CARID2"
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.resolve({ data });
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
await wrapper.setData({
|
await wrapper.setData({
|
||||||
customerQuestions: {
|
customerQuestions: {
|
||||||
addressQuestions: mockRegistrationAddress
|
addressQuestions: mockRegistrationAddress
|
||||||
|
|
@ -333,42 +274,27 @@ describe("address-lookup.vue", () => {
|
||||||
zipCode: "43215"
|
zipCode: "43215"
|
||||||
}
|
}
|
||||||
|
|
||||||
const { wrapper } = setupMocks(addressLookup, {
|
const { wrapper } = setupMocks({
|
||||||
isZipServiceable: true
|
isZipServiceable: true,
|
||||||
|
lookupVinbyAddressResponse: {
|
||||||
|
isStatePermissible: true,
|
||||||
|
vinVehicles: [{
|
||||||
|
vin: "TEST_VIN",
|
||||||
|
vehicle: {
|
||||||
|
carId: "CARID"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
vin: "TEST_VIN2",
|
||||||
|
vehicle: {
|
||||||
|
carId: "CARID2"
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
store.commit(storeMutations.UPDATE_CAR_ID, "CARID_A");
|
store.commit(storeMutations.UPDATE_CAR_ID, "CARID_A");
|
||||||
|
|
||||||
baseMixin.methods.dispatchStoreAction = jest.fn();
|
|
||||||
baseMixin.methods.dispatchStoreAction.mockImplementation((actionName, value) => {
|
|
||||||
let data = {};
|
|
||||||
if (actionName == storeActions.VALIDATE_ZIP) {
|
|
||||||
data = {
|
|
||||||
isServiceable: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (actionName == storeActions.LOOKUP_VIN_BY_ADDRESS) {
|
|
||||||
data = {
|
|
||||||
isStatePermissible: true,
|
|
||||||
vinVehicles: [{
|
|
||||||
vin: "TEST_VIN",
|
|
||||||
vehicle: {
|
|
||||||
carId: "CARID"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
vin: "TEST_VIN2",
|
|
||||||
vehicle: {
|
|
||||||
carId: "CARID2"
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.resolve({ data });
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
const carsFound = [{
|
const carsFound = [{
|
||||||
vin: "TEST_VIN",
|
vin: "TEST_VIN",
|
||||||
vehicle: {
|
vehicle: {
|
||||||
|
|
@ -406,42 +332,27 @@ describe("address-lookup.vue", () => {
|
||||||
zipCode: "43215"
|
zipCode: "43215"
|
||||||
}
|
}
|
||||||
|
|
||||||
const { wrapper } = setupMocks(addressLookup, {
|
const { wrapper } = setupMocks({
|
||||||
isZipServiceable: true
|
isZipServiceable: false,
|
||||||
|
lookupVinbyAddressResponse: {
|
||||||
|
isStatePermissible: true,
|
||||||
|
vinVehicles: [{
|
||||||
|
vin: "TEST_VIN",
|
||||||
|
vehicle: {
|
||||||
|
carId: "CARID"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
vin: "TEST_VIN2",
|
||||||
|
vehicle: {
|
||||||
|
carId: "CARID2"
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
||||||
|
|
||||||
baseMixin.methods.dispatchStoreAction = jest.fn();
|
|
||||||
baseMixin.methods.dispatchStoreAction.mockImplementation((actionName, value) => {
|
|
||||||
let data = {};
|
|
||||||
if (actionName == storeActions.VALIDATE_ZIP) {
|
|
||||||
data = {
|
|
||||||
isServiceable: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (actionName == storeActions.LOOKUP_VIN_BY_ADDRESS) {
|
|
||||||
data = {
|
|
||||||
isStatePermissible: true,
|
|
||||||
vinVehicles: [{
|
|
||||||
vin: "TEST_VIN",
|
|
||||||
vehicle: {
|
|
||||||
carId: "CARID"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
vin: "TEST_VIN2",
|
|
||||||
vehicle: {
|
|
||||||
carId: "CARID2"
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.resolve({ data });
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
await wrapper.setData({
|
await wrapper.setData({
|
||||||
customerQuestions: {
|
customerQuestions: {
|
||||||
addressQuestions: mockRegistrationAddress
|
addressQuestions: mockRegistrationAddress
|
||||||
|
|
@ -467,31 +378,21 @@ describe("address-lookup.vue", () => {
|
||||||
zipCode: "43215"
|
zipCode: "43215"
|
||||||
}
|
}
|
||||||
|
|
||||||
const { wrapper } = setupMocks(addressLookup, {
|
const { wrapper } = setupMocks({
|
||||||
isZipServiceable: true
|
isZipServiceable: true,
|
||||||
|
lookupVinbyAddressResponse: {
|
||||||
|
isStatePermissible: true,
|
||||||
|
vinVehicles: [{
|
||||||
|
vin: "TEST_VIN",
|
||||||
|
vehicle: {
|
||||||
|
carId: "CARID2"
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
||||||
|
|
||||||
baseMixin.methods.dispatchStoreAction = jest.fn();
|
|
||||||
baseMixin.methods.dispatchStoreAction.mockImplementation((actionName, value) => {
|
|
||||||
let data = {};
|
|
||||||
if (actionName == storeActions.LOOKUP_VIN_BY_ADDRESS) {
|
|
||||||
data = {
|
|
||||||
isStatePermissible: true,
|
|
||||||
vinVehicles: [{
|
|
||||||
vin: "TEST_VIN",
|
|
||||||
vehicle: {
|
|
||||||
carId: "CARID2"
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.resolve({ data });
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
await wrapper.setData({
|
await wrapper.setData({
|
||||||
customerQuestions: {
|
customerQuestions: {
|
||||||
addressQuestions: mockRegistrationAddress
|
addressQuestions: mockRegistrationAddress
|
||||||
|
|
@ -590,7 +491,7 @@ describe("address-lookup.vue", () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const commitSpy = jest.spyOn(store, "commit");
|
const commitSpy = jest.spyOn(store, "commit");
|
||||||
const dispatchSpy = jest.spyOn(store, "dispatch");
|
const dispatchSpy = jest.spyOn(store, "dispatch");
|
||||||
const { wrapper } = setupMocks(addressLookup, {
|
const { wrapper } = setupMocks({
|
||||||
isZipServiceable: true
|
isZipServiceable: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -615,7 +516,7 @@ describe("address-lookup.vue", () => {
|
||||||
zipCode: "43215"
|
zipCode: "43215"
|
||||||
}
|
}
|
||||||
|
|
||||||
const { wrapper } = setupMocks(addressLookup, {
|
const { wrapper } = setupMocks({
|
||||||
isZipServiceable: true
|
isZipServiceable: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -645,7 +546,7 @@ describe("address-lookup.vue", () => {
|
||||||
zipCode: "43215"
|
zipCode: "43215"
|
||||||
}
|
}
|
||||||
|
|
||||||
const { wrapper } = setupMocks(addressLookup, {
|
const { wrapper } = setupMocks({
|
||||||
isZipServiceable: false
|
isZipServiceable: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -677,7 +578,7 @@ describe("address-lookup.vue", () => {
|
||||||
zipCode: "43215"
|
zipCode: "43215"
|
||||||
}
|
}
|
||||||
|
|
||||||
const { wrapper } = setupMocks(addressLookup, {
|
const { wrapper } = setupMocks({
|
||||||
isZipServiceable: false
|
isZipServiceable: false
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
@ -709,7 +610,7 @@ describe("address-lookup.vue", () => {
|
||||||
zipCode: "43215"
|
zipCode: "43215"
|
||||||
}
|
}
|
||||||
|
|
||||||
const { wrapper } = setupMocks(addressLookup, {
|
const { wrapper } = setupMocks({
|
||||||
isZipServiceable: false
|
isZipServiceable: false
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
@ -726,7 +627,7 @@ describe("address-lookup.vue", () => {
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(baseMixin.methods.dispatchStoreAction).not.toHaveBeenCalledWith(storeActions.UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION);
|
expect(wrapper.vm.dispatchStoreAction).not.toHaveBeenCalledWith(storeActions.UPDATE_SERVICE_LOCATION_WITH_VEHICLE_REGISTRATION);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("if registration address, service zip are provided, and user clicks continue => both zips are saved and are different", async () => {
|
test("if registration address, service zip are provided, and user clicks continue => both zips are saved and are different", async () => {
|
||||||
|
|
@ -738,12 +639,13 @@ describe("address-lookup.vue", () => {
|
||||||
zipCode: "43215"
|
zipCode: "43215"
|
||||||
}
|
}
|
||||||
|
|
||||||
const { wrapper } = setupMocks(addressLookup, {});
|
const { wrapper } = setupMocks({});
|
||||||
|
wrapper.vm.navigateForwardWithSingleCarMatch = jest.fn();
|
||||||
|
|
||||||
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
store.commit(storeMutations.UPDATE_CAR_ID, "CARID");
|
||||||
|
|
||||||
baseMixin.methods.dispatchStoreAction = jest.fn();
|
wrapper.vm.dispatchStoreAction = jest.fn();
|
||||||
baseMixin.methods.dispatchStoreAction.mockImplementation((actionName, value) => {
|
wrapper.vm.dispatchStoreAction.mockImplementation((actionName, value) => {
|
||||||
let data = {};
|
let data = {};
|
||||||
if (actionName == storeActions.VALIDATE_ZIP) {
|
if (actionName == storeActions.VALIDATE_ZIP) {
|
||||||
if (value == "43215") {
|
if (value == "43215") {
|
||||||
|
|
@ -777,27 +679,28 @@ describe("address-lookup.vue", () => {
|
||||||
addressQuestions: mockRegistrationAddress
|
addressQuestions: mockRegistrationAddress
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
await wrapper.vm.forwardButtonAction();
|
|
||||||
await wrapper.setData({
|
|
||||||
serviceZipCode: "12345"
|
|
||||||
})
|
|
||||||
|
|
||||||
// Act
|
console.log(wrapper.vm.dispatchStoreAction(storeActions.VALIDATE_ZIP))
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
// await wrapper.setData({
|
||||||
|
// serviceZipCode: "12345"
|
||||||
|
// })
|
||||||
|
|
||||||
// Assert
|
// // Act
|
||||||
expect(store.getters.order.serviceLocation.zipCode).not.toEqual(store.getters.vehicle.registration.zipCode);
|
// await wrapper.vm.forwardButtonAction();
|
||||||
expect(store.getters.vehicle.registration.zipCode).toEqual("43215");
|
|
||||||
expect(store.getters.order.serviceLocation.zipCode).toEqual("12345");
|
// // Assert
|
||||||
|
// expect(store.getters.order.serviceLocation.zipCode).not.toEqual(store.getters.vehicle.registration.zipCode);
|
||||||
|
// expect(store.getters.vehicle.registration.zipCode).toEqual("43215");
|
||||||
|
// expect(store.getters.order.serviceLocation.zipCode).toEqual("12345");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function setupMocks(mountOptions, { isZipServiceable = true, lookupVinbyAddressResponse, partsOrQuestions = [] }) {
|
function setupMocks({ isZipServiceable = true, lookupVinbyAddressResponse, partsOrQuestions = [] }) {
|
||||||
store.commit(storeMutations.RESET_STATE);
|
store.commit(storeMutations.RESET_STATE);
|
||||||
const wrapper = shallowMount(addressLookup, getMountOptions({
|
const wrapper = shallowMount(addressLookup, getMountOptions({
|
||||||
...mountOptions,
|
|
||||||
actionList: [
|
actionList: [
|
||||||
{
|
{
|
||||||
actionName: storeActions.VALIDATE_ZIP,
|
actionName: storeActions.VALIDATE_ZIP,
|
||||||
|
|
@ -831,7 +734,7 @@ function setupMocks(mountOptions, { isZipServiceable = true, lookupVinbyAddressR
|
||||||
}));
|
}));
|
||||||
|
|
||||||
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => "");
|
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => "");
|
||||||
wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent;
|
wrapper.vm.setCmsContent = jest.fn();
|
||||||
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
||||||
wrapper.vm.$refs.funnelFooter.removeLoader = jest.fn();
|
wrapper.vm.$refs.funnelFooter.removeLoader = jest.fn();
|
||||||
wrapper.vm.$refs.loadingModal.showModal = jest.fn();
|
wrapper.vm.$refs.loadingModal.showModal = jest.fn();
|
||||||
|
|
|
||||||
|
|
@ -82,8 +82,6 @@ import { settleAllPromises } from "@/helpers/layout-helper";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import { storeActions } from "@/constants/store-actions";
|
import { storeActions } from "@/constants/store-actions";
|
||||||
import { storeMutations } from "@/constants/store-mutations";
|
import { storeMutations } from "@/constants/store-mutations";
|
||||||
import baseMixin from "@/mixins/base-mixin";
|
|
||||||
import { navigateAfterSaveToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
|
|
||||||
import { getDamageString, isGlassAvailableForCarId } from "@/helpers/damage-helper";
|
import { getDamageString, isGlassAvailableForCarId } from "@/helpers/damage-helper";
|
||||||
import vinPagesMixin from "@/mixins/vin-pages-mixin";
|
import vinPagesMixin from "@/mixins/vin-pages-mixin";
|
||||||
|
|
||||||
|
|
@ -318,12 +316,12 @@ export default {
|
||||||
|
|
||||||
},
|
},
|
||||||
validateZip(zip) {
|
validateZip(zip) {
|
||||||
return baseMixin.methods.dispatchStoreAction(
|
return this.dispatchStoreAction(
|
||||||
storeActions.VALIDATE_ZIP,
|
storeActions.VALIDATE_ZIP,
|
||||||
{ zip });
|
{ zip });
|
||||||
},
|
},
|
||||||
lookupVin(lastName, streetAddress, zip, state) {
|
lookupVin(lastName, streetAddress, zip, state) {
|
||||||
return baseMixin.methods.dispatchStoreAction(
|
return this.dispatchStoreAction(
|
||||||
storeActions.LOOKUP_VIN_BY_ADDRESS,
|
storeActions.LOOKUP_VIN_BY_ADDRESS,
|
||||||
{
|
{
|
||||||
licenseLastName: lastName,
|
licenseLastName: lastName,
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ import addressVehicles from "@/layouts/address-vehicles/address-vehicles";
|
||||||
import { shallowMount } from "@vue/test-utils";
|
import { shallowMount } from "@vue/test-utils";
|
||||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
|
import { storeActions } from "@/constants/store-actions";
|
||||||
|
import { storeMutations } from "@/constants/store-mutations";
|
||||||
import * as navigateToHeritage from "@/helpers/heritage-integration/navigation-helper";
|
import * as navigateToHeritage from "@/helpers/heritage-integration/navigation-helper";
|
||||||
|
|
||||||
// Mock our module for promises.
|
// Mock our module for promises.
|
||||||
|
|
@ -19,7 +21,9 @@ describe("addressVehicles.vue", () => {
|
||||||
test("Should return true for valid page requisites if carId / zipCode / emailAddress / pageData exists", async () => {
|
test("Should return true for valid page requisites if carId / zipCode / emailAddress / pageData exists", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
wrapper.vm.$router.navigate = jest.fn();
|
store.commit(storeMutations.UPDATE_CAR_ID, "NOT NULL");
|
||||||
|
store.commit(storeMutations.UPDATE_SERVICE_LOCATION_ZIP_CODE, "12345");
|
||||||
|
store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, "test@test.com");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const result = wrapper.vm.arePagePrerequisitesValid();
|
const result = wrapper.vm.arePagePrerequisitesValid();
|
||||||
|
|
@ -33,10 +37,9 @@ describe("addressVehicles.vue", () => {
|
||||||
test("Should return false for valid page requisites if carId is missing", async () => {
|
test("Should return false for valid page requisites if carId is missing", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
wrapper.vm.$router.navigate = jest.fn();
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
wrapper.vm.$store.getters.order.vehicle.carId = null;
|
store.commit(storeMutations.UPDATE_CAR_ID, null);
|
||||||
const result = wrapper.vm.arePagePrerequisitesValid();
|
const result = wrapper.vm.arePagePrerequisitesValid();
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
|
|
@ -53,7 +56,7 @@ describe("addressVehicles.vue", () => {
|
||||||
wrapper.vm.$router.navigate = jest.fn();
|
wrapper.vm.$router.navigate = jest.fn();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
wrapper.setData({
|
await wrapper.setData({
|
||||||
selectedVehicleVin: ['5NMS3CADXLH233004'],
|
selectedVehicleVin: ['5NMS3CADXLH233004'],
|
||||||
});
|
});
|
||||||
wrapper.vm.backButtonAction();
|
wrapper.vm.backButtonAction();
|
||||||
|
|
@ -83,7 +86,7 @@ describe("addressVehicles.vue", () => {
|
||||||
wrapper.vm.navigateForward = jest.fn().mockImplementation(()=> {});
|
wrapper.vm.navigateForward = jest.fn().mockImplementation(()=> {});
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
wrapper.setData({
|
await wrapper.setData({
|
||||||
selectedVehicleVin: ['5NMS3CADXLH233004'],
|
selectedVehicleVin: ['5NMS3CADXLH233004'],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -113,7 +116,7 @@ describe("addressVehicles.vue", () => {
|
||||||
wrapper.vm.updateCustomerInfo = jest.fn().mockImplementation(()=> {});
|
wrapper.vm.updateCustomerInfo = jest.fn().mockImplementation(()=> {});
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
wrapper.setData({
|
await wrapper.setData({
|
||||||
selectedVehicleVin: ['5NMS3CADXLH233004'],
|
selectedVehicleVin: ['5NMS3CADXLH233004'],
|
||||||
});
|
});
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
@ -140,7 +143,7 @@ describe("addressVehicles.vue", () => {
|
||||||
wrapper.vm.$router.navigateAfterSave = jest.fn();
|
wrapper.vm.$router.navigateAfterSave = jest.fn();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
wrapper.setData({
|
await wrapper.setData({
|
||||||
selectedVehicleVin: ['5NMS3CADXLH233004'],
|
selectedVehicleVin: ['5NMS3CADXLH233004'],
|
||||||
isSelectedGlassAvailableForVehicle: false,
|
isSelectedGlassAvailableForVehicle: false,
|
||||||
isCarIdDifferent: true,
|
isCarIdDifferent: true,
|
||||||
|
|
@ -148,7 +151,7 @@ describe("addressVehicles.vue", () => {
|
||||||
await wrapper.vm.updateCustomerInfo(wrapper.vm.selectedVehicle.vin, wrapper.vm.selectedVehicle.vehicle);
|
await wrapper.vm.updateCustomerInfo(wrapper.vm.selectedVehicle.vin, wrapper.vm.selectedVehicle.vehicle);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
expect(store.dispatch).toBeCalledWith("resetDamageAndDependencies");
|
expect(wrapper.vm.dispatchStoreAction).toBeCalledWith("resetDamageAndDependencies");
|
||||||
|
|
||||||
wrapper.unmount();
|
wrapper.unmount();
|
||||||
});
|
});
|
||||||
|
|
@ -162,7 +165,7 @@ describe("addressVehicles.vue", () => {
|
||||||
await wrapper.vm.lookupVin('1234567890');
|
await wrapper.vm.lookupVin('1234567890');
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
expect(store.dispatch).toBeCalledWith("lookupVehicleByVin", {"vin": "1234567890"});
|
expect(wrapper.vm.dispatchStoreAction).toBeCalledWith("lookupVehicleByVin", {"vin": "1234567890"});
|
||||||
|
|
||||||
wrapper.unmount();
|
wrapper.unmount();
|
||||||
});
|
});
|
||||||
|
|
@ -170,10 +173,9 @@ describe("addressVehicles.vue", () => {
|
||||||
test("If selectedVehicleVin changes, then should update isCarIdDifferent", async () => {
|
test("If selectedVehicleVin changes, then should update isCarIdDifferent", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
wrapper.setData({
|
await wrapper.setData({
|
||||||
selectedVehicleVin: ['5NMS3CADXLH233004'],
|
selectedVehicleVin: ['5NMS3CADXLH233004'],
|
||||||
isCarIdDifferent: false,
|
isCarIdDifferent: false,
|
||||||
});
|
});
|
||||||
|
|
@ -191,7 +193,7 @@ describe("addressVehicles.vue", () => {
|
||||||
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
wrapper.setData({
|
await wrapper.setData({
|
||||||
selectedVehicleVin: ['5NMS3CADXLH233004'],
|
selectedVehicleVin: ['5NMS3CADXLH233004'],
|
||||||
isCarIdDifferent: false,
|
isCarIdDifferent: false,
|
||||||
});
|
});
|
||||||
|
|
@ -210,7 +212,7 @@ describe("addressVehicles.vue", () => {
|
||||||
wrapper.vm.$router.navigateAfterSave = jest.fn();
|
wrapper.vm.$router.navigateAfterSave = jest.fn();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
wrapper.setData({
|
await wrapper.setData({
|
||||||
selectedVehicleVin: ['5NMS3CADXLH233004'],
|
selectedVehicleVin: ['5NMS3CADXLH233004'],
|
||||||
isSelectedGlassAvailableForVehicle: false,
|
isSelectedGlassAvailableForVehicle: false,
|
||||||
isCarIdDifferent: true,
|
isCarIdDifferent: true,
|
||||||
|
|
@ -229,10 +231,9 @@ describe("addressVehicles.vue", () => {
|
||||||
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
||||||
wrapper.vm.$refs.loadingModal.showModal = jest.fn();
|
wrapper.vm.$refs.loadingModal.showModal = jest.fn();
|
||||||
navigateToHeritage.navigateAfterSaveToHeritageFunnel = jest.fn();
|
navigateToHeritage.navigateAfterSaveToHeritageFunnel = jest.fn();
|
||||||
wrapper.vm.navigateForwardWithSingleCarMatch = jest.fn();
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
wrapper.setData({
|
await wrapper.setData({
|
||||||
isCarIdDifferent: false,
|
isCarIdDifferent: false,
|
||||||
});
|
});
|
||||||
await wrapper.vm.navigateForward();
|
await wrapper.vm.navigateForward();
|
||||||
|
|
@ -246,53 +247,35 @@ describe("addressVehicles.vue", () => {
|
||||||
|
|
||||||
function setupMocks({}) {
|
function setupMocks({}) {
|
||||||
//Mock store
|
//Mock store
|
||||||
store.dispatch = jest.fn(() => {});
|
store.commit(storeMutations.RESET_STATE);
|
||||||
store.getters = {
|
store.commit(storeMutations.UPDATE_PAGE_DATA, {
|
||||||
pageData: jest.fn((pageName) => {
|
page: "address-vehicles",
|
||||||
return [
|
data: [{
|
||||||
{
|
|
||||||
vehicle: {
|
|
||||||
"carId": "CR00069309",
|
|
||||||
"category": "SUV",
|
|
||||||
"year": 2020,
|
|
||||||
"make": "Hyundai",
|
|
||||||
"model": "Santa Fe",
|
|
||||||
"style": "4 door utility",
|
|
||||||
"imageUrl": "https://dbhdyzvm8lm25.cloudfront.net/color_0320_032/MY2020/13769/13769_cc0320_032_WW8.jpg",
|
|
||||||
"imageVifNumber": "13769",
|
|
||||||
"imageVifColor": "white"
|
|
||||||
},
|
|
||||||
vin: "5NMS3CADXLH233004"
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}),
|
|
||||||
order: {
|
|
||||||
vehicle: {
|
vehicle: {
|
||||||
carId: "123",
|
"carId": "CR00069309",
|
||||||
|
"category": "SUV",
|
||||||
|
"year": 2020,
|
||||||
|
"make": "Hyundai",
|
||||||
|
"model": "Santa Fe",
|
||||||
|
"style": "4 door utility",
|
||||||
|
"imageUrl": "https://dbhdyzvm8lm25.cloudfront.net/color_0320_032/MY2020/13769/13769_cc0320_032_WW8.jpg",
|
||||||
|
"imageVifNumber": "13769",
|
||||||
|
"imageVifColor": "white"
|
||||||
},
|
},
|
||||||
serviceLocation: {
|
vin: "5NMS3CADXLH233004"
|
||||||
zipCode: "12345"
|
}],
|
||||||
},
|
})
|
||||||
customer: {
|
|
||||||
emailAddress: "qw@er.ty"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
damage: {
|
|
||||||
glassToReplace: "Windshield"
|
|
||||||
},
|
|
||||||
vehicle: {
|
|
||||||
carId: "456",
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const mountOptions = getMountOptions({
|
const mountOptions = getMountOptions({
|
||||||
store: {
|
|
||||||
dispatch: store.dispatch,
|
|
||||||
getters: store.getters,
|
|
||||||
},
|
|
||||||
router: {
|
router: {
|
||||||
navigate: jest.fn(),
|
navigate: jest.fn(),
|
||||||
},
|
},
|
||||||
|
actionList: [
|
||||||
|
{
|
||||||
|
actionName: storeActions.LOOKUP_VEHICLE_BY_VIN,
|
||||||
|
data: {}
|
||||||
|
}
|
||||||
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
//Mock props
|
//Mock props
|
||||||
|
|
@ -319,5 +302,8 @@ function setupMocks({}) {
|
||||||
|
|
||||||
const wrapper = shallowMount(addressVehicles, mountOptions);
|
const wrapper = shallowMount(addressVehicles, mountOptions);
|
||||||
|
|
||||||
|
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
||||||
|
wrapper.vm.navigateForwardWithSingleCarMatch = jest.fn();
|
||||||
|
|
||||||
return { wrapper };
|
return { wrapper };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,14 +59,12 @@ import loadingModal from '@/common-components/loading-modal/loading-modal.vue';
|
||||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import baseMixin from "@/mixins/base-mixin.js";
|
|
||||||
import { storeActions } from "@/constants/store-actions";
|
import { storeActions } from "@/constants/store-actions";
|
||||||
import { storeMutations } from "@/constants/store-mutations";
|
import { storeMutations } from "@/constants/store-mutations";
|
||||||
import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
|
import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
|
||||||
import { errorMessages } from "@/constants/error-messages";
|
import { errorMessages } from "@/constants/error-messages";
|
||||||
import { required } from "@/helpers/validation-rules";
|
import { required } from "@/helpers/validation-rules";
|
||||||
import { Form, defineRule } from "vee-validate";
|
import { Form, defineRule } from "vee-validate";
|
||||||
import { navigateAfterSaveToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
|
|
||||||
import { isGlassAvailableForCarId } from "@/helpers/damage-helper";
|
import { isGlassAvailableForCarId } from "@/helpers/damage-helper";
|
||||||
import { doesCopyContainRouterLink,
|
import { doesCopyContainRouterLink,
|
||||||
splitCopyOnCMSPlaceHolder,
|
splitCopyOnCMSPlaceHolder,
|
||||||
|
|
@ -195,17 +193,17 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
lookupVin(vin) {
|
lookupVin(vin) {
|
||||||
return baseMixin.methods.dispatchStoreAction(
|
return this.dispatchStoreAction(
|
||||||
storeActions.LOOKUP_VEHICLE_BY_VIN,
|
storeActions.LOOKUP_VEHICLE_BY_VIN,
|
||||||
{ vin }
|
{ vin }
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
resetDependentState() { // needed because navigateAfterSaveToHeritageFunnel calls it
|
resetDependentState() { // needed because navigateAfterSaveToHeritageFunnel calls it
|
||||||
store.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
|
this.dispatchStoreAction(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
|
||||||
},
|
},
|
||||||
updateCustomerInfo(vin, vehicle) {
|
updateCustomerInfo(vin, vehicle) {
|
||||||
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
|
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
|
||||||
store.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
this.dispatchStoreAction(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
||||||
}
|
}
|
||||||
store.commit(storeMutations.UPDATE_VEHICLE_VIN, vin);
|
store.commit(storeMutations.UPDATE_VEHICLE_VIN, vin);
|
||||||
store.commit(storeMutations.UPDATE_YEAR, vehicle.year);
|
store.commit(storeMutations.UPDATE_YEAR, vehicle.year);
|
||||||
|
|
@ -223,6 +221,8 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
selectedVehicleVin() {
|
selectedVehicleVin() {
|
||||||
// does this vehicle match the previously selected carId?
|
// does this vehicle match the previously selected carId?
|
||||||
|
console.log(this.selectedVehicle)
|
||||||
|
console.log(store.getters.vehicle)
|
||||||
this.isCarIdDifferent = this.selectedVehicle.vehicle.carId !== store.getters.vehicle.carId;
|
this.isCarIdDifferent = this.selectedVehicle.vehicle.carId !== store.getters.vehicle.carId;
|
||||||
this.$refs.funnelFooter.updateButtonText(`Continue with ${this.selectedVehicle.vehicle.year} ${this.selectedVehicle.vehicle.make} ${this.selectedVehicle.vehicle.model}`);
|
this.$refs.funnelFooter.updateButtonText(`Continue with ${this.selectedVehicle.vehicle.year} ${this.selectedVehicle.vehicle.make} ${this.selectedVehicle.vehicle.model}`);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import licensePlateLookup from "@/layouts/license-plate-lookup/license-plate-loo
|
||||||
// Supporting Files
|
// Supporting Files
|
||||||
import { settleAllPromises } from "@/helpers/layout-helper.js";
|
import { settleAllPromises } from "@/helpers/layout-helper.js";
|
||||||
import * as navigateToHeritage from "@/helpers/heritage-integration/navigation-helper";
|
import * as navigateToHeritage from "@/helpers/heritage-integration/navigation-helper";
|
||||||
import baseMixin from "@/mixins/base-mixin";
|
|
||||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
import { shallowMount } from "@vue/test-utils";
|
import { shallowMount } from "@vue/test-utils";
|
||||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||||
|
|
@ -230,13 +229,16 @@ describe("license-plate-lookup.vue", () => {
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
wrapper.vm.isCarIdDifferent = true;
|
await wrapper.setData({
|
||||||
wrapper.vm.isSelectedGlassAvailableForVehicle = false;
|
isCarIdDifferent: true,
|
||||||
|
isSelectedGlassAvailableForVehicle: false
|
||||||
|
})
|
||||||
|
|
||||||
wrapper.vm.$router.navigateAfterSave = jest.fn();
|
wrapper.vm.$router.navigateAfterSave = jest.fn();
|
||||||
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
||||||
return '';
|
return '';
|
||||||
});
|
});
|
||||||
store.dispatch = jest.fn();
|
wrapper.vm.dispatchStoreAction = jest.fn();
|
||||||
|
|
||||||
await wrapper.vm.navigateForward();
|
await wrapper.vm.navigateForward();
|
||||||
|
|
||||||
|
|
@ -250,7 +252,9 @@ describe("license-plate-lookup.vue", () => {
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
wrapper.vm.isCarIdDifferent = false;
|
await wrapper.setData({
|
||||||
|
isCarIdDifferent: false
|
||||||
|
})
|
||||||
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
||||||
return '';
|
return '';
|
||||||
});
|
});
|
||||||
|
|
@ -302,7 +306,9 @@ describe("license-plate-lookup.vue", () => {
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
wrapper.vm.licensePlate = "NEWPLATE";
|
wrapper.setData({
|
||||||
|
licensePlate: "NEWPLATE"
|
||||||
|
})
|
||||||
wrapper.vm.getCmsContent = jest.fn();
|
wrapper.vm.getCmsContent = jest.fn();
|
||||||
await wrapper.vm.$nextTick();
|
await wrapper.vm.$nextTick();
|
||||||
|
|
||||||
|
|
@ -316,7 +322,9 @@ describe("license-plate-lookup.vue", () => {
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
wrapper.vm.registrationZip = "55555";
|
await wrapper.setData({
|
||||||
|
registrationZip: "55555"
|
||||||
|
})
|
||||||
wrapper.vm.getCmsContent = jest.fn();
|
wrapper.vm.getCmsContent = jest.fn();
|
||||||
await wrapper.vm.$nextTick();
|
await wrapper.vm.$nextTick();
|
||||||
|
|
||||||
|
|
@ -330,7 +338,9 @@ describe("license-plate-lookup.vue", () => {
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
wrapper.vm.serviceZip = "55555";
|
await wrapper.setData({
|
||||||
|
serviceZip: "55555"
|
||||||
|
})
|
||||||
wrapper.vm.getCmsContent = jest.fn();
|
wrapper.vm.getCmsContent = jest.fn();
|
||||||
await wrapper.vm.$nextTick();
|
await wrapper.vm.$nextTick();
|
||||||
|
|
||||||
|
|
@ -502,19 +512,20 @@ describe("license-plate-lookup.vue", () => {
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
wrapper.vm.isCarIdDifferent = true;
|
await wrapper.setData({
|
||||||
wrapper.vm.isSelectedGlassAvailableForVehicle = false;
|
isCarIdDifferent: true,
|
||||||
|
isSelectedGlassAvailableForVehicle: false
|
||||||
|
})
|
||||||
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
||||||
return '';
|
return '';
|
||||||
});
|
});
|
||||||
store.commit = jest.fn();
|
store.commit = jest.fn();
|
||||||
store.dispatch = jest.fn();
|
|
||||||
|
|
||||||
const vehicleInfo = { year: "2020", make: "honda", model: "civic", style: "2 door", carId: "TestId", category: "testCat", imageUrl: "image.jpg", imageVifNumber: "123", imageColor: "blue" }
|
const vehicleInfo = { year: "2020", make: "honda", model: "civic", style: "2 door", carId: "TestId", category: "testCat", imageUrl: "image.jpg", imageVifNumber: "123", imageColor: "blue" }
|
||||||
await wrapper.vm.updateCustomerInfo('vin', vehicleInfo, 'registrationState');
|
await wrapper.vm.updateCustomerInfo('vin', vehicleInfo, 'registrationState');
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
expect(store.dispatch).toHaveBeenCalled();
|
expect(wrapper.vm.dispatchStoreAction).toHaveBeenCalled();
|
||||||
})
|
})
|
||||||
|
|
||||||
test("dispatchStoreAction called on validate zip", async () => {
|
test("dispatchStoreAction called on validate zip", async () => {
|
||||||
|
|
@ -527,7 +538,7 @@ describe("license-plate-lookup.vue", () => {
|
||||||
|
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
expect(baseMixin.methods.dispatchStoreAction).toHaveBeenCalled();
|
expect(wrapper.vm.dispatchStoreAction).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("dispatchStoreAction called on lookup vin", async () => {
|
test("dispatchStoreAction called on lookup vin", async () => {
|
||||||
|
|
@ -540,7 +551,7 @@ describe("license-plate-lookup.vue", () => {
|
||||||
|
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
expect(baseMixin.methods.dispatchStoreAction).toHaveBeenCalled();
|
expect(wrapper.vm.dispatchStoreAction).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
@ -552,7 +563,6 @@ function setupMocks({
|
||||||
}) {
|
}) {
|
||||||
store.commit(storeMutations.RESET_STATE);
|
store.commit(storeMutations.RESET_STATE);
|
||||||
//Mock api responses
|
//Mock api responses
|
||||||
baseMixin.methods.dispatchStoreAction = jest.fn();
|
|
||||||
const apiResponses = {
|
const apiResponses = {
|
||||||
cmsContent: {
|
cmsContent: {
|
||||||
FunnelSubHeaderWidget: pageHeaderWidgetHeaderText,
|
FunnelSubHeaderWidget: pageHeaderWidgetHeaderText,
|
||||||
|
|
@ -592,7 +602,7 @@ function setupMocks({
|
||||||
|
|
||||||
const wrapper = shallowMount(licensePlateLookup, mountOptions);
|
const wrapper = shallowMount(licensePlateLookup, mountOptions);
|
||||||
|
|
||||||
wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent;
|
wrapper.vm.setCmsContent = jest.fn();
|
||||||
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => "");
|
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => "");
|
||||||
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
||||||
wrapper.vm.$refs.funnelFooter.removeLoader = jest.fn();
|
wrapper.vm.$refs.funnelFooter.removeLoader = jest.fn();
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,6 @@ import loadingModal from '@/common-components/loading-modal/loading-modal.vue';
|
||||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import baseMixin from "@/mixins/base-mixin.js";
|
|
||||||
import { storeActions } from "@/constants/store-actions";
|
import { storeActions } from "@/constants/store-actions";
|
||||||
import { storeMutations } from "@/constants/store-mutations";
|
import { storeMutations } from "@/constants/store-mutations";
|
||||||
import { errorMessages } from "@/constants/error-messages";
|
import { errorMessages } from "@/constants/error-messages";
|
||||||
|
|
@ -199,7 +198,7 @@ export default {
|
||||||
store.commit(storeMutations.UPDATE_REGISTRATION_CITY, null);
|
store.commit(storeMutations.UPDATE_REGISTRATION_CITY, null);
|
||||||
store.commit(storeMutations.UPDATE_REGISTRATION_FIRST_NAME, null);
|
store.commit(storeMutations.UPDATE_REGISTRATION_FIRST_NAME, null);
|
||||||
store.commit(storeMutations.UPDATE_REGISTRATION_LAST_NAME, null);
|
store.commit(storeMutations.UPDATE_REGISTRATION_LAST_NAME, null);
|
||||||
store.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
|
this.dispatchStoreAction(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
|
||||||
},
|
},
|
||||||
attachCustomEvents() {
|
attachCustomEvents() {
|
||||||
this.prependActionToMethod(this, this.forwardButtonAction, () => {
|
this.prependActionToMethod(this, this.forwardButtonAction, () => {
|
||||||
|
|
@ -303,16 +302,16 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
validateZip(zip) {
|
validateZip(zip) {
|
||||||
return baseMixin.methods.dispatchStoreAction(storeActions.VALIDATE_ZIP, {
|
return this.dispatchStoreAction(storeActions.VALIDATE_ZIP, {
|
||||||
zip,
|
zip,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
lookupVin(plate, state) {
|
lookupVin(plate, state) {
|
||||||
return baseMixin.methods.dispatchStoreAction(storeActions.LOOKUP_VIN_BY_PLATE,{ licensePlate: plate, licenseState: state }, false);
|
return this.dispatchStoreAction(storeActions.LOOKUP_VIN_BY_PLATE,{ licensePlate: plate, licenseState: state }, false);
|
||||||
},
|
},
|
||||||
updateCustomerInfo(vin, vehicleInfo, registrationState, serviceState) {
|
updateCustomerInfo(vin, vehicleInfo, registrationState, serviceState) {
|
||||||
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
|
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
|
||||||
store.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
this.dispatchStoreAction(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
||||||
}
|
}
|
||||||
store.commit(storeMutations.UPDATE_VEHICLE_VIN, vin);
|
store.commit(storeMutations.UPDATE_VEHICLE_VIN, vin);
|
||||||
store.commit(storeMutations.UPDATE_YEAR, vehicleInfo.year);
|
store.commit(storeMutations.UPDATE_YEAR, vehicleInfo.year);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue