-
-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…507) * feat: support dinamically set min_temp and max_temp in climate #445 * fix: use max/min value instead of topic * use function to retrieve value * add test Co-authored-by: Chris Nesbitt-Smith <chris@cns.me.uk>
- Loading branch information
1 parent
f3e6456
commit 460ba97
Showing
2 changed files
with
80 additions
and
0 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,60 @@ | ||
const chai = require('chai') | ||
const rewire = require('rewire') | ||
chai.use(require('sinon-chai')) | ||
chai.should() | ||
|
||
const mod = rewire('../../lib/Gateway') | ||
|
||
describe('#Gateway', () => { | ||
describe('#setDiscoveryValue()', () => { | ||
let untouchedPayload | ||
const func = mod.__get__('setDiscoveryValue') | ||
let payload | ||
const node = { | ||
values: { | ||
c: { value: 'a' }, | ||
d: { value: null }, | ||
e: false | ||
} | ||
} | ||
beforeEach(() => { | ||
payload = { | ||
a: 1, | ||
b: 'c', | ||
c: 'd', | ||
d: 'e' | ||
} | ||
untouchedPayload = JSON.parse(JSON.stringify(payload)) | ||
}) | ||
|
||
describe('payload prop not string', () => { | ||
it('should not change payload', () => { | ||
func(payload, 'a', node) | ||
payload.should.deep.equal(untouchedPayload) | ||
}) | ||
}) | ||
describe('no valueId', () => { | ||
it('should not change payload', () => { | ||
func(payload, 'd', node) | ||
payload.should.deep.equal(untouchedPayload) | ||
}) | ||
}) | ||
describe('no valueId.value', () => { | ||
it('should not change payload', () => { | ||
func(payload, 'c', node) | ||
payload.should.deep.equal(untouchedPayload) | ||
}) | ||
}) | ||
describe('happy path', () => { | ||
it('should not change payload', () => { | ||
func(payload, 'b', node) | ||
payload.should.deep.equal({ | ||
a: 1, | ||
b: 'a', | ||
c: 'd', | ||
d: 'e' | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) |