45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
const {models} = require('vn-loopback/server/server');
|
|
|
|
describe('AgencyMode byWarehhouse()', () => {
|
|
const warehouseId = 1;
|
|
it('should return all the agencies', async() => {
|
|
const where = {};
|
|
|
|
const tx = await models.Zone.beginTransaction({});
|
|
|
|
try {
|
|
const options = {transaction: tx};
|
|
|
|
const agencies = await models.AgencyMode.byWarehouse({where}, options);
|
|
|
|
expect(agencies.length).toBeGreaterThan(10);
|
|
|
|
await tx.rollback();
|
|
} catch (e) {
|
|
await tx.rollback();
|
|
throw e;
|
|
}
|
|
});
|
|
|
|
it('should return only the agencies for a warehouse', async() => {
|
|
const where = {warehouseFk: warehouseId};
|
|
|
|
const tx = await models.Zone.beginTransaction({});
|
|
|
|
try {
|
|
const options = {transaction: tx};
|
|
|
|
const agencies = await models.AgencyMode.byWarehouse({where}, options);
|
|
const validWarehouse = agencies.every(agency => agency.warehouseFk = warehouseId);
|
|
|
|
expect(agencies.length).toEqual(6);
|
|
expect(validWarehouse).toBeTruthy();
|
|
|
|
await tx.rollback();
|
|
} catch (e) {
|
|
await tx.rollback();
|
|
throw e;
|
|
}
|
|
});
|
|
});
|