#548 ticket/summary.js Backend unit tests

This commit is contained in:
Carlos Jimenez 2018-08-22 09:20:34 +02:00
parent 5a4f6e2e1e
commit 05ae6bd534
1 changed files with 33 additions and 10 deletions

View File

@ -1,12 +1,35 @@
// const app = require(`${servicesDir}/ticket/server/server`); const app = require(`${servicesDir}/ticket/server/server`);
// describe('ticket summary()', () => { describe('ticket summary()', () => {
// describe('getTicketData()', () => { it('should return a summary object containing data from 1 ticket', async() => {
// it('should sum all sales price', done => { let result = await app.models.Ticket.summary(1);
// let result = getTicketData(model, 1);
// expect(result).toEqual("pepinillos"); expect(result.id).toEqual(1);
// done(); expect(result.nickname).toEqual('Batman');
// }); });
// });
// }); 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(389.5);
});
it('should return a summary object containing VAT for 1 ticket', async() => {
let result = await app.models.Ticket.summary(1);
expect(result.VAT).toEqual(58.75);
});
it('should return a summary object containing total for 1 ticket', async() => {
let result = await app.models.Ticket.summary(1);
let expectedTotal = result.subTotal + result.VAT;
expect(result.total).toEqual(expectedTotal);
});
});