const app = require('vn-loopback/server/server'); describe('AgencyMode byWarehhouse()', () => { const warehouseId = 1; it('should return all the agencies', async() => { const where = {}; const agencies = await app.models.AgencyMode.byWarehouse({where}); expect(agencies.length).toBeGreaterThan(10); }); it('should return only the agencies for a warehouse', async() => { const where = {warehouseFk: warehouseId}; const agencies = await app.models.AgencyMode.byWarehouse({where}); const validWarehouse = agencies.every(agency => agency.warehouseFk = warehouseId); expect(agencies.length).toEqual(6); expect(validWarehouse).toBeTruthy(); }); });