diff --git a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js index a941013cd..bb7f230ee 100644 --- a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js +++ b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js @@ -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; + } + }); });