DigitalConsumer.FixMyGlass/src/fmg-components/save-progress-modal-question/save-progress-modal-question.spec.js
2025-01-13 17:10:54 -05:00

51 lines
1.3 KiB
JavaScript

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 };
}