#709 PROCEDURE vn.buyUltimate() unit test

This commit is contained in:
Carlos Jimenez 2018-10-04 14:42:44 +02:00
parent efc477f42d
commit af2803deda
1 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,41 @@
const app = require(`../../../ticket/server/server`);
describe('buyUltimate()', () => {
const today = new Date();
it(`should create buyUltimate temporal table and update it's values`, async() => {
let params = {
warehouseFk: 1,
date: today
};
let query = `
START TRANSACTION;
CALL vn.buyUltimate(?, ?);
SELECT * FROM tmp.buyUltimate;
ROLLBACK;`;
let result = await app.models.Ticket.rawSql(query, [
params.warehouseFk,
params.date
]);
let buyUltimateTable = result[2];
expect(buyUltimateTable.length).toEqual(4);
expect(buyUltimateTable[0].itemFk).toEqual(1);
expect(buyUltimateTable[1].itemFk).toEqual(2);
expect(buyUltimateTable[2].itemFk).toEqual(3);
expect(buyUltimateTable[3].itemFk).toEqual(4);
expect(buyUltimateTable[0].warehouseFk).toEqual(1);
expect(buyUltimateTable[1].warehouseFk).toEqual(1);
expect(buyUltimateTable[2].warehouseFk).toEqual(1);
expect(buyUltimateTable[3].warehouseFk).toEqual(1);
expect(buyUltimateTable[1].buyFk).toEqual(4);
expect(buyUltimateTable[0].buyFk).toEqual(3);
expect(buyUltimateTable[2].buyFk).toEqual(5);
expect(buyUltimateTable[3].buyFk).toEqual(6);
});
});