1781-zoneHoliday #994
|
@ -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,
|
||||
|
|
|
@ -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({});
|
||||
|
||||
|
|
Loading…
Reference in New Issue