2023-01-24 08:04:43 +00:00
|
|
|
const {models} = require('vn-loopback/server/server');
|
2020-09-23 09:21:25 +00:00
|
|
|
|
|
|
|
describe('AgencyMode byWarehhouse()', () => {
|
|
|
|
const warehouseId = 1;
|
|
|
|
it('should return all the agencies', async() => {
|
|
|
|
const where = {};
|
|
|
|
|
2023-01-24 08:04:43 +00:00
|
|
|
const tx = await models.Zone.beginTransaction({});
|
2021-06-18 13:05:03 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
const options = {transaction: tx};
|
|
|
|
|
2023-01-24 08:04:43 +00:00
|
|
|
const agencies = await models.AgencyMode.byWarehouse({where}, options);
|
2021-06-18 13:05:03 +00:00
|
|
|
|
|
|
|
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};
|
|
|
|
|
2023-01-24 08:04:43 +00:00
|
|
|
const tx = await models.Zone.beginTransaction({});
|
2021-06-18 13:05:03 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
const options = {transaction: tx};
|
|
|
|
|
2023-01-24 08:04:43 +00:00
|
|
|
const agencies = await models.AgencyMode.byWarehouse({where}, options);
|
2021-06-18 13:05:03 +00:00
|
|
|
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
|
|
|
});
|
|
|
|
});
|