import { shallowMount } from "@vue/test-utils";
import saveProgressQuestion from "./save-progress-question";

describe("save-progress-question.vue", () => {
    it("Should get the modelValue", async () => {
        // Arrange
        const text = "test";
        const wrapper = shallowMount(saveProgressQuestion, {
            props: {
                modelValue: text,
            },
            attachTo: document.body,
        });

        // Act
        const modelValueText = wrapper.vm.value;
        wrapper.vm.value = "test also";

        // Assert
        expect(modelValueText).toEqual("test");
    });

    it("Should emit to set value", async () => {
        // Arrange
        const text = "test";
        const wrapper = shallowMount(saveProgressQuestion, {
            props: {
                modelValue: text,
            },
            attachTo: document.body,
        });

        // Act
        const modelValueText = wrapper.vm.value;
        wrapper.vm.value = "test also";

        // Assert
        expect(wrapper.emitted("update:modelValue")).toEqual([["test also"]]);
    });
});
