// Components
import vehicleReview from '@/layouts/payment-method/review-dropdown/review-sections/vehicle-review/vehicle-review.vue';

// Supporting Files
import { shallowMount } from '@vue/test-utils';
import { getMountOptions } from '@/helpers/unit-test-helper.js';

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

function getShallowMountedComponent(initialData = {}, methodToRun = () => {}) {
    const mountOptions = getMountOptions({
        router: {
            navigate: jest.fn()
        }
    });

    methodToRun();

    mountOptions.data = () => (
        initialData
    );

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

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

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

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