// Components
import bailout from "@/layouts/bailout/bailout.vue";

// Supporting Files
import { shallowMount } from "@vue/test-utils";
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(),
}));

describe("bailout.vue", () => {
    test("arePagePrerequisitesValid should be true ", async () => {
        //Arrange
        const { wrapper } = setupMocks();

        //Act
        let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();

        //Assert
        expect(arePagePrerequisitesValid).toBe(true);
    });
});

function setupMocks() {
    const mountOptions = getMountOptions({});

    //Mock props
    const mockMixin = {
        methods: {
            getCmsContent: jest.fn(),
        },
    };

    mountOptions.mixins = [mockMixin];
    const wrapper = shallowMount(bailout, mountOptions);

    wrapper.vm.setCmsContent = jest.fn();
    wrapper.vm.backButtonAction = jest.fn();

    return { wrapper };
}
