unit tests
This commit is contained in:
parent
7d21d3b697
commit
8448ae3da2
1 changed files with 297 additions and 46 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
import coverageStatement from '@/layouts/coverage-statement/coverage-statement';
|
import coverageStatement from '@/layouts/coverage-statement/coverage-statement';
|
||||||
|
|
||||||
// Supporting Files
|
// Supporting Files
|
||||||
import { shallowMount } from '@vue/test-utils';
|
import { mount, shallowMount } from '@vue/test-utils';
|
||||||
import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||||
import { createTestingPinia } from '@pinia/testing';
|
import { createTestingPinia } from '@pinia/testing';
|
||||||
import { navigationScenarios } from '@/router/router-constants/navigation-scenarios.js';
|
import { navigationScenarios } from '@/router/router-constants/navigation-scenarios.js';
|
||||||
|
|
@ -513,7 +513,19 @@ describe('coverageStatement.vue', () => {
|
||||||
describe('Navigation', () => {
|
describe('Navigation', () => {
|
||||||
test('If Unverified, navigate forward with CLICKED_FORWARD scenario', () => {
|
test('If Unverified, navigate forward with CLICKED_FORWARD scenario', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions();
|
const footer = {
|
||||||
|
render: () => {},
|
||||||
|
methods: {
|
||||||
|
updateButtonText: jest.fn()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const mountOptions = {
|
||||||
|
router: {
|
||||||
|
navigate: jest.fn()
|
||||||
|
},
|
||||||
|
mixins: [mockMixin]
|
||||||
|
};
|
||||||
const mainInitialState = {
|
const mainInitialState = {
|
||||||
order: {
|
order: {
|
||||||
damage: {
|
damage: {
|
||||||
|
|
@ -526,15 +538,23 @@ describe('coverageStatement.vue', () => {
|
||||||
initialState: {
|
initialState: {
|
||||||
main: mainInitialState
|
main: mainInitialState
|
||||||
}
|
}
|
||||||
})]
|
})],
|
||||||
|
stubs: {
|
||||||
|
'siteFooter': footer,
|
||||||
|
siteHeader: true,
|
||||||
|
recalModal: true,
|
||||||
|
contentGroupModal: true,
|
||||||
|
alert: true,
|
||||||
|
},
|
||||||
|
mocks: {
|
||||||
|
$router: {
|
||||||
|
navigate: jest.fn()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const wrapper = shallowMount(coverageStatement, getMountOptions({
|
const wrapper = mount(coverageStatement, mountOptions);
|
||||||
router: {
|
|
||||||
navigate: jest.fn()
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
wrapper.setData({
|
wrapper.setData({
|
||||||
isVerified: false,
|
isVerified: false,
|
||||||
})
|
})
|
||||||
|
|
@ -548,7 +568,20 @@ describe('coverageStatement.vue', () => {
|
||||||
});
|
});
|
||||||
test('If Verified Deductible, navigate forward with CLICKED_FORWARD scenario', () => {
|
test('If Verified Deductible, navigate forward with CLICKED_FORWARD scenario', () => {
|
||||||
// Arrange
|
// 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 sellingPrice = getRandomInt(100, 500);
|
||||||
const deductible = sellingPrice - 1;
|
const deductible = sellingPrice - 1;
|
||||||
const mainInitialState = {
|
const mainInitialState = {
|
||||||
|
|
@ -569,14 +602,22 @@ describe('coverageStatement.vue', () => {
|
||||||
initialState: {
|
initialState: {
|
||||||
main: mainInitialState
|
main: mainInitialState
|
||||||
}
|
}
|
||||||
})]
|
})],
|
||||||
|
stubs: {
|
||||||
|
'siteFooter': footer,
|
||||||
|
siteHeader: true,
|
||||||
|
recalModal: true,
|
||||||
|
contentGroupModal: true,
|
||||||
|
alert: true,
|
||||||
|
},
|
||||||
|
mocks: {
|
||||||
|
$router: {
|
||||||
|
navigate: jest.fn()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const wrapper = shallowMount(coverageStatement, getMountOptions({
|
const wrapper = mount(coverageStatement, mountOptions);
|
||||||
router: {
|
|
||||||
navigate: jest.fn()
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
wrapper.setData({
|
wrapper.setData({
|
||||||
isVerified: true,
|
isVerified: true,
|
||||||
availableLineItems: [
|
availableLineItems: [
|
||||||
|
|
@ -592,13 +633,24 @@ describe('coverageStatement.vue', () => {
|
||||||
wrapper.vm.forwardButtonAction();
|
wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
//expect(wrapper.vm.verifiedDeductible).toBeTruthy();
|
|
||||||
expect(wrapper.vm.$router.navigate)
|
expect(wrapper.vm.$router.navigate)
|
||||||
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD, undefined);
|
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD, undefined);
|
||||||
});
|
});
|
||||||
test('If Verified ITAC and selected Safelite, navigate forward with CLICKED_FORWARD_WITH_SAFELITE scenario', () => {
|
test('If Verified ITAC and selected Safelite, navigate forward with CLICKED_FORWARD_WITH_SAFELITE scenario', () => {
|
||||||
// Arrange
|
// 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 sellingPrice = getRandomInt(100, 500);
|
||||||
const deductible = sellingPrice + 1;
|
const deductible = sellingPrice + 1;
|
||||||
const mainInitialState = {
|
const mainInitialState = {
|
||||||
|
|
@ -613,20 +665,29 @@ describe('coverageStatement.vue', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
mountOptions.global = {
|
mountOptions.global = {
|
||||||
plugins: [createTestingPinia({
|
plugins: [createTestingPinia({
|
||||||
initialState: {
|
initialState: {
|
||||||
main: mainInitialState
|
main: mainInitialState
|
||||||
}
|
}
|
||||||
})]
|
})],
|
||||||
|
stubs: {
|
||||||
|
'siteFooter': footer,
|
||||||
|
siteHeader: true,
|
||||||
|
recalModal: true,
|
||||||
|
contentGroupModal: true,
|
||||||
|
alert: true,
|
||||||
|
},
|
||||||
|
mocks: {
|
||||||
|
$router: {
|
||||||
|
navigate: jest.fn()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const wrapper = shallowMount(coverageStatement, getMountOptions({
|
const wrapper = mount(coverageStatement, mountOptions);
|
||||||
router: {
|
|
||||||
navigate: jest.fn()
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
wrapper.setData({
|
wrapper.setData({
|
||||||
isVerified: true,
|
isVerified: true,
|
||||||
availableLineItems: [
|
availableLineItems: [
|
||||||
|
|
@ -638,34 +699,40 @@ describe('coverageStatement.vue', () => {
|
||||||
],
|
],
|
||||||
selectedProvider: 'Safelite'
|
selectedProvider: 'Safelite'
|
||||||
});
|
});
|
||||||
wrapper.vm.$refs.siteFooter.updateButtonText = jest.fn();
|
|
||||||
useMainStore().order.policy.noCoverage = false;
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
wrapper.vm.forwardButtonAction();
|
wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
// Assert
|
// 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.verifiedITAC).toBeTruthy();
|
||||||
// expect(wrapper.vm.$router.navigate)
|
expect(wrapper.vm.$router.navigate)
|
||||||
// .toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE, undefined);
|
.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', () => {
|
test('If Verified ITAC, selected other shop, and TPA enabled, navigate forward with CLICKED_FORWARD_WITH_TPA_ENABLED scenario', () => {
|
||||||
// Arrange
|
// 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 sellingPrice = getRandomInt(100, 500);
|
||||||
const deductible = sellingPrice + 100;
|
const deductible = sellingPrice + 1;
|
||||||
const mainInitialState = {
|
const mainInitialState = {
|
||||||
order: {
|
order: {
|
||||||
damage: {
|
damage: {
|
||||||
isRepair: true
|
isRepair: true
|
||||||
},
|
},
|
||||||
policy: {
|
policy: {
|
||||||
//noCoverage: false,
|
noCoverage: false,
|
||||||
deductible: {
|
deductible: {
|
||||||
repair: deductible,
|
repair: deductible,
|
||||||
}
|
}
|
||||||
|
|
@ -680,14 +747,22 @@ describe('coverageStatement.vue', () => {
|
||||||
initialState: {
|
initialState: {
|
||||||
main: mainInitialState
|
main: mainInitialState
|
||||||
}
|
}
|
||||||
})]
|
})],
|
||||||
|
stubs: {
|
||||||
|
'siteFooter': footer,
|
||||||
|
siteHeader: true,
|
||||||
|
recalModal: true,
|
||||||
|
contentGroupModal: true,
|
||||||
|
alert: true,
|
||||||
|
},
|
||||||
|
mocks: {
|
||||||
|
$router: {
|
||||||
|
navigate: jest.fn()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const wrapper = shallowMount(coverageStatement, getMountOptions({
|
const wrapper = mount(coverageStatement, mountOptions);
|
||||||
router: {
|
|
||||||
navigate: jest.fn()
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
wrapper.setData({
|
wrapper.setData({
|
||||||
isVerified: true,
|
isVerified: true,
|
||||||
availableLineItems: [
|
availableLineItems: [
|
||||||
|
|
@ -699,18 +774,194 @@ describe('coverageStatement.vue', () => {
|
||||||
],
|
],
|
||||||
selectedProvider: 'Other'
|
selectedProvider: 'Other'
|
||||||
});
|
});
|
||||||
wrapper.vm.$refs.siteFooter.updateButtonText = jest.fn();
|
|
||||||
useMainStore().order.policy.noCoverage = false;
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
wrapper.vm.forwardButtonAction();
|
wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.verifiedITAC).toBeTruthy();
|
//expect(wrapper.vm.verifiedITAC).toBeTruthy();
|
||||||
// expect(wrapper.vm.$router.navigate)
|
expect(wrapper.vm.$router.navigate)
|
||||||
// .toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE, undefined);
|
.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();
|
||||||
|
// });
|
||||||
|
// })
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue