PR changes
This commit is contained in:
parent
54c760830f
commit
20a9af13ba
4 changed files with 46 additions and 9 deletions
|
|
@ -7,6 +7,7 @@ import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||||
import navigationScenarios from '@/router/router-constants/navigation-scenarios';
|
import navigationScenarios from '@/router/router-constants/navigation-scenarios';
|
||||||
import { createTestingPinia } from '@pinia/testing';
|
import { createTestingPinia } from '@pinia/testing';
|
||||||
import { useMainStore } from '@/store';
|
import { useMainStore } from '@/store';
|
||||||
|
import { getRandomString } from '@/helpers/data-generation';
|
||||||
|
|
||||||
function getMountedComponent(mainInitialState = {}) {
|
function getMountedComponent(mainInitialState = {}) {
|
||||||
const mountOptions = getMountOptions({
|
const mountOptions = getMountOptions({
|
||||||
|
|
@ -63,6 +64,22 @@ describe('policyEndorsements.vue', () => {
|
||||||
expect(wrapper.vm.educatorEndorsement).toBeTruthy();
|
expect(wrapper.vm.educatorEndorsement).toBeTruthy();
|
||||||
expect(buttonQuestion.exists()).toBe(true);
|
expect(buttonQuestion.exists()).toBe(true);
|
||||||
});
|
});
|
||||||
|
test('Should not render schoolProperty buttonQuestion component if policy vehicle does not have Educator endorsement', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
policy: {
|
||||||
|
endorsements: [getRandomString(20, 30)]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
const buttonQuestion = wrapper.findComponent({ ref: 'schoolPropertyQuestion' });
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.educatorEndorsement).toBeFalsy();
|
||||||
|
expect(buttonQuestion.exists()).toBe(false);
|
||||||
|
});
|
||||||
test('Should render parkingLot buttonQuestion component if policy vehicle has Parking Guard endorsement', () => {
|
test('Should render parkingLot buttonQuestion component if policy vehicle has Parking Guard endorsement', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mainInitialState = {
|
const mainInitialState = {
|
||||||
|
|
@ -79,6 +96,22 @@ describe('policyEndorsements.vue', () => {
|
||||||
expect(wrapper.vm.parkingGuardEndorsement).toBeTruthy();
|
expect(wrapper.vm.parkingGuardEndorsement).toBeTruthy();
|
||||||
expect(buttonQuestion.exists()).toBe(true);
|
expect(buttonQuestion.exists()).toBe(true);
|
||||||
});
|
});
|
||||||
|
test('Should not render parkingLot buttonQuestion component if policy vehicle does not have Parking Guard endorsement', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
policy: {
|
||||||
|
endorsements: [getRandomString(20, 30)]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
const buttonQuestion = wrapper.findComponent({ ref: 'parkingLotQuestion' });
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.parkingGuardEndorsement).toBeFalsy();
|
||||||
|
expect(buttonQuestion.exists()).toBe(false);
|
||||||
|
});
|
||||||
test('Should render site footer', () => {
|
test('Should render site footer', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const wrapper = shallowMount(policyEndorsements, getMountOptions());
|
const wrapper = shallowMount(policyEndorsements, getMountOptions());
|
||||||
|
|
|
||||||
|
|
@ -120,10 +120,10 @@ export default {
|
||||||
return this.getCmsContent('ParkingLotQuestion', 'Answers');
|
return this.getCmsContent('ParkingLotQuestion', 'Answers');
|
||||||
},
|
},
|
||||||
educatorEndorsement() {
|
educatorEndorsement() {
|
||||||
return useMainStore().order.policy.endorsements.includes('Educator');
|
return useMainStore().order.policy.endorsements?.includes('Educator');
|
||||||
},
|
},
|
||||||
parkingGuardEndorsement() {
|
parkingGuardEndorsement() {
|
||||||
return useMainStore().order.policy.endorsements.includes('Parking Guard');
|
return useMainStore().order.policy.endorsements?.includes('Parking Guard');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods:
|
methods:
|
||||||
|
|
|
||||||
|
|
@ -152,8 +152,7 @@ describe('policy-vehicles.vue', () => {
|
||||||
vin,
|
vin,
|
||||||
endorsements
|
endorsements
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
bailout: false
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const year = getRandomInt(1998, 2023);
|
const year = getRandomInt(1998, 2023);
|
||||||
|
|
@ -178,7 +177,6 @@ describe('policy-vehicles.vue', () => {
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.bailout).toBeFalsy();
|
|
||||||
expect(store.updateVehicle).toHaveBeenCalledWith(expectedInput);
|
expect(store.updateVehicle).toHaveBeenCalledWith(expectedInput);
|
||||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
|
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
|
||||||
navigationScenarios.CLICKED_FORWARD_WITH_ENDORSEMENTS,
|
navigationScenarios.CLICKED_FORWARD_WITH_ENDORSEMENTS,
|
||||||
|
|
|
||||||
|
|
@ -153,10 +153,12 @@ describe('Store', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const noCoverage = getRandomBoolean();
|
const noCoverage = getRandomBoolean();
|
||||||
const deductible = getRandomInt(1, 500);
|
const deductible = getRandomInt(1, 500);
|
||||||
|
const endorsements = [getRandomString(10, 20)];
|
||||||
const vehicle = {
|
const vehicle = {
|
||||||
noCoverage,
|
noCoverage,
|
||||||
deductible,
|
deductible,
|
||||||
repairWaived: true
|
repairWaived: true,
|
||||||
|
endorsements
|
||||||
};
|
};
|
||||||
|
|
||||||
const expectedPolicy = {
|
const expectedPolicy = {
|
||||||
|
|
@ -164,7 +166,8 @@ describe('Store', () => {
|
||||||
deductible: {
|
deductible: {
|
||||||
replace: deductible,
|
replace: deductible,
|
||||||
repair: 0
|
repair: 0
|
||||||
}
|
},
|
||||||
|
endorsements
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -178,10 +181,12 @@ describe('Store', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const noCoverage = getRandomBoolean();
|
const noCoverage = getRandomBoolean();
|
||||||
const deductible = getRandomInt(1, 500);
|
const deductible = getRandomInt(1, 500);
|
||||||
|
const endorsements = [getRandomString(10, 20)];
|
||||||
const vehicle = {
|
const vehicle = {
|
||||||
noCoverage,
|
noCoverage,
|
||||||
deductible,
|
deductible,
|
||||||
repairWaived: false
|
repairWaived: false,
|
||||||
|
endorsements
|
||||||
};
|
};
|
||||||
|
|
||||||
const expectedPolicy = {
|
const expectedPolicy = {
|
||||||
|
|
@ -189,7 +194,8 @@ describe('Store', () => {
|
||||||
deductible: {
|
deductible: {
|
||||||
replace: deductible,
|
replace: deductible,
|
||||||
repair: deductible
|
repair: deductible
|
||||||
}
|
},
|
||||||
|
endorsements
|
||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue