Tarea #723 TESTS

This commit is contained in:
Gerard 2018-10-10 14:13:53 +02:00
parent 04f0f6d9f5
commit a016d4de31
2 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,17 @@
const app = require(`${servicesDir}/order/server/server`);
describe('order getVAT()', () => {
it('should call the getVAT method and return the response', async() => {
await app.models.Order.getVAT(1)
.then(response => {
expect(response).toEqual(9.49);
});
});
it(`should call the getVAT method and return zero if doesn't have lines`, async() => {
await app.models.Order.getVAT(13)
.then(response => {
expect(response).toEqual(0);
});
});
});

View File

@ -0,0 +1,36 @@
const app = require(`${servicesDir}/order/server/server`);
describe('order summary()', () => {
it('should return a summary object containing data from 1 order', async() => {
let result = await app.models.Order.summary(1);
expect(result.id).toEqual(1);
expect(result.clientFk).toEqual(101);
});
it('should return a summary object containing sales from 1 order', async() => {
let result = await app.models.Order.summary(1);
expect(result.rows.length).toEqual(3);
});
it('should return a summary object containing subTotal for 1 order', async() => {
let result = await app.models.Order.summary(1);
expect(Math.round(result.subTotal * 100) / 100).toEqual(135.60);
});
it('should return a summary object containing VAT for 1 order', async() => {
let result = await app.models.Order.summary(1);
expect(Math.round(result.VAT * 100) / 100).toEqual(9.49);
});
it('should return a summary object containing total for 1 order', async() => {
let result = await app.models.Order.summary(1);
let total = result.subTotal + result.VAT;
let expectedTotal = Math.round(total * 100) / 100;
expect(result.total).toEqual(expectedTotal);
});
});