2023-09-27 13:08:36 +00:00
|
|
|
const models = require('vn-loopback/server/server').models;
|
|
|
|
|
|
|
|
describe('collection getTickets()', () => {
|
2024-06-14 06:39:57 +00:00
|
|
|
const ctx = beforeAll.getCtx();
|
2023-09-28 06:30:50 +00:00
|
|
|
|
|
|
|
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);
|
2024-05-27 09:33:04 +00:00
|
|
|
expect(collectionTickets.tickets[1].sales.length).toEqual(0);
|
|
|
|
expect(collectionTickets.tickets[2].sales.length).toEqual(0);
|
2023-09-28 06:30:50 +00:00
|
|
|
expect(collectionTickets.tickets[0].sales[0].Barcodes.length).toBeTruthy();
|
2023-09-27 13:08:36 +00:00
|
|
|
|
2023-09-28 06:30:50 +00:00
|
|
|
await tx.rollback();
|
|
|
|
} catch (e) {
|
|
|
|
await tx.rollback();
|
|
|
|
throw e;
|
|
|
|
}
|
2023-09-27 13:08:36 +00:00
|
|
|
});
|
|
|
|
});
|