0
0
Fork 0

chore: refs #7524 fix test

This commit is contained in:
Jorge Penadés 2024-10-28 14:21:03 +01:00
parent a73a451cd8
commit 934b32092b
1 changed files with 13 additions and 9 deletions

View File

@ -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([]);
});
});