1 | {afterEach, beforeEach, context, describe, it} = global
|
2 | {expect} = require 'chai'
|
3 | sinon = require 'sinon'
|
4 | HueManager = require '../src/hue-manager'
|
5 |
|
6 | describe 'HueManager', ->
|
7 | beforeEach ->
|
8 | @sut = new HueManager
|
9 | @sut.emit = sinon.spy @sut.emit
|
10 | sinon.stub(@sut, '_checkButtons').yields null
|
11 | @sut.verify = sinon.stub().yields null
|
12 |
|
13 | afterEach (done) ->
|
14 | @sut.close done
|
15 |
|
16 | describe '->connect', ->
|
17 | beforeEach (done) ->
|
18 | @sut.connect {}, done
|
19 |
|
20 | it 'should create a hue connection', ->
|
21 | expect(@sut.hue).to.exist
|
22 |
|
23 | it 'should update apikey', ->
|
24 | apikey =
|
25 | devicetype: 'octoblu-hue-button'
|
26 | expect(@sut.apikey).to.deep.equal apikey
|
27 |
|
28 | context 'with an active client', ->
|
29 | beforeEach (done) ->
|
30 | options =
|
31 | sensorPollInterval: 5
|
32 | sensorName: 'tapppy'
|
33 |
|
34 | @sut.connect options, (error) =>
|
35 | {@hue} = @sut
|
36 | @sut._checkButtons.restore()
|
37 | @hue.checkButtons = sinon.stub().yields null, state: 'ok', button: 'hi'
|
38 | done error
|