37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
const app = require(`${servicesDir}/ticket/server/server`);
|
|
|
|
describe('ticket summary()', () => {
|
|
it('should return a summary object containing data from 1 ticket', async() => {
|
|
let result = await app.models.Ticket.summary(1);
|
|
|
|
expect(result.id).toEqual(1);
|
|
expect(result.nickname).toEqual('address 21');
|
|
});
|
|
|
|
it('should return a summary object containing sales from 1 ticket', async() => {
|
|
let result = await app.models.Ticket.summary(1);
|
|
|
|
expect(result.sales.length).toEqual(4);
|
|
});
|
|
|
|
it('should return a summary object containing subTotal for 1 ticket', async() => {
|
|
let result = await app.models.Ticket.summary(1);
|
|
|
|
expect(result.subTotal).toEqual(158.14);
|
|
});
|
|
|
|
it('should return a summary object containing VAT for 1 ticket', async() => {
|
|
let result = await app.models.Ticket.summary(1);
|
|
|
|
expect(Math.round(result.VAT * 100) / 100).toEqual(22.98);
|
|
});
|
|
|
|
it('should return a summary object containing total for 1 ticket', async() => {
|
|
let result = await app.models.Ticket.summary(1);
|
|
let total = result.subTotal + result.VAT;
|
|
let expectedTotal = Math.round(total * 100) / 100;
|
|
|
|
expect(result.total).toEqual(expectedTotal);
|
|
});
|
|
});
|