From 934b32092bb27eebcbbd298674bb5e5f7e832515 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 28 Oct 2024 14:21:03 +0100 Subject: [PATCH] chore: refs #7524 fix test --- .../pages/Tickets/TicketAdvance.spec.js | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/test/vitest/__tests__/pages/Tickets/TicketAdvance.spec.js b/test/vitest/__tests__/pages/Tickets/TicketAdvance.spec.js index 6fae2788e..ab1a47544 100644 --- a/test/vitest/__tests__/pages/Tickets/TicketAdvance.spec.js +++ b/test/vitest/__tests__/pages/Tickets/TicketAdvance.spec.js @@ -2,6 +2,7 @@ import { vi, describe, expect, it, beforeAll, afterEach, beforeEach } from 'vite import { createWrapper, axios } from 'app/test/vitest/helper'; import TicketAdvance from 'pages/Ticket/TicketAdvance.vue'; import { Notify } from 'quasar'; +import { nextTick } from 'vue'; describe('TicketAdvance', () => { let wrapper; @@ -11,7 +12,8 @@ describe('TicketAdvance', () => { vi.spyOn(axios, 'get').mockImplementation(() => ({ data: [] })); wrapper = createWrapper(TicketAdvance); vm = wrapper.vm; - // vm.vnTableRef.value = { reload: vi.fn(), params: {} }; + vi.spyOn(vm.vnTableRef, 'reload').mockImplementation(() => vi.fn()); + vm.vnTableRef.value = { params: {} }; }); beforeEach(() => { Notify.create = vi.fn(); @@ -29,7 +31,7 @@ describe('TicketAdvance', () => { futureAgencyModeFk: 1, futureWarehouseFk: 1, futureCompanyFk: 1, - landed: '2023-01-01', + landed: '2023-01-02', zoneFk: 1, }; const mockParams = { @@ -40,7 +42,8 @@ describe('TicketAdvance', () => { zoneFk: 1, warehouseFk: 1, companyFk: 1, - landed: '2023-01-01', + landed: '2023-01-02', + shipped: '2023-01-01', isDeleted: false, isWithoutNegatives: false, newTicket: undefined, @@ -49,7 +52,10 @@ describe('TicketAdvance', () => { const queryResult = 'tickets/1/componentUpdate'; it('should return query and params when ticket has no landed', async () => { - const mockLanded = { landed: '2023-01-01', zoneFk: 1 }; + vm.vnTableRef.params.dateToAdvance = '2023-01-01'; + await nextTick(); + + const mockLanded = { landed: '2023-01-02', zoneFk: 1 }; vi.spyOn(vm, 'getLanded').mockResolvedValue(mockLanded); const { query, params } = await vm.requestComponentUpdate(mockTicket, false); @@ -84,7 +90,7 @@ describe('TicketAdvance', () => { workerFk: 1, }, ]; - vm.selectedTickets.value = tickets; + vm.selectedTickets = tickets; vi.spyOn(axios, 'post').mockResolvedValue({}); await vm.moveTicketsAdvance(); @@ -106,10 +112,8 @@ describe('TicketAdvance', () => { }, ], }); - expect(Notify.create).toHaveBeenCalledWith({ - type: 'positive', - message: 'advanceTickets.moveTicketSuccess', - }); + expect(vm.vnTableRef.reload).toHaveBeenCalled(); + expect(Notify.create).toHaveBeenCalled(); expect(vm.selectedTickets).toEqual([]); }); });