diff --git a/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js b/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js index 86c04f844..ccd1abb80 100644 --- a/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js +++ b/modules/zone/back/methods/zone/specs/toggleIsIncluded.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); -describe('zone toggleIsIncluded()', () => { +fdescribe('zone toggleIsIncluded()', () => { beforeAll(async() => { const activeCtx = { accessToken: {userId: 9}, @@ -20,10 +20,12 @@ describe('zone toggleIsIncluded()', () => { try { const options = {transaction: tx}; + await validateSchedules('before', options); let result = await models.Zone.toggleIsIncluded(1, 20, true, options); expect(result.isIncluded).toBeTrue(); + await validateSchedules('after', options); await tx.rollback(); } catch (e) { @@ -37,10 +39,12 @@ describe('zone toggleIsIncluded()', () => { try { const options = {transaction: tx}; + await validateSchedules('before', options); let result = await models.Zone.toggleIsIncluded(1, 20, false, options); expect(result.isIncluded).toBeFalse(); + await validateSchedules('after', options); await tx.rollback(); } catch (e) { @@ -54,13 +58,14 @@ describe('zone toggleIsIncluded()', () => { try { const options = {transaction: tx}; - + await validateSchedules('before', options); await models.Zone.toggleIsIncluded(1, 20, false, options); - let result = await models.Zone.toggleIsIncluded(1, 20, undefined, options); + const result = await models.Zone.toggleIsIncluded(1, 20, undefined, options); expect(result).toEqual({count: 1}); + await validateSchedules('after', options); await tx.rollback(); } catch (e) { await tx.rollback(); @@ -68,3 +73,22 @@ describe('zone toggleIsIncluded()', () => { } }); }); + +async function validateSchedules(step, options = null) { + const querySchedules = `SELECT count(*) count FROM util.vn_schedules;`; + + switch (step) { + case 'before': { + const [{count}] = await models.Application.rawSql(querySchedules, null, options); + + expect(count).toEqual(0); + } + break; + case 'after': { + const [{count}] = await models.Application.rawSql(querySchedules, null, options); + + expect(count).toEqual(1); + } + break; + } +}