const models = require('vn-loopback/server/server').models; describe('collection getTickets()', () => { const ctx = beforeAll.getCtx(); it('should get tickets, sales and barcodes from collection', async() => { const tx = await models.Collection.beginTransaction({}); try { const options = {transaction: tx}; const collectionId = 1; const collectionTickets = await models.Collection.getTickets(ctx, collectionId, null, options); expect(collectionTickets.collectionFk).toEqual(collectionId); expect(collectionTickets.tickets.length).toEqual(3); expect(collectionTickets.tickets[0].ticketFk).toEqual(1); expect(collectionTickets.tickets[1].ticketFk).toEqual(2); expect(collectionTickets.tickets[2].ticketFk).toEqual(23); expect(collectionTickets.tickets[0].sales[0].ticketFk).toEqual(1); expect(collectionTickets.tickets[1].sales.length).toEqual(0); expect(collectionTickets.tickets[2].sales.length).toEqual(0); expect(collectionTickets.tickets[0].sales[0].Barcodes.length).toBeTruthy(); await tx.rollback(); } catch (e) { await tx.rollback(); throw e; } }); });