67 lines
1.7 KiB
JavaScript
67 lines
1.7 KiB
JavaScript
import shopPreferenceModal from "./shop-preference-modal.vue"
|
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
import { settleAllPromises } from "@/helpers/layout-helper.js";
|
|
import { fetchCmsContentForPage, setupModalLinks } from "@/helpers/cms-content-helper";
|
|
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
|
|
|
// Mock our module for promises.
|
|
jest.mock("@/helpers/layout-helper.js", () => ({
|
|
settleAllPromises: jest.fn(),
|
|
}));
|
|
|
|
// Mock fetchCmsContentForPage
|
|
jest.mock("@/helpers/cms-content-helper", () => ({
|
|
fetchCmsContentForPage: jest.fn(),
|
|
setupModalLinks: jest.fn(),
|
|
}));
|
|
|
|
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();
|
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
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 };
|
|
}
|