feat: refs #6583 add tests
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Jorge Penadés 2024-12-17 12:58:25 +01:00
parent f965f7aa52
commit b935878dd6
1 changed files with 52 additions and 0 deletions

View File

@ -167,4 +167,56 @@ describe('TicketFuture getTicketsAdvance()', () => {
throw e;
}
});
it('should return the tickets with only destination', async() => {
const tx = await models.Ticket.beginTransaction({});
try {
const options = {transaction: tx};
const args = {
dateFuture: today,
dateToAdvance: today.setHours(23, 59, 59, 999),
warehouseFk: 1,
};
ctx.args = args;
const allTickets = await models.Ticket.getTicketsAdvance(ctx, options);
ctx.args.onlyWithDestination = true;
const withDestinationTickets = await models.Ticket.getTicketsAdvance(ctx, options);
expect(allTickets.filter(ticket => ticket.id).length).toBe(withDestinationTickets.length);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
fit('should return the tickets without only destination', async() => {
const tx = await models.Ticket.beginTransaction({});
try {
const options = {transaction: tx};
const args = {
dateFuture: today,
dateToAdvance: today.setHours(23, 59, 59, 999),
warehouseFk: 1,
};
ctx.args = args;
const allTickets = await models.Ticket.getTicketsAdvance(ctx, options);
ctx.args.onlyWithDestination = false;
const withoutDestinationTickets = await models.Ticket.getTicketsAdvance(ctx, options);
expect(allTickets.filter(ticket => !ticket.id).length).toBe(withoutDestinationTickets.length);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});