salix/modules/zone/back/methods/agency-mode/specs/byWarehouse.spec.js

45 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

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({});
try {
const options = {transaction: tx};
2023-01-24 08:04:43 +00:00
const agencies = await 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};
2023-01-24 08:04:43 +00:00
const tx = await models.Zone.beginTransaction({});
try {
const options = {transaction: tx};
2023-01-24 08:04:43 +00:00
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;
}
2020-09-23 09:21:25 +00:00
});
});