1 | Connector = require '../'
|
2 |
|
3 | describe 'Connector', ->
|
4 | beforeEach (done) ->
|
5 | @sut = new Connector
|
6 | {@hue} = @sut
|
7 | @hue.connect = sinon.stub().yields null
|
8 | @sut.start {}, done
|
9 |
|
10 | afterEach (done) ->
|
11 | @sut.close done
|
12 |
|
13 | it 'should call connect', ->
|
14 | expect(@hue.connect).to.have.been.called
|
15 |
|
16 | describe 'on change:username', ->
|
17 | beforeEach ->
|
18 | @sut.emit = sinon.stub()
|
19 | apikey =
|
20 | some: 'thing'
|
21 |
|
22 | @hue.emit 'change:username', {apikey}
|
23 |
|
24 | it 'should emit update', ->
|
25 | apikey =
|
26 | some: 'thing'
|
27 | expect(@sut.emit).to.have.been.calledWith 'update', {apikey}
|
28 |
|
29 | describe 'on click', ->
|
30 | beforeEach ->
|
31 | @sut.emit = sinon.stub()
|
32 | @hue.emit 'click', button: 'tapppy', state: 'arizona'
|
33 |
|
34 | it 'should emit update', ->
|
35 | data =
|
36 | action: 'click'
|
37 | button: 'tapppy'
|
38 | state: 'arizona'
|
39 | device: {}
|
40 | expect(@sut.emit).to.have.been.calledWith 'message', {devices: ['*'], data}
|
41 |
|
42 | describe '->isOnline', ->
|
43 | it 'should yield running true', (done) ->
|
44 | @sut.isOnline (error, response) =>
|
45 | return done error if error?
|
46 | expect(response.running).to.be.true
|
47 | done()
|
48 |
|
49 | describe '->onConfig', ->
|
50 | beforeEach (done) ->
|