import { shallowMount } from '@vue/test-utils';
import calendarModalQuestion from '@/layouts/order-confirmation/add-to-calendar/calendar-modal-question/calendar-modal-question.vue';

describe('calendar-modal-question.vue', () => {
    test('When selected calendar option is changed, a correctly selectedCalendarOption should be emitted', async () => {
        // Arrange
        const url = 'iCal url';
        const name = 'iCal';
        const icon = 'iCal.svg';
        const expectedEmit = [
            [
                {
                    url,
                    name,
                    icon
                }
            ]
        ];

        const wrapper = shallowMount(calendarModalQuestion, {
            propsData: {
                calendarOptionsData: [
                    {
                        url,
                        name,
                        icon
                    }
                ]
            }
        });

        wrapper.vm.$refs.calendarOptions.closeModal = jest.fn();
        wrapper.vm.selectedCalendarOption = name;

        // Act
        wrapper.vm.setSelectedCalendarOption();

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