unit tests

This commit is contained in:
Katie Kroell 2023-07-27 16:22:25 -04:00
parent 7d21d3b697
commit 8448ae3da2

View file

@ -2,7 +2,7 @@
import coverageStatement from '@/layouts/coverage-statement/coverage-statement';
// Supporting Files
import { shallowMount } from '@vue/test-utils';
import { mount, shallowMount } from '@vue/test-utils';
import { getMountOptions } from '@/helpers/unit-test-helper.js';
import { createTestingPinia } from '@pinia/testing';
import { navigationScenarios } from '@/router/router-constants/navigation-scenarios.js';
@ -513,7 +513,19 @@ describe('coverageStatement.vue', () => {
describe('Navigation', () => {
test('If Unverified, navigate forward with CLICKED_FORWARD scenario', () => {
// Arrange
const mountOptions = getMountOptions();
const footer = {
render: () => {},
methods: {
updateButtonText: jest.fn()
}
}
const mountOptions = {
router: {
navigate: jest.fn()
},
mixins: [mockMixin]
};
const mainInitialState = {
order: {
damage: {
@ -526,15 +538,23 @@ describe('coverageStatement.vue', () => {
initialState: {
main: mainInitialState
}
})]
})],
stubs: {
'siteFooter': footer,
siteHeader: true,
recalModal: true,
contentGroupModal: true,
alert: true,
},
mocks: {
$router: {
navigate: jest.fn()
}
}
}
// Act
const wrapper = shallowMount(coverageStatement, getMountOptions({
router: {
navigate: jest.fn()
},
}));
const wrapper = mount(coverageStatement, mountOptions);
wrapper.setData({
isVerified: false,
})
@ -548,7 +568,20 @@ describe('coverageStatement.vue', () => {
});
test('If Verified Deductible, navigate forward with CLICKED_FORWARD scenario', () => {
// Arrange
const mountOptions = getMountOptions();
const footer = {
render: () => {},
methods: {
updateButtonText: jest.fn()
}
}
const mountOptions = {
router: {
navigate: jest.fn()
},
mixins: [mockMixin]
};
const sellingPrice = getRandomInt(100, 500);
const deductible = sellingPrice - 1;
const mainInitialState = {
@ -569,14 +602,22 @@ describe('coverageStatement.vue', () => {
initialState: {
main: mainInitialState
}
})]
})],
stubs: {
'siteFooter': footer,
siteHeader: true,
recalModal: true,
contentGroupModal: true,
alert: true,
},
mocks: {
$router: {
navigate: jest.fn()
}
}
}
const wrapper = shallowMount(coverageStatement, getMountOptions({
router: {
navigate: jest.fn()
},
}));
const wrapper = mount(coverageStatement, mountOptions);
wrapper.setData({
isVerified: true,
availableLineItems: [
@ -592,13 +633,24 @@ describe('coverageStatement.vue', () => {
wrapper.vm.forwardButtonAction();
// Assert
//expect(wrapper.vm.verifiedDeductible).toBeTruthy();
expect(wrapper.vm.$router.navigate)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD, undefined);
});
test('If Verified ITAC and selected Safelite, navigate forward with CLICKED_FORWARD_WITH_SAFELITE scenario', () => {
// Arrange
const mountOptions = getMountOptions();
const footer = {
render: () => {},
methods: {
updateButtonText: jest.fn()
}
}
const mountOptions = {
router: {
navigate: jest.fn()
},
mixins: [mockMixin]
};
const sellingPrice = getRandomInt(100, 500);
const deductible = sellingPrice + 1;
const mainInitialState = {
@ -613,20 +665,29 @@ describe('coverageStatement.vue', () => {
}
}
},
};
mountOptions.global = {
plugins: [createTestingPinia({
initialState: {
main: mainInitialState
}
})]
})],
stubs: {
'siteFooter': footer,
siteHeader: true,
recalModal: true,
contentGroupModal: true,
alert: true,
},
mocks: {
$router: {
navigate: jest.fn()
}
}
}
const wrapper = shallowMount(coverageStatement, getMountOptions({
router: {
navigate: jest.fn()
},
}));
const wrapper = mount(coverageStatement, mountOptions);
wrapper.setData({
isVerified: true,
availableLineItems: [
@ -638,34 +699,40 @@ describe('coverageStatement.vue', () => {
],
selectedProvider: 'Safelite'
});
wrapper.vm.$refs.siteFooter.updateButtonText = jest.fn();
useMainStore().order.policy.noCoverage = false;
// Act
wrapper.vm.forwardButtonAction();
// Assert
console.log(wrapper.vm.coverageVerified);
console.log(wrapper.vm.verifiedNoComp);
console.log(wrapper.vm.vehicleDeductible);
console.log(sellingPrice);
console.log(wrapper.vm.verifiedITAC);
//expect(wrapper.vm.verifiedITAC).toBeTruthy();
// expect(wrapper.vm.$router.navigate)
// .toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE, undefined);
expect(wrapper.vm.$router.navigate)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE, undefined);
});
test('If Verified ITAC, selected other shop, and TPA enabled, navigate forward with CLICKED_FORWARD_WITH_TPA_ENABLED scenario', () => {
// Arrange
const mountOptions = getMountOptions();
const footer = {
render: () => {},
methods: {
updateButtonText: jest.fn()
}
}
const mountOptions = {
router: {
navigate: jest.fn()
},
mixins: [mockMixin]
};
const sellingPrice = getRandomInt(100, 500);
const deductible = sellingPrice + 100;
const deductible = sellingPrice + 1;
const mainInitialState = {
order: {
damage: {
isRepair: true
},
policy: {
//noCoverage: false,
noCoverage: false,
deductible: {
repair: deductible,
}
@ -680,14 +747,22 @@ describe('coverageStatement.vue', () => {
initialState: {
main: mainInitialState
}
})]
})],
stubs: {
'siteFooter': footer,
siteHeader: true,
recalModal: true,
contentGroupModal: true,
alert: true,
},
mocks: {
$router: {
navigate: jest.fn()
}
}
}
const wrapper = shallowMount(coverageStatement, getMountOptions({
router: {
navigate: jest.fn()
},
}));
const wrapper = mount(coverageStatement, mountOptions);
wrapper.setData({
isVerified: true,
availableLineItems: [
@ -699,18 +774,194 @@ describe('coverageStatement.vue', () => {
],
selectedProvider: 'Other'
});
wrapper.vm.$refs.siteFooter.updateButtonText = jest.fn();
useMainStore().order.policy.noCoverage = false;
// Act
wrapper.vm.forwardButtonAction();
// Assert
expect(wrapper.vm.verifiedITAC).toBeTruthy();
// expect(wrapper.vm.$router.navigate)
// .toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE, undefined);
//expect(wrapper.vm.verifiedITAC).toBeTruthy();
expect(wrapper.vm.$router.navigate)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_TPA_ENABLED, undefined);
});
test('If Verified ITAC, selected other shop, and TPA disabled, navigate forward with CLICKED_FORWARD_WITH_TPA_DISABLED scenario', () => {
// Arrange
const footer = {
render: () => {},
methods: {
updateButtonText: jest.fn()
}
}
const mountOptions = {
router: {
navigate: jest.fn()
},
mixins: [mockMixin]
};
const sellingPrice = getRandomInt(100, 500);
const deductible = sellingPrice + 1;
const mainInitialState = {
order: {
damage: {
isRepair: true
},
policy: {
noCoverage: false,
deductible: {
repair: deductible,
}
}
},
issConfig: {
enableTPAFlow: false
}
};
mountOptions.global = {
plugins: [createTestingPinia({
initialState: {
main: mainInitialState
}
})],
stubs: {
'siteFooter': footer,
siteHeader: true,
recalModal: true,
contentGroupModal: true,
alert: true,
},
mocks: {
$router: {
navigate: jest.fn()
}
}
}
const wrapper = mount(coverageStatement, mountOptions);
wrapper.setData({
isVerified: true,
availableLineItems: [
{
sellingPrice: sellingPrice,
kitPrice: 0,
laborAmount: 0,
}
],
selectedProvider: 'Other'
});
// Act
wrapper.vm.forwardButtonAction();
// Assert
//expect(wrapper.vm.verifiedITAC).toBeTruthy();
expect(wrapper.vm.$router.navigate)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_TPA_DISABLED, undefined);
});
test('If No Comp and selected Safelite, navigate forward with CLICKED_FORWARD scenario', () => {
// Arrange
const footer = {
render: () => {},
methods: {
updateButtonText: jest.fn()
}
}
const mountOptions = {
router: {
navigate: jest.fn()
},
mixins: [mockMixin]
};
const sellingPrice = getRandomInt(100, 500);
const deductible = sellingPrice - 1;
const mainInitialState = {
order: {
damage: {
isRepair: true
},
policy: {
noCoverage: true,
}
}
};
mountOptions.global = {
plugins: [createTestingPinia({
initialState: {
main: mainInitialState
}
})],
stubs: {
'siteFooter': footer,
siteHeader: true,
recalModal: true,
contentGroupModal: true,
alert: true,
},
mocks: {
$router: {
navigate: jest.fn()
}
}
}
const wrapper = mount(coverageStatement, mountOptions);
wrapper.setData({
isVerified: false,
selectedProvider: 'Safelite'
});
// Act
wrapper.vm.forwardButtonAction();
// Assert
//expect(wrapper.vm.verifiedNoComp).toBeTruthy();
expect(wrapper.vm.$router.navigate)
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE, undefined);
});
});
// describe("claim registration api call", () => {
// it.only("claim registration not required => method not called", async () => {
// // Arrange
// const wrapper = setupMocks({});
// const store = useMainStore();
// store.isClaimRegistrationRequired = false;
// const to = {
// query: { issPage: getRandomString(4,10) }
// };
// const next = jest.fn();
// // SUT
// coverageStatement.beforeRouteEnter.call(wrapper.vm, to, undefined, next)
// // Assert
// expect(store.registerClaim).not.toHaveBeenCalled();
// });
// it("claim registration required => register claim method called", async () => {
// // Arrange
// const wrapper = setupMocks({});
// const store = useMainStore();
// store.isClaimRegistrationRequired = true;
// const to = {
// query: { issPage: getRandomString(4,10) }
// };
// const next = jest.fn();
// // SUT
// coverageStatement.beforeRouteEnter.call(wrapper.vm, to, undefined, next)
// // Assert
// expect(store.registerClaim).toHaveBeenCalled();
// });
// })
})