2023-05-11 06:00:49 +00:00
|
|
|
const models = require('vn-loopback/server/server').models;
|
2018-07-24 10:14:35 +00:00
|
|
|
|
2019-11-18 11:32:50 +00:00
|
|
|
describe('agency getShipped()', () => {
|
2023-05-11 06:00:49 +00:00
|
|
|
const employeeId = 1;
|
|
|
|
const ctx = {req: {accessToken: {userId: employeeId}}};
|
|
|
|
|
2018-08-16 11:12:18 +00:00
|
|
|
it('should return a shipment date', async() => {
|
2023-01-16 14:18:24 +00:00
|
|
|
const landed = Date.vnNew();
|
2021-06-18 13:05:03 +00:00
|
|
|
landed.setDate(landed.getDate() + 1);
|
|
|
|
const addressFk = 121;
|
|
|
|
const agencyModeFk = 7;
|
|
|
|
const warehouseFk = 1;
|
|
|
|
|
2023-01-24 08:04:43 +00:00
|
|
|
const tx = await models.Agency.beginTransaction({});
|
2019-07-26 09:48:01 +00:00
|
|
|
|
2021-05-14 17:21:04 +00:00
|
|
|
try {
|
|
|
|
const options = {transaction: tx};
|
2023-05-11 06:00:49 +00:00
|
|
|
const result = await models.Agency.getShipped(ctx, landed, addressFk, agencyModeFk, warehouseFk, options);
|
2021-05-14 17:21:04 +00:00
|
|
|
|
2021-06-18 13:05:03 +00:00
|
|
|
expect(result).toBeDefined();
|
2021-05-14 17:21:04 +00:00
|
|
|
|
|
|
|
await tx.rollback();
|
|
|
|
} catch (e) {
|
|
|
|
await tx.rollback();
|
|
|
|
throw e;
|
|
|
|
}
|
2018-08-16 11:12:18 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should not return a shipment date', async() => {
|
2023-01-16 14:18:24 +00:00
|
|
|
const newDate = Date.vnNew();
|
2021-06-18 13:05:03 +00:00
|
|
|
newDate.setMonth(newDate.getMonth() - 1);
|
|
|
|
const landed = newDate;
|
|
|
|
const addressFk = 121;
|
|
|
|
const agencyModeFk = 7;
|
|
|
|
const warehouseFk = 1;
|
|
|
|
|
2023-01-24 08:04:43 +00:00
|
|
|
const tx = await models.Agency.beginTransaction({});
|
2021-05-14 17:21:04 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
const options = {transaction: tx};
|
2018-08-16 11:12:18 +00:00
|
|
|
|
2023-05-11 06:00:49 +00:00
|
|
|
const result = await models.Agency.getShipped(ctx, landed, addressFk, agencyModeFk, warehouseFk, options);
|
2021-06-18 13:05:03 +00:00
|
|
|
|
|
|
|
expect(result).toBeUndefined();
|
2019-07-26 09:48:01 +00:00
|
|
|
|
2021-05-14 17:21:04 +00:00
|
|
|
await tx.rollback();
|
|
|
|
} catch (e) {
|
|
|
|
await tx.rollback();
|
|
|
|
throw e;
|
|
|
|
}
|
2018-07-24 10:14:35 +00:00
|
|
|
});
|
|
|
|
});
|