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 steeringModal from '@/layouts/provider-preference/steering-modal/steering-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() { const mountOptions = getMountOptions({ router: { navigate: jest.fn() } }); const wrapper = shallowMount( steeringModal, mountOptions ); const apiResponses = {}; settleAllPromises.mockImplementation(() => apiResponses); fetchCmsContentForPage.mockImplementation(() => { }); return { wrapper }; } describe('steering-modal.vue', () => { test('getStateSpecificText should return true if state matches', () => { const { wrapper } = setupMocks(); useMainStore().order.customer.address.state = 'OH'; expect(wrapper.vm.getStateSpecificText('OH')).toBeTruthy(); }); });