From 2cc85b2c9eb1d7023c7c5071323b5731ebbde9a5 Mon Sep 17 00:00:00 2001 From: euguuu Date: Thu, 29 Sep 2022 22:26:40 +0200 Subject: [PATCH] fix test --- .../lib/device/device.destroyByServiceId.test.js | 4 +++- .../lib/device/device.saveHistoricalState.test.js | 12 +++++++++--- server/test/lib/device/device.setParam.test.js | 6 +++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/server/test/lib/device/device.destroyByServiceId.test.js b/server/test/lib/device/device.destroyByServiceId.test.js index 7b3c432289..0ac42e2e0b 100644 --- a/server/test/lib/device/device.destroyByServiceId.test.js +++ b/server/test/lib/device/device.destroyByServiceId.test.js @@ -5,9 +5,11 @@ const { assert } = require('chai'); const Device = require('../../../lib/device'); const StateManager = require('../../../lib/state'); const ServiceManager = require('../../../lib/service'); +const Job = require('../../../lib/job'); const db = require('../../../models'); const event = new EventEmitter(); +const job = new Job(event); const serviceName = 'fake-service'; describe('Device', () => { @@ -42,7 +44,7 @@ describe('Device', () => { it('should destroy device', async () => { const serviceManager = new ServiceManager({}, stateManager); - const device = new Device(event, {}, stateManager, serviceManager); + const device = new Device(event, {}, stateManager, serviceManager, {}, {}, job); await device.create({ name: 'test-device-destroyByServiceId', external_id: 'test-device-new-destroyByServiceId', diff --git a/server/test/lib/device/device.saveHistoricalState.test.js b/server/test/lib/device/device.saveHistoricalState.test.js index dfa33786b0..2f35f78323 100644 --- a/server/test/lib/device/device.saveHistoricalState.test.js +++ b/server/test/lib/device/device.saveHistoricalState.test.js @@ -2,9 +2,12 @@ const EventEmitter = require('events'); const { assert, expect } = require('chai'); const Device = require('../../../lib/device'); const StateManager = require('../../../lib/state'); +const ServiceManager = require('../../../lib/service'); +const Job = require('../../../lib/job'); const { BadParameters } = require('../../../utils/coreErrors'); const event = new EventEmitter(); +const job = new Job(event); describe('Device saveHistoricalState', () => { it('should save historical sate (new state)', async () => { @@ -36,7 +39,8 @@ describe('Device saveHistoricalState', () => { }); stateManager.setState('deviceFeature', 'test-feature', testFeature); - const device = new Device(event, {}, stateManager); + const serviceManager = new ServiceManager({}, stateManager); + const device = new Device(event, {}, stateManager, serviceManager, {}, {}, job); const testDevice = await device.getBySelector('test-device'); const deviceFeature = testDevice.features[0]; @@ -74,7 +78,8 @@ describe('Device saveHistoricalState', () => { }); stateManager.setState('deviceFeature', 'test-feature', testFeature); - const device = new Device(event, {}, stateManager); + const serviceManager = new ServiceManager({}, stateManager); + const device = new Device(event, {}, stateManager, serviceManager, {}, {}, job); const testDevice = await device.getBySelector('test-device'); const deviceFeature = testDevice.features[0]; @@ -88,7 +93,8 @@ describe('Device saveHistoricalState', () => { it('should not save NaN as state', async () => { const stateManager = new StateManager(event); - const device = new Device(event, {}, stateManager); + const serviceManager = new ServiceManager({}, stateManager); + const device = new Device(event, {}, stateManager, serviceManager, {}, {}, job); const nanValue = parseInt('NaN value', 10); diff --git a/server/test/lib/device/device.setParam.test.js b/server/test/lib/device/device.setParam.test.js index ab007a2389..9fc728405a 100644 --- a/server/test/lib/device/device.setParam.test.js +++ b/server/test/lib/device/device.setParam.test.js @@ -2,14 +2,18 @@ const EventEmitter = require('events'); const { assert } = require('chai'); const Device = require('../../../lib/device'); const StateManager = require('../../../lib/state'); +const ServiceManager = require('../../../lib/service'); +const Job = require('../../../lib/job'); const event = new EventEmitter(); +const job = new Job(event); describe('Device', () => { it('save test param', async () => { const stateManager = new StateManager(event); - const device = new Device(event, {}, stateManager); + const serviceManager = new ServiceManager({}, stateManager); + const device = new Device(event, {}, stateManager, serviceManager, {}, {}, job); let testDevice = await device.get({ search: 'test' }); await device.setParam(testDevice[0], 'testParamName', 'testParamValue'); await device.setParam(testDevice[0], 'testParamName2', 'testParamValue2');