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

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

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

            // Act
            wrapper.vm.openModal();

            // 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(saveProgressModalQuestion, mountOptions);

    return { wrapper };
}
