import { jest, describe, expect, it, beforeAll } from '@jest/globals'; import { createWrapper, axios } from 'app/tests/jest/jestHelpers'; import TicketBoxing from '../TicketBoxing.vue'; const mockPush = jest.fn(); jest.mock('vue-router', () => ({ useRouter: () => ({ push: mockPush, currentRoute: { value: { params: { id: 1 } } } }), })); // #4836 - Investigate how to test q-drawer outside // q-layout or how to teleport q-drawer inside xdescribe('TicketBoxing', () => { let vm; beforeAll(() => { vm = createWrapper(TicketBoxing).vm; }); afterEach(() => { jest.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", ] jest.spyOn(axios, 'get').mockResolvedValue({ data: videoList }); jest.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 } jest.spyOn(axios, 'get').mockResolvedValue({ data: [] }); jest.spyOn(vm.quasar, 'notify') await vm.getVideoList(expeditionId, timed); expect(vm.quasar.notify).toHaveBeenCalledWith(expect.objectContaining( { 'type': 'negative' } )); }); }); });