const models = require('vn-loopback/server/server').models; describe('agency getShipped()', () => { const employeeId = 1; const ctx = {req: {accessToken: {userId: employeeId}}}; it('should return a shipment date', async() => { const landed = Date.vnNew(); landed.setDate(landed.getDate() + 1); const addressFk = 121; const agencyModeFk = 7; const warehouseFk = 1; const tx = await models.Agency.beginTransaction({}); try { const options = {transaction: tx}; 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; } }); it('should not return a shipment date', async() => { const newDate = Date.vnNew(); newDate.setMonth(newDate.getMonth() - 1); const landed = newDate; const addressFk = 121; const agencyModeFk = 7; const warehouseFk = 1; const tx = await models.Agency.beginTransaction({}); try { const options = {transaction: tx}; 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; } }); });