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

51 lines
1.4 KiB
JavaScript
Raw Normal View History

2019-01-24 08:08:28 +00:00
const app = require('vn-loopback/server/server');
2019-11-18 11:32:50 +00:00
describe('agency getShipped()', () => {
2018-08-16 11:12:18 +00:00
it('should return a shipment date', async() => {
const landed = new Date();
landed.setDate(landed.getDate() + 1);
const addressFk = 121;
const agencyModeFk = 7;
const warehouseFk = 1;
const tx = await app.models.Agency.beginTransaction({});
try {
const options = {transaction: tx};
const result = await app.models.Agency.getShipped(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() => {
const newDate = new Date();
newDate.setMonth(newDate.getMonth() - 1);
const landed = newDate;
const addressFk = 121;
const agencyModeFk = 7;
const warehouseFk = 1;
const tx = await app.models.Agency.beginTransaction({});
try {
const options = {transaction: tx};
2018-08-16 11:12:18 +00:00
const result = await app.models.Agency.getShipped(landed, addressFk, agencyModeFk, warehouseFk, options);
expect(result).toBeUndefined();
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});