diff --git a/src/layouts/policy-endorsements/policy-endorsements.spec.js b/src/layouts/policy-endorsements/policy-endorsements.spec.js index 86b8fa73..41202415 100644 --- a/src/layouts/policy-endorsements/policy-endorsements.spec.js +++ b/src/layouts/policy-endorsements/policy-endorsements.spec.js @@ -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', () => {