1781-zoneHoliday #994

Merged
joan merged 49 commits from 1781-zoneHoliday into dev 2022-08-03 06:41:31 +00:00
2 changed files with 22 additions and 1 deletions
Showing only changes of commit f6ab9d8a31 - Show all commits

View File

@ -39,7 +39,7 @@ module.exports = Self => {
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!geoIds.lenght) throw new Error(`You must select a location`);
if (!geoIds[0]) throw new UserError(`You must select a location`);
const newZoneExclusion = await models.ZoneExclusion.create({
zoneFk: zoneFk,

View File

@ -1,6 +1,27 @@
const models = require('vn-loopback/server/server').models;
describe('zone exclusionGeo()', () => {
it(`should show an error when location isn't selected`, async() => {
const tx = await models.Zone.beginTransaction({});
try {
const options = {transaction: tx};
const today = new Date();
const zoneId = 1;
const geoIds = [];
const result = await models.Zone.exclusionGeo(zoneId, today, geoIds, options);
expect(result.length).toEqual(2);
await tx.rollback();
} catch (e) {
await tx.rollback();
error = e;
}
expect(error.message).toContain(`You must select a location`);
});
it('should create two exclusion by geo', async() => {
const tx = await models.Zone.beginTransaction({});