32 lines
1.3 KiB
JavaScript
32 lines
1.3 KiB
JavaScript
const models = require('vn-loopback/server/server').models;
|
|
|
|
describe('collection getTickets()', () => {
|
|
const {ctx} = beforeAll;
|
|
|
|
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[0].sales[1].ticketFk).toEqual(1);
|
|
expect(collectionTickets.tickets[0].sales[2].ticketFk).toEqual(1);
|
|
expect(collectionTickets.tickets[0].sales[0].Barcodes.length).toBeTruthy();
|
|
|
|
await tx.rollback();
|
|
} catch (e) {
|
|
await tx.rollback();
|
|
throw e;
|
|
}
|
|
});
|
|
});
|