salix/db/tests/vn/item_getBalance.spec.js

33 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-03-29 13:31:00 +00:00
const app = require('vn-loopback/server/server');
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
describe('item_getBalance()', () => {
it(`should return the item balance`, async() => {
let stmts = [];
let params = {
warehouseFk: 1,
itemFk: 1
};
const conn = await app.models.Item.dataSource.connector;
stmts.push(new ParameterizedSQL('CALL vn.item_getBalance(?, ?)', [
params.warehouseFk,
params.itemFk
]));
let sql = ParameterizedSQL.join(stmts, ';');
let result = await conn.executeStmt(sql);
let itemBalance = result[0];
expect(itemBalance[0].alertLevel >= itemBalance[1].alertLevel).toBeTruthy();
expect(itemBalance[1].alertLevel >= itemBalance[2].alertLevel).toBeTruthy();
expect(itemBalance[2].alertLevel >= itemBalance[3].alertLevel).toBeTruthy();
expect(itemBalance[3].alertLevel >= itemBalance[4].alertLevel).toBeTruthy();
expect(itemBalance[4].alertLevel >= itemBalance[5].alertLevel).toBeTruthy();
expect(itemBalance[5].alertLevel >= itemBalance[6].alertLevel).toBeTruthy();
});
});