salix/back/methods/collection/spec/getTickets.spec.js

32 lines
1.3 KiB
JavaScript
Raw Normal View History

const models = require('vn-loopback/server/server').models;
describe('collection getTickets()', () => {
2024-06-14 06:39:57 +00:00
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);
2024-05-27 09:33:04 +00:00
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;
}
});
});