-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #236 from ka-vaNu/231-add-tests
231 add tests
- Loading branch information
Showing
20 changed files
with
8,799 additions
and
8,354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* eslint-disable no-undef */ | ||
'use strict'; | ||
const gatebox = require('./gatebox'); | ||
|
||
const { expect } = require('chai'); | ||
|
||
const datapointMoveCommand = { | ||
path: 'command.move', | ||
type: 'state', | ||
common: { | ||
name: 'primary action (p), secondary action (s), open (o), close (c)', | ||
type: 'string', | ||
role: 'text', | ||
read: true, | ||
write: true, | ||
states: { p: 'Primary', s: 'Secondary', o: 'Open', c: 'Close' }, | ||
}, | ||
}; | ||
|
||
describe('test gatebox.getDatapoints', () => { | ||
const result = gatebox.datapoints; | ||
it(`expect command.move object`, () => { | ||
expect(JSON.stringify(result['gatebox#command.move'])).to.equal(JSON.stringify(datapointMoveCommand)); | ||
}); | ||
}); | ||
|
||
describe('test gatebox.getApiUrl', () => { | ||
it('expect correct URL', () => { | ||
const result = '/state/extended'; | ||
expect(gatebox.getApiUrl('gateExtendedState')).to.be.equal(result); | ||
}); | ||
it('expect false on unsupported call', () => { | ||
expect(gatebox.getApiUrl('notExisting')).to.be.false; | ||
}); | ||
}); | ||
|
||
describe('test gatebox.getDeviceTypeMapping', () => { | ||
it('expect supported devices by this API', () => { | ||
const result = { | ||
gatebox: 'gatebox', | ||
}; | ||
|
||
expect(JSON.stringify(gatebox.getDeviceTypeMapping())).to.be.equal(JSON.stringify(result)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* eslint-disable no-undef */ | ||
'use strict'; | ||
const multisensor = require('./multisensor'); | ||
|
||
const { expect } = require('chai'); | ||
|
||
const datapointElapsedTimeS = { | ||
path: 'multiSensor.sensors.0.elapsedTimeS', | ||
type: 'state', | ||
common: { | ||
name: 'Time in seconds that has elapsed since last valid measurement occurred, where -1 = Error, 0 = Fresh data', | ||
type: 'number', | ||
role: 'value', | ||
read: true, | ||
write: false, | ||
}, | ||
}; | ||
|
||
describe('test multisensor.getDatapoints', () => { | ||
const result = multisensor.datapoints; | ||
it(`expect command.move object`, () => { | ||
expect(JSON.stringify(result['multisensor#multiSensor.sensors[0].elapsedTimeS'])).to.equal( | ||
JSON.stringify(datapointElapsedTimeS), | ||
); | ||
}); | ||
}); | ||
|
||
describe('test multisensor.getApiUrl', () => { | ||
it('expect correct URL', () => { | ||
const result = '/state/extended'; | ||
expect(multisensor.getApiUrl('multisensorExtendedState')).to.be.equal(result); | ||
}); | ||
it('expect false on unsupported call', () => { | ||
expect(multisensor.getApiUrl('notExisting')).to.be.false; | ||
}); | ||
}); | ||
|
||
describe('test multisensor.getDeviceTypeMapping', () => { | ||
it('expect supported devices by this API', () => { | ||
const result = { | ||
multisensor: 'multisensor', | ||
tempSensor_PRO: 'multisensor', | ||
tempSensorAC: 'multisensor', | ||
humiditySensor: 'multisensor', | ||
windSensor_PRO: 'multisensor', | ||
rainSensor: 'multisensor', | ||
floodSensor: 'multisensor', | ||
}; | ||
|
||
expect(JSON.stringify(multisensor.getDeviceTypeMapping())).to.be.equal(JSON.stringify(result)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* eslint-disable no-undef */ | ||
'use strict'; | ||
const saunabox = require('./saunabox'); | ||
|
||
const { expect } = require('chai'); | ||
|
||
const datapointDesiredTemp = { | ||
path: 'command.desiredTemp', | ||
type: 'state', | ||
common: { | ||
name: 'temperature in celsius. It should be value between max&min from settings', | ||
type: 'number', | ||
role: 'value', | ||
read: true, | ||
write: true, | ||
}, | ||
}; | ||
|
||
describe('test saunabox.getDatapoints', () => { | ||
const result = saunabox.datapoints; | ||
it(`expect saunabox#command.desiredTemp object`, () => { | ||
expect(JSON.stringify(result['saunabox#command.desiredTemp'])).to.equal(JSON.stringify(datapointDesiredTemp)); | ||
}); | ||
}); | ||
|
||
describe('test saunabox.getApiUrl', () => { | ||
it('expect correct URL', () => { | ||
const result = '/api/heat/extended/state'; | ||
expect(saunabox.getApiUrl('saunaboxExtendedState')).to.be.equal(result); | ||
}); | ||
it('expect false on unsupported call', () => { | ||
expect(saunabox.getApiUrl('notExisting')).to.be.false; | ||
}); | ||
}); | ||
|
||
describe('test saunabox.getDeviceTypeMapping', () => { | ||
it('expect supported devices by this API', () => { | ||
const result = { | ||
saunabox: 'saunabox', | ||
}; | ||
|
||
expect(JSON.stringify(saunabox.getDeviceTypeMapping())).to.be.equal(JSON.stringify(result)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* eslint-disable no-undef */ | ||
'use strict'; | ||
const shutterbox = require('./shutterbox'); | ||
|
||
const { expect } = require('chai'); | ||
|
||
const datapointMoveCommand = { | ||
path: 'command.move', | ||
type: 'state', | ||
common: { | ||
name: 'move up (u), down (d), stop (s)', | ||
type: 'string', | ||
role: 'text', | ||
read: true, | ||
write: true, | ||
states: { u: 'Up', d: 'Down', s: 'Stop' }, | ||
}, | ||
}; | ||
|
||
describe('test shutterbox.getDatapoints', () => { | ||
const result = shutterbox.datapoints; | ||
it(`expect command.move object`, () => { | ||
expect(JSON.stringify(result['shutterbox#command.move'])).to.equal(JSON.stringify(datapointMoveCommand)); | ||
}); | ||
}); | ||
|
||
describe('test shutterbox.getApiUrl', () => { | ||
it('expect correct URL', () => { | ||
const result = '/api/shutter/extended/state'; | ||
expect(shutterbox.getApiUrl('shutterExtendedState')).to.be.equal(result); | ||
}); | ||
|
||
it('expect false on unsupported call', () => { | ||
expect(shutterbox.getApiUrl('notExisting')).to.be.false; | ||
}); | ||
}); | ||
|
||
describe('test shutterbox.getDeviceTypeMapping', () => { | ||
it('expect supported devices by this API', () => { | ||
const result = { | ||
shutterbox: 'shutterbox', | ||
shutterboxDC: 'shutterbox', | ||
shutterboxDIN: 'shutterbox', | ||
}; | ||
|
||
expect(JSON.stringify(shutterbox.getDeviceTypeMapping())).to.be.equal(JSON.stringify(result)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* eslint-disable no-undef */ | ||
'use strict'; | ||
const switchbox = require('./switchbox'); | ||
|
||
const { expect } = require('chai'); | ||
|
||
const datapointRelayCommand = { | ||
path: 'command.relay', | ||
type: 'state', | ||
common: { | ||
name: 'set state off (0) or on (1) or toggle (2)', | ||
type: 'string', | ||
role: 'text', | ||
read: true, | ||
write: true, | ||
states: { 0: 'Off', 1: 'On', 2: 'Toggle' }, | ||
}, | ||
}; | ||
|
||
describe('test switchbox.getDatapoints', () => { | ||
const result = switchbox.datapoints; | ||
it(`expect command.move object`, () => { | ||
expect(JSON.stringify(result['switchbox#command.relay'])).to.equal(JSON.stringify(datapointRelayCommand)); | ||
}); | ||
}); | ||
|
||
describe('test switchbox.getApiUrl', () => { | ||
it('expect correct URL', () => { | ||
const result = '/state/extended'; | ||
expect(switchbox.getApiUrl('switchExtendedState')).to.be.equal(result); | ||
}); | ||
|
||
it('expect false on unsupported call', () => { | ||
expect(switchbox.getApiUrl('notExisting')).to.be.false; | ||
}); | ||
}); | ||
|
||
describe('test switchbox.getDeviceTypeMapping', () => { | ||
it('expect supported devices by this API', () => { | ||
const result = { | ||
switchbox: 'switchbox', | ||
switchBoxD: 'switchbox', | ||
switchBoxDC: 'switchbox', | ||
switchBox_DIN: 'switchbox', | ||
switchBoxD_DIN: 'switchbox', | ||
switchBoxT_PRO: 'switchbox', | ||
}; | ||
|
||
expect(JSON.stringify(switchbox.getDeviceTypeMapping())).to.be.equal(JSON.stringify(result)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* eslint-disable no-undef */ | ||
'use strict'; | ||
const tempsensor = require('./tempsensor'); | ||
|
||
const { expect } = require('chai'); | ||
|
||
const datapointElapsedTimeS = { | ||
path: 'tempSensor.sensors.0.elapsedTimeS', | ||
type: 'state', | ||
common: { | ||
name: 'Time in seconds that has elapsed since last valid measurement occurred, where -1 = Error, 0 = Fresh data', | ||
type: 'number', | ||
role: 'value', | ||
read: true, | ||
write: false, | ||
}, | ||
}; | ||
|
||
describe('test tempsensor.getDatapoints', () => { | ||
const result = tempsensor.datapoints; | ||
it(`expect command.move object`, () => { | ||
expect(JSON.stringify(result['tempsensor#tempSensor.sensors[0].elapsedTimeS'])).to.equal( | ||
JSON.stringify(datapointElapsedTimeS), | ||
); | ||
}); | ||
}); | ||
|
||
describe('test tempsensor.getApiUrl', () => { | ||
it('expect correct URL', () => { | ||
const result = '/api/tempsensor/state'; | ||
expect(tempsensor.getApiUrl('tempsensorExtendedState')).to.be.equal(result); | ||
}); | ||
it('expect false on unsupported call', () => { | ||
expect(tempsensor.getApiUrl('notExisting')).to.be.false; | ||
}); | ||
}); | ||
|
||
describe('test tempsensor.getDeviceTypeMapping', () => { | ||
it('expect supported devices by this API', () => { | ||
const result = { | ||
tempsensor: 'tempsensor', | ||
}; | ||
|
||
expect(JSON.stringify(tempsensor.getDeviceTypeMapping())).to.be.equal(JSON.stringify(result)); | ||
}); | ||
}); |
Oops, something went wrong.