2021-03-29 13:31:00 +00:00
|
|
|
const app = require('vn-loopback/server/server');
|
|
|
|
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
|
|
|
|
|
|
|
describe('item_getBalance()', () => {
|
2021-03-31 05:54:50 +00:00
|
|
|
it(`should return the item balance ordered by alert level`, async() => {
|
2021-03-29 13:31:00 +00:00
|
|
|
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];
|
|
|
|
|
2021-03-31 05:54:50 +00:00
|
|
|
expect(itemBalance[0].alertLevel).toBeGreaterThanOrEqual(itemBalance[1].alertLevel);
|
|
|
|
expect(itemBalance[1].alertLevel).toBeGreaterThanOrEqual(itemBalance[2].alertLevel);
|
|
|
|
expect(itemBalance[2].alertLevel).toBeGreaterThanOrEqual(itemBalance[3].alertLevel);
|
|
|
|
expect(itemBalance[3].alertLevel).toBeGreaterThanOrEqual(itemBalance[4].alertLevel);
|
|
|
|
expect(itemBalance[4].alertLevel).toBeGreaterThanOrEqual(itemBalance[5].alertLevel);
|
|
|
|
expect(itemBalance[5].alertLevel).toBeGreaterThanOrEqual(itemBalance[6].alertLevel);
|
2021-03-29 13:31:00 +00:00
|
|
|
});
|
|
|
|
});
|