unit test updates - test computed properties
This commit is contained in:
parent
0b6607177d
commit
d67b979de1
1 changed files with 37 additions and 8 deletions
|
|
@ -8,6 +8,23 @@ 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';
|
||||||
|
|
||||||
|
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('policyEndorsements.vue', () => {
|
||||||
describe('Rendering', () => {
|
describe('Rendering', () => {
|
||||||
test('Should render site header', () => {
|
test('Should render site header', () => {
|
||||||
|
|
@ -30,24 +47,36 @@ describe('policyEndorsements.vue', () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(siteSubHeader.exists()).toBe(true);
|
expect(siteSubHeader.exists()).toBe(true);
|
||||||
});
|
});
|
||||||
test('Should render schoolProperty buttonQuestion component', () => {
|
test('Should render schoolProperty buttonQuestion component if policy vehicle has Educator endorsement', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const wrapper = shallowMount(policyEndorsements, getMountOptions());
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
// Act
|
policy: {
|
||||||
|
endorsements: ['Educator']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
const buttonQuestion = wrapper.findComponent({ ref: 'schoolPropertyQuestion' });
|
const buttonQuestion = wrapper.findComponent({ ref: 'schoolPropertyQuestion' });
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
expect(wrapper.vm.educatorEndorsement).toBeTruthy();
|
||||||
expect(buttonQuestion.exists()).toBe(true);
|
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
|
// Arrange
|
||||||
const wrapper = shallowMount(policyEndorsements, getMountOptions());
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
// Act
|
policy: {
|
||||||
|
endorsements: ['Parking Guard']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
const buttonQuestion = wrapper.findComponent({ ref: 'parkingLotQuestion' });
|
const buttonQuestion = wrapper.findComponent({ ref: 'parkingLotQuestion' });
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
expect(wrapper.vm.parkingGuardEndorsement).toBeTruthy();
|
||||||
expect(buttonQuestion.exists()).toBe(true);
|
expect(buttonQuestion.exists()).toBe(true);
|
||||||
});
|
});
|
||||||
test('Should render site footer', () => {
|
test('Should render site footer', () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue