import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
import { createWrapper, axios } from 'app/test/vitest/helper';
import TicketBoxing from 'pages/Ticket/Card/TicketBoxing.vue';

// #4836 - Investigate how to test q-drawer outside
// q-layout or how to teleport q-drawer inside
describe('TicketBoxing', () => {
    let vm;
    beforeAll(() => {
        vm = createWrapper(TicketBoxing).vm;
    });

    afterEach(() => {
        vi.clearAllMocks();
    });

    describe('getVideoList()', () => {
        it('should when response videoList use to list', async () => {
            const expeditionId = 1;
            const timed = {
                min: 1,
                max: 2,
            };
            const videoList = ['2022-01-01T01-01-00.mp4', '2022-02-02T02-02-00.mp4', '2022-03-03T03-03-00.mp4'];

            vi.spyOn(axios, 'get').mockResolvedValue({ data: videoList });
            vi.spyOn(vm.quasar, 'notify');

            await vm.getVideoList(expeditionId, timed);

            expect(vm.videoList.length).toEqual(videoList.length);
            expect(vm.slide).toEqual(videoList.reverse()[0]);
        });

        it('should if not have video show notify', async () => {
            const expeditionId = 1;
            const timed = {
                min: 1,
                max: 2,
            };

            vi.spyOn(axios, 'get').mockResolvedValue({ data: [] });
            vi.spyOn(vm.quasar, 'notify');

            await vm.getVideoList(expeditionId, timed);

            expect(vm.quasar.notify).toHaveBeenCalledWith(expect.objectContaining({ type: 'negative' }));
        });
    });
});