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

76 lines
2.1 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');
2022-06-09 11:33:01 +00:00
const date = new Date();
date.setHours(0, 0, 0, 0);
let params = {
addressFk: 121,
agencyModeFk: 7,
2020-06-05 08:01:21 +00:00
warehouseFk: 1,
showExpiredZones: true};
2022-06-09 11:33:01 +00:00
stmt = new ParameterizedSQL('CALL zone_getLanded(DATE_ADD(?, INTERVAL -1 DAY), ?, ?, ?, ?)', [
date,
params.addressFk,
params.agencyModeFk,
2020-06-05 08:01:21 +00:00
params.warehouseFk,
params.showExpiredZones
]);
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;
2022-06-09 11:33:01 +00:00
const date = new Date();
date.setHours(0, 0, 0, 0);
stmts.push('START TRANSACTION');
let params = {
addressFk: 121,
agencyModeFk: 7,
2020-06-05 08:01:21 +00:00
warehouseFk: 1,
showExpiredZones: false};
2022-06-09 11:33:01 +00:00
stmt = new ParameterizedSQL('CALL zone_getLanded(DATE_ADD(?, INTERVAL +2 DAY), ?, ?, ?, ?)', [
date,
params.addressFk,
params.agencyModeFk,
2020-06-05 08:01:21 +00:00
params.warehouseFk,
params.showExpiredZones
]);
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);
});
});