salix/services/db/tests/vn/buyUltimate.spec.js

42 lines
1.3 KiB
JavaScript
Raw Normal View History

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);
});
});