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

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

describe("Vehicle Review Block", () => {
    test("Correctly assembles vehicle info into a display string", async () => {
        // Arrange
        const { wrapper } = setupMocks({
            propsData: {
                vehicle: {
                    year: "2019",
                    make: "Honda",
                    model: "Odyssey",
                },
            },
        });

        // Act
        await wrapper.vm.$nextTick();

        // Assert
        expect(wrapper.vm.displayContent).toStrictEqual(["2019 Honda Odyssey"]);
    });
});

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

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