-
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.
- Loading branch information
Showing
7 changed files
with
8,505 additions
and
8,347 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* eslint-disable no-undef */ | ||
const expect = require('chai').expect; | ||
const tools = require('../lib/tools'); | ||
|
||
const datapoints = { | ||
'gatebox#command.move': { | ||
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' }, | ||
}, | ||
}, | ||
}; | ||
|
||
const fruits = []; | ||
fruits.push('banana', 'apple', 'peach'); | ||
|
||
describe('Test isObject', function () { | ||
it('expect false', function () { | ||
expect(tools.isObject(null)).to.be.false; | ||
}); | ||
|
||
it('expect true', function () { | ||
expect(tools.isObject(['true', 'true'])).to.be.false; | ||
}); | ||
|
||
it('expect true', function () { | ||
expect(tools.isObject(datapoints)).to.be.true; | ||
}); | ||
}); | ||
|
||
describe('Test isArray', function () { | ||
it('expect true', function () { | ||
expect(tools.isArray(fruits)).to.be.true; | ||
}); | ||
|
||
it('expect true', function () { | ||
expect(tools.isArray(['true', 'true'])).to.be.true; | ||
}); | ||
|
||
it('expect false', function () { | ||
expect(tools.isArray(datapoints)).to.be.false; | ||
}); | ||
}); |
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
Oops, something went wrong.