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 { createTestingPinia } from '@pinia/testing';
|
||||
import { useMainStore } from '@/store';
|
||||
import { getRandomString } from '@/helpers/data-generation';
|
||||
|
||||
function getMountedComponent(mainInitialState = {}) {
|
||||
const mountOptions = getMountOptions({
|
||||
|
|
@ -63,6 +64,22 @@ describe('policyEndorsements.vue', () => {
|
|||
expect(wrapper.vm.educatorEndorsement).toBeTruthy();
|
||||
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', () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
|
|
@ -79,6 +96,22 @@ describe('policyEndorsements.vue', () => {
|
|||
expect(wrapper.vm.parkingGuardEndorsement).toBeTruthy();
|
||||
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', () => {
|
||||
// Arrange
|
||||
const wrapper = shallowMount(policyEndorsements, getMountOptions());
|
||||
|
|
|
|||
|
|
@ -120,10 +120,10 @@ export default {
|
|||
return this.getCmsContent('ParkingLotQuestion', 'Answers');
|
||||
},
|
||||
educatorEndorsement() {
|
||||
return useMainStore().order.policy.endorsements.includes('Educator');
|
||||
return useMainStore().order.policy.endorsements?.includes('Educator');
|
||||
},
|
||||
parkingGuardEndorsement() {
|
||||
return useMainStore().order.policy.endorsements.includes('Parking Guard');
|
||||
return useMainStore().order.policy.endorsements?.includes('Parking Guard');
|
||||
}
|
||||
},
|
||||
methods:
|
||||
|
|
|
|||
|
|
@ -152,8 +152,7 @@ describe('policy-vehicles.vue', () => {
|
|||
vin,
|
||||
endorsements
|
||||
}
|
||||
],
|
||||
bailout: false
|
||||
]
|
||||
});
|
||||
|
||||
const year = getRandomInt(1998, 2023);
|
||||
|
|
@ -178,7 +177,6 @@ describe('policy-vehicles.vue', () => {
|
|||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.bailout).toBeFalsy();
|
||||
expect(store.updateVehicle).toHaveBeenCalledWith(expectedInput);
|
||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
|
||||
navigationScenarios.CLICKED_FORWARD_WITH_ENDORSEMENTS,
|
||||
|
|
|
|||
|
|
@ -153,10 +153,12 @@ describe('Store', () => {
|
|||
// Arrange
|
||||
const noCoverage = getRandomBoolean();
|
||||
const deductible = getRandomInt(1, 500);
|
||||
const endorsements = [getRandomString(10, 20)];
|
||||
const vehicle = {
|
||||
noCoverage,
|
||||
deductible,
|
||||
repairWaived: true
|
||||
repairWaived: true,
|
||||
endorsements
|
||||
};
|
||||
|
||||
const expectedPolicy = {
|
||||
|
|
@ -164,7 +166,8 @@ describe('Store', () => {
|
|||
deductible: {
|
||||
replace: deductible,
|
||||
repair: 0
|
||||
}
|
||||
},
|
||||
endorsements
|
||||
};
|
||||
|
||||
// Act
|
||||
|
|
@ -178,10 +181,12 @@ describe('Store', () => {
|
|||
// Arrange
|
||||
const noCoverage = getRandomBoolean();
|
||||
const deductible = getRandomInt(1, 500);
|
||||
const endorsements = [getRandomString(10, 20)];
|
||||
const vehicle = {
|
||||
noCoverage,
|
||||
deductible,
|
||||
repairWaived: false
|
||||
repairWaived: false,
|
||||
endorsements
|
||||
};
|
||||
|
||||
const expectedPolicy = {
|
||||
|
|
@ -189,7 +194,8 @@ describe('Store', () => {
|
|||
deductible: {
|
||||
replace: deductible,
|
||||
repair: deductible
|
||||
}
|
||||
},
|
||||
endorsements
|
||||
};
|
||||
|
||||
// Act
|
||||
|
|
|
|||
Loading…
Reference in a new issue