navigation unit tests
This commit is contained in:
parent
187cf5243c
commit
022a879adb
1 changed files with 226 additions and 20 deletions
|
|
@ -7,11 +7,7 @@ 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';
|
||||||
import { useMainStore } from '@/store/index.js';
|
import { useMainStore } from '@/store/index.js';
|
||||||
import { settleAllPromises } from '@/helpers/layout-helper';
|
import { getRandomString, getRandomInt } from '@/helpers/data-generation.js';
|
||||||
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
|
||||||
import { render } from '@testing-library/vue';
|
|
||||||
import { getRandomString, getRandomInt, getRandomBoolean } from '@/helpers/data-generation.js';
|
|
||||||
import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin";
|
|
||||||
|
|
||||||
// Mock fetchCmsContentForPage
|
// Mock fetchCmsContentForPage
|
||||||
// jest.mock('@/helpers/cms-content-helper', () => ({
|
// jest.mock('@/helpers/cms-content-helper', () => ({
|
||||||
|
|
@ -62,6 +58,36 @@ describe('coverageStatement.vue', () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(siteHeader.exists()).toBe(true);
|
expect(siteHeader.exists()).toBe(true);
|
||||||
}),
|
}),
|
||||||
|
test('Should render site subheader', () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const subheader = wrapper.find({ ref: 'siteSubHeader' });
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(subheader.exists()).toBe(true);
|
||||||
|
});
|
||||||
|
test('Should render explanatory text', () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const explanatoryText = wrapper.find({ ref: 'explanatoryText' });
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(explanatoryText.exists()).toBe(true);
|
||||||
|
});
|
||||||
|
test('Should render secondary text', () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const secondaryText = wrapper.find({ ref: 'secondaryText' });
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(secondaryText.exists()).toBe(true);
|
||||||
|
});
|
||||||
test('Should render site footer', () => {
|
test('Should render site footer', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
|
|
@ -76,7 +102,12 @@ describe('coverageStatement.vue', () => {
|
||||||
describe('Verified ITAC scenario', () => {
|
describe('Verified ITAC scenario', () => {
|
||||||
test('If coverage verified, not No Comp, and deductible > service price, verifiedITAC returns true', () => {
|
test('If coverage verified, not No Comp, and deductible > service price, verifiedITAC returns true', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mountOptions = getMountOptions();
|
const mountOptions = getMountOptions({
|
||||||
|
methods: {
|
||||||
|
getCmsContent: jest.fn().mockImplementation(() => ''),
|
||||||
|
setCmsContent: jest.fn(),
|
||||||
|
},
|
||||||
|
});
|
||||||
const sellingPrice = getRandomInt(100, 500);
|
const sellingPrice = getRandomInt(100, 500);
|
||||||
const deductible = sellingPrice + 1;
|
const deductible = sellingPrice + 1;
|
||||||
const mainInitialState = {
|
const mainInitialState = {
|
||||||
|
|
@ -480,37 +511,212 @@ describe('coverageStatement.vue', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('Navigation', () => {
|
describe('Navigation', () => {
|
||||||
test('Back button clicked triggers navigation', () => {
|
test('If Unverified, navigate forward with CLICKED_FORWARD scenario', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
const mountOptions = getMountOptions();
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: true
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mountOptions.global = {
|
||||||
|
plugins: [createTestingPinia({
|
||||||
|
initialState: {
|
||||||
|
main: mainInitialState
|
||||||
|
}
|
||||||
|
})]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Act
|
||||||
const wrapper = shallowMount(coverageStatement, getMountOptions({
|
const wrapper = shallowMount(coverageStatement, getMountOptions({
|
||||||
router: {
|
router: {
|
||||||
navigate: jest.fn()
|
navigate: jest.fn()
|
||||||
},
|
},
|
||||||
route: {
|
|
||||||
query: {
|
|
||||||
issPage: 'coverage-statement'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
}));
|
||||||
|
wrapper.setData({
|
||||||
|
isVerified: false,
|
||||||
|
})
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
wrapper.vm.navigateBack();
|
wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
|
expect(wrapper.vm.$router.navigate)
|
||||||
//expect(wrapper.vm.$router.navigate)
|
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD, undefined);
|
||||||
//.toHaveBeenCalledWith(navigationScenarios.CLICKED_BACK, undefined);
|
});
|
||||||
|
test('If Verified Deductible, navigate forward with CLICKED_FORWARD scenario', () => {
|
||||||
|
// Arrange
|
||||||
|
const mountOptions = getMountOptions();
|
||||||
|
const sellingPrice = getRandomInt(100, 500);
|
||||||
|
const deductible = sellingPrice - 1;
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: true
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
noCoverage: false,
|
||||||
|
deductible: {
|
||||||
|
repair: deductible,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mountOptions.global = {
|
||||||
|
plugins: [createTestingPinia({
|
||||||
|
initialState: {
|
||||||
|
main: mainInitialState
|
||||||
|
}
|
||||||
|
})]
|
||||||
|
}
|
||||||
|
|
||||||
|
const wrapper = shallowMount(coverageStatement, getMountOptions({
|
||||||
|
router: {
|
||||||
|
navigate: jest.fn()
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
wrapper.setData({
|
||||||
|
isVerified: true,
|
||||||
|
availableLineItems: [
|
||||||
|
{
|
||||||
|
sellingPrice: sellingPrice,
|
||||||
|
kitPrice: 0,
|
||||||
|
laborAmount: 0,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
//expect(wrapper.vm.verifiedDeductible).toBeTruthy();
|
||||||
|
expect(wrapper.vm.$router.navigate)
|
||||||
|
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD, undefined);
|
||||||
|
});
|
||||||
|
test.only('If Verified ITAC and selected Safelite, navigate forward with CLICKED_FORWARD_WITH_SAFELITE scenario', () => {
|
||||||
|
// Arrange
|
||||||
|
const mountOptions = getMountOptions();
|
||||||
|
const sellingPrice = getRandomInt(100, 500);
|
||||||
|
const deductible = sellingPrice + 1;
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: true
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
noCoverage: false,
|
||||||
|
deductible: {
|
||||||
|
repair: deductible,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
mountOptions.global = {
|
||||||
|
plugins: [createTestingPinia({
|
||||||
|
initialState: {
|
||||||
|
main: mainInitialState
|
||||||
|
}
|
||||||
|
})]
|
||||||
|
}
|
||||||
|
|
||||||
|
const wrapper = shallowMount(coverageStatement, getMountOptions({
|
||||||
|
router: {
|
||||||
|
navigate: jest.fn()
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
wrapper.setData({
|
||||||
|
isVerified: true,
|
||||||
|
availableLineItems: [
|
||||||
|
{
|
||||||
|
sellingPrice: sellingPrice,
|
||||||
|
kitPrice: 0,
|
||||||
|
laborAmount: 0,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
test('If Verified ITAC, selected other shop, and TPA enabled, navigate forward with CLICKED_FORWARD_WITH_TPA_ENABLED scenario', () => {
|
||||||
|
// Arrange
|
||||||
|
const mountOptions = getMountOptions();
|
||||||
|
const sellingPrice = getRandomInt(100, 500);
|
||||||
|
const deductible = sellingPrice + 100;
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: true
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
noCoverage: false,
|
||||||
|
deductible: {
|
||||||
|
repair: deductible,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
issConfig: {
|
||||||
|
enableTPAFlow: true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mountOptions.global = {
|
||||||
|
plugins: [createTestingPinia({
|
||||||
|
initialState: {
|
||||||
|
main: mainInitialState
|
||||||
|
}
|
||||||
|
})]
|
||||||
|
}
|
||||||
|
|
||||||
|
const wrapper = shallowMount(coverageStatement, getMountOptions({
|
||||||
|
router: {
|
||||||
|
navigate: jest.fn()
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
wrapper.setData({
|
||||||
|
isVerified: true,
|
||||||
|
availableLineItems: [
|
||||||
|
{
|
||||||
|
sellingPrice: sellingPrice,
|
||||||
|
kitPrice: 0,
|
||||||
|
laborAmount: 0,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
selectedProvider: 'Other'
|
||||||
|
});
|
||||||
|
wrapper.vm.$refs.siteFooter.updateButtonText = jest.fn();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
//expect(wrapper.vm.verifiedITAC).toBeTruthy();
|
||||||
|
expect(wrapper.vm.$router.navigate)
|
||||||
|
.toHaveBeenCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE, undefined);
|
||||||
});
|
});
|
||||||
//test('If Unverified scenario, forwardButtonAction triggers ')
|
|
||||||
});
|
});
|
||||||
|
|
||||||
})
|
})
|
||||||
//const testWidget = getRandomString(50, 100);
|
|
||||||
const mockMixin = {
|
const mockMixin = {
|
||||||
methods: {
|
methods: {
|
||||||
getCmsContent: jest.fn().mockImplementation(() => ''),
|
getCmsContent: jest.fn().mockImplementation(() => ''),
|
||||||
setCmsContent: jest.fn(),
|
setCmsContent: jest.fn(),
|
||||||
navigateBack: jest.fn()
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue