2020-09-23 09:21:25 +00:00
|
|
|
const app = require('vn-loopback/server/server');
|
|
|
|
|
|
|
|
describe('AgencyMode byWarehhouse()', () => {
|
|
|
|
const warehouseId = 1;
|
|
|
|
it('should return all the agencies', async() => {
|
|
|
|
const where = {};
|
|
|
|
|
2021-06-18 13:05:03 +00:00
|
|
|
const tx = await app.models.Zone.beginTransaction({});
|
|
|
|
|
|
|
|
try {
|
|
|
|
const options = {transaction: tx};
|
|
|
|
|
|
|
|
const agencies = await app.models.AgencyMode.byWarehouse({where}, options);
|
|
|
|
|
|
|
|
expect(agencies.length).toBeGreaterThan(10);
|
|
|
|
|
|
|
|
await tx.rollback();
|
|
|
|
} catch (e) {
|
|
|
|
await tx.rollback();
|
|
|
|
throw e;
|
|
|
|
}
|
2020-09-23 09:21:25 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should return only the agencies for a warehouse', async() => {
|
|
|
|
const where = {warehouseFk: warehouseId};
|
|
|
|
|
2021-06-18 13:05:03 +00:00
|
|
|
const tx = await app.models.Zone.beginTransaction({});
|
|
|
|
|
|
|
|
try {
|
|
|
|
const options = {transaction: tx};
|
|
|
|
|
|
|
|
const agencies = await app.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;
|
|
|
|
}
|
2020-09-23 09:21:25 +00:00
|
|
|
});
|
|
|
|
});
|