salix/modules/zone/back/methods/agency/specs/getShipped.spec.js

53 lines
1.5 KiB
JavaScript
Raw Permalink Normal View History

2023-05-11 06:00:49 +00:00
const models = require('vn-loopback/server/server').models;
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();
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({});
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);
expect(result).toBeDefined();
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();
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({});
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);
expect(result).toBeUndefined();
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});