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