import { mount, shallowMount } from "@vue/test-utils";
import saveProgressPopupQuestion from "./save-progress-popup-question";
import { getMountOptions } from "@/helpers/unit-test-helper.js";

jest.mock("@/digital-components/modal/modal", () => ({
    methods: {
        closeModal: jest.fn(),
        resetButtonStyle: jest.fn(),
    },
}));

describe("save-progress-popup-question ", () => {
    describe("when closeModal is run ", () => {
        test("the modal should close ", () => {
            // Arrange
            const { wrapper } = setupMocks({
                props: {
                    modelValue: "",
                    modalWidgetName: "testModal",
                },
            });

            // Act
            wrapper.vm.closeModal();

            // Assert
            expect(wrapper.vm.modal).not.toBeNull();
        });
    });
});

function setupMocks({ options, props }) {
    const mountOptions = getMountOptions({
        ...options,
    });

    const mockBaseMixin = {
        methods: {
            getCmsContent: jest.fn(),
            dispatchStoreAction: jest.fn(),
        },
    };

    if (props) mountOptions.propsData = props;

    mountOptions.global.mixins = [mockBaseMixin];

    const wrapper = mount(saveProgressPopupQuestion, mountOptions);

    return { wrapper };
}
