const models = require('vn-loopback/server/server').models; describe('ticket summary()', () => { const ctx = {req: {accessToken: 9}}; it('should return a summary object containing data from 1 ticket', async() => { const tx = await models.Ticket.beginTransaction({}); try { const options = {transaction: tx}; const result = await models.Ticket.summary(ctx, 1, options); expect(result.id).toEqual(1); expect(result.nickname).toEqual('Bat cave'); await tx.rollback(); } catch (e) { await tx.rollback(); throw e; } }); it('should return a summary object containing sales from 1 ticket', async() => { const tx = await models.Ticket.beginTransaction({}); try { const options = {transaction: tx}; const result = await models.Ticket.summary(ctx, 1, options); expect(result.sales.length).toEqual(4); await tx.rollback(); } catch (e) { await tx.rollback(); throw e; } }); it('should return a summary object containing totalWithoutVat for 1 ticket', async() => { const tx = await models.Ticket.beginTransaction({}); try { const options = {transaction: tx}; const result = await models.Ticket.summary(ctx, 1, options); expect(result.totalWithoutVat).toEqual(jasmine.any(Number)); await tx.rollback(); } catch (e) { await tx.rollback(); throw e; } }); it('should return a summary object containing total for 1 ticket', async() => { const tx = await models.Ticket.beginTransaction({}); try { const options = {transaction: tx}; const result = await models.Ticket.summary(ctx, 1, options); expect(result.totalWithVat).toEqual(jasmine.any(Number)); await tx.rollback(); } catch (e) { await tx.rollback(); throw e; } }); });