59 lines
1.7 KiB
JavaScript
59 lines
1.7 KiB
JavaScript
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 shopPreferenceModal from '@/layouts/provider-preference/shop-preference-modal/shop-preference-modal.vue';
|
|
|
|
// 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(propsData) {
|
|
const mountOptions = getMountOptions({
|
|
router: {
|
|
navigate: jest.fn()
|
|
}
|
|
});
|
|
|
|
mountOptions.propsData = propsData;
|
|
|
|
const wrapper = shallowMount(
|
|
shopPreferenceModal,
|
|
mountOptions
|
|
);
|
|
|
|
const apiResponses = {};
|
|
|
|
settleAllPromises.mockImplementation(() => apiResponses);
|
|
fetchCmsContentForPage.mockImplementation(() => { });
|
|
|
|
return { wrapper };
|
|
}
|
|
|
|
describe('provider-preference.vue', () => {
|
|
test('Should display state specific steering modal link when in state with steering language', async () => {
|
|
// Arrange
|
|
const { wrapper } = setupMocks({ showSteeringLink: true });
|
|
|
|
// Act
|
|
|
|
// Test
|
|
expect(wrapper.vm.showSteeringLink).toBeTruthy();
|
|
});
|
|
|
|
test('Should not display state specific steering modal link when not in state with steering language', async () => {
|
|
// Arrange
|
|
const { wrapper } = setupMocks({ showSteeringLink: false });
|
|
|
|
// Act
|
|
|
|
// Test
|
|
expect(wrapper.vm.showSteeringLink).toBeFalsy();
|
|
});
|
|
});
|