unit test updates - test computed properties

This commit is contained in:
Katie Kroell 2023-10-12 13:27:28 -04:00
parent 0b6607177d
commit d67b979de1

View file

@ -8,6 +8,23 @@ import navigationScenarios from '@/router/router-constants/navigation-scenarios'
import { createTestingPinia } from '@pinia/testing';
import { useMainStore } from '@/store';
function getMountedComponent(mainInitialState = {}, initialData = {}) {
const mountOptions = getMountOptions({
router: {
navigate: jest.fn()
}
});
mountOptions.global.plugins = [createTestingPinia({
initialState: {
main: mainInitialState
}
})];
const wrapper = shallowMount(policyEndorsements, mountOptions);
return { wrapper };
}
describe('policyEndorsements.vue', () => {
describe('Rendering', () => {
test('Should render site header', () => {
@ -30,24 +47,36 @@ describe('policyEndorsements.vue', () => {
// Assert
expect(siteSubHeader.exists()).toBe(true);
});
test('Should render schoolProperty buttonQuestion component', () => {
test('Should render schoolProperty buttonQuestion component if policy vehicle has Educator endorsement', () => {
// Arrange
const wrapper = shallowMount(policyEndorsements, getMountOptions());
// Act
const mainInitialState = {
order: {
policy: {
endorsements: ['Educator']
}
}
};
const { wrapper } = getMountedComponent(mainInitialState);
const buttonQuestion = wrapper.findComponent({ ref: 'schoolPropertyQuestion' });
// Assert
expect(wrapper.vm.educatorEndorsement).toBeTruthy();
expect(buttonQuestion.exists()).toBe(true);
});
test('Should render parkingLot buttonQuestion component', () => {
test('Should render parkingLot buttonQuestion component if policy vehicle has Parking Guard endorsement', () => {
// Arrange
const wrapper = shallowMount(policyEndorsements, getMountOptions());
// Act
const mainInitialState = {
order: {
policy: {
endorsements: ['Parking Guard']
}
}
};
const { wrapper } = getMountedComponent(mainInitialState);
const buttonQuestion = wrapper.findComponent({ ref: 'parkingLotQuestion' });
// Assert
expect(wrapper.vm.parkingGuardEndorsement).toBeTruthy();
expect(buttonQuestion.exists()).toBe(true);
});
test('Should render site footer', () => {