80 lines
2.5 KiB
JavaScript
80 lines
2.5 KiB
JavaScript
import ProviderPreference from '@/layouts/provider-preference/provider-preference.vue';
|
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
import settleAllPromises from '@/helpers/layout-helper.js';
|
|
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
|
import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
|
import { useMainStore } from '@/store';
|
|
import navigationScenarios from '@/router/router-constants/navigation-scenarios';
|
|
|
|
// Mock our module for promises.
|
|
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
|
|
|
|
// Mock fetchCmsContentForPage
|
|
jest.mock('@/helpers/cms-content-helper', () => ({
|
|
fetchCmsContentForPage: jest.fn(),
|
|
setupModalLinks: jest.fn()
|
|
}));
|
|
|
|
/** @ignore */
|
|
function setupMocks(mockApiResponses) {
|
|
const mountOptions = getMountOptions({
|
|
router: {
|
|
navigate: jest.fn(),
|
|
navigateBailout: jest.fn()
|
|
},
|
|
route: 'provider-preference'
|
|
});
|
|
|
|
const wrapper = shallowMount(
|
|
ProviderPreference,
|
|
mountOptions
|
|
);
|
|
|
|
useMainStore().getCoveragePolicyInfo = jest.fn().mockImplementation(() => Promise.resolve({
|
|
data: {}
|
|
}));
|
|
|
|
const apiResponses = mockApiResponses;
|
|
|
|
settleAllPromises.mockImplementation(() => apiResponses);
|
|
fetchCmsContentForPage.mockImplementation(() => { });
|
|
|
|
return { wrapper };
|
|
}
|
|
|
|
describe('provider-preference.vue', () => {
|
|
test('Should navigateBailout when TPAOption selected and TPA Flow disabled', () => {
|
|
// Arrange
|
|
const { wrapper } = setupMocks();
|
|
|
|
// Act
|
|
useMainStore().issConfig.enableTPAFlow = false;
|
|
wrapper.vm.findAnotherShopClicked();
|
|
|
|
// Test
|
|
expect(wrapper.vm.$router.navigateBailout).toBeCalled();
|
|
});
|
|
|
|
test('Should navigate to safelite flow when navigateWithTPARecalAnswer is called with SafeliteOption', () => {
|
|
// Arrange
|
|
const { wrapper } = setupMocks();
|
|
|
|
// Act
|
|
wrapper.vm.navigateWithTPARecalAnswer('SafeliteOption');
|
|
|
|
// Test
|
|
expect(wrapper.vm.$router.navigate).toBeCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE, 'provider-preference');
|
|
});
|
|
|
|
test('Should navigate to TPA flow when navigateWithTPARecalAnswer is called with TPAOption', () => {
|
|
// Arrange
|
|
const { wrapper } = setupMocks();
|
|
|
|
// Act
|
|
wrapper.vm.navigateWithTPARecalAnswer('TPAOption');
|
|
|
|
// Test
|
|
expect(wrapper.vm.$router.navigate).toBeCalledWith(navigationScenarios.CLICKED_FORWARD_WITH_TPA_ENABLED, 'provider-preference');
|
|
});
|
|
});
|