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

67 lines
1.8 KiB
JavaScript
Raw Normal View History

const app = require('vn-loopback/server/server');
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
describe('zone zone_getLanded()', () => {
it(`should return data for a shipped in the past`, async() => {
let stmts = [];
let stmt;
stmts.push('START TRANSACTION');
let params = {
addressFk: 121,
agencyModeFk: 7,
warehouseFk: 1};
stmt = new ParameterizedSQL('CALL zone_getLanded(DATE_ADD(CURDATE(), INTERVAL -1 DAY), ?, ?, ?)', [
params.addressFk,
params.agencyModeFk,
params.warehouseFk
]);
stmts.push(stmt);
let tableIndex = stmts.push('SELECT count(*) countZone FROM tmp.zoneGetLanded') - 1;
stmts.push('ROLLBACK');
let sql = ParameterizedSQL.join(stmts, ';');
let result = await app.models.Ticket.rawStmt(sql);
let [zoneTable] = result[tableIndex];
expect(zoneTable.countZone).toBe(1);
});
it(`should return data for a shipped tomorrow`, async() => {
let stmts = [];
let stmt;
stmts.push('START TRANSACTION');
let params = {
addressFk: 121,
agencyModeFk: 7,
warehouseFk: 1};
stmt = new ParameterizedSQL('CALL zone_getLanded(DATE_ADD(CURDATE(), INTERVAL +2 DAY), ?, ?, ?)', [
params.addressFk,
params.agencyModeFk,
params.warehouseFk
]);
stmts.push(stmt);
let tableIndex = stmts.push('SELECT count(*) countZone FROM tmp.zoneGetLanded') - 1;
stmts.push('ROLLBACK');
let sql = ParameterizedSQL.join(stmts, ';');
let result = await app.models.Ticket.rawStmt(sql);
let [zoneTable] = result[tableIndex];
expect(zoneTable.countZone).toBe(1);
});
});