import policyVehiclesQuestion from '@/layouts/policy-vehicles/policy-vehicles-question/policy-vehicles-question.vue';
import { shallowMount } from '@vue/test-utils';

const mockMixin = {
    methods: {
        getCmsContent: jest.fn(() => ['vehicle not listed'])
    }
};

describe('policy-vehicles-question.vue', () => {
    test('Selected vehicle is emitted upon selection', async () => {
        // Arrange
        const vehicleToSelect = 'Test1';
        const wrapper = shallowMount(policyVehiclesQuestion, {
            mixins: [mockMixin],
            propsData: {
                vehicles: ['Test1', 'Test2']
            }
        });

        // Act
        wrapper.setValue({ modelValue: vehicleToSelect });
        await wrapper.vm.$nextTick();

        // Assert
        expect(wrapper.emitted()['update:modelValue'][0]).toEqual([
            { modelValue: 'Test1' }
        ]);
    });
});
