Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
euguuu committed Sep 29, 2022
1 parent 750dd74 commit 2cc85b2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
4 changes: 3 additions & 1 deletion server/test/lib/device/device.destroyByServiceId.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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',
Expand Down
12 changes: 9 additions & 3 deletions server/test/lib/device/device.saveHistoricalState.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand All @@ -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);

Expand Down
6 changes: 5 additions & 1 deletion server/test/lib/device/device.setParam.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 2cc85b2

Please sign in to comment.