import { shallowMount } from "@vue/test-utils";
import { getMountOptions } from "@/helpers/unit-test-helper.js";
import store from "@/store";
import reviewBlock from "@/layouts/payment-method/review-dropdown/review-block/review-block";

jest.mock("@/helpers/cms-content-helper", () => ({
    fetchCmsContentForPage: () => Promise.resolve("content"),
}));

describe("Review Content Block", () => {
    test("Displays one new line of content for each element in the content prop.", () => {
        // Arrange
        const { wrapper } = setupMocks({
            propsData: {
                headerCmsWidgetName: "TestWidget",
                content: ["a", "b", "c", "d"],
            },
        });

        // Act
        const contentLines = wrapper.findAll("[data-test='contentLine']");

        // Assert
        expect(contentLines.length).toBe(4);
    });
});

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

    mountOptions["attachTo"] = document.body;

    const wrapper = shallowMount(reviewBlock, mountOptions);
    wrapper.vm.setCmsContent = jest.fn();
    return { wrapper };
}
