// Components
import entryPage from '@/layouts/entry-page/entry-page.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';

// 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(queryString) {
    const mountOptions = getMountOptions({
        router: {
            navigate: jest.fn()
        },
        route: { queryString }
    });

    const wrapper = shallowMount(
        entryPage,
        mountOptions
    );

    const apiResponses = {};

    settleAllPromises.mockImplementation(() => apiResponses);
    fetchCmsContentForPage.mockImplementation(() => { });

    return { wrapper };
}

describe('entry-page.vue', () => {
    test('should render', () => {
        const queryString = 'policynumber="123456"';
        const { wrapper } = setupMocks(queryString);

        window.console.log(wrapper.vm.$route.query);
        expect(wrapper).toBeTruthy();
    });
});
