import { shallowMount } from '@vue/test-utils';
import calendarOptionSelection from '@/layouts/order-confirmation/add-to-calendar/calendar-option-selection/calendar-option-selection.vue';

describe('calendar-option-selection.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 url2 = 'Google url';
        const name2 = 'Google';
        const icon2 = 'Google.svg';
        const expectedEmit = [
            [
                1
            ]
        ];

        const wrapper = shallowMount(calendarOptionSelection, {
            propsData: {
                calendarOptionsData: [
                    {
                        url,
                        name,
                        icon
                    },
                    {
                        url: url2,
                        name: name2,
                        icon: icon2
                    }
                ]
            }
        });

        // Act
        wrapper.vm.setSelectedCalendarOption(1);

        // Assert
        expect(wrapper.emitted()['calendar-option-selected']).toEqual(expectedEmit);
    });
});
