forked from hubotio/hubot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
adapter_test.coffee
81 lines (57 loc) · 1.83 KB
/
adapter_test.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
chai = require 'chai'
sinon = require 'sinon'
chai.use require 'sinon-chai'
expect = chai.expect
Adapter = require '../src/adapter.coffee'
describe 'Adapter', ->
beforeEach ->
@robot =
receive: sinon.spy()
# this one is hard, as it requires files
it "can load adapter by name"
describe 'Public API', ->
beforeEach ->
@adapter = new Adapter(@robot)
it 'assigns robot', ->
expect(@adapter.robot).to.equal(@robot)
describe 'send', ->
it 'is a function', ->
expect(@adapter.send).to.be.a('function')
it 'does nothing', ->
@adapter.send({}, 'nothing')
describe 'reply', ->
it 'is a function', ->
expect(@adapter.reply).to.be.a('function')
it 'does nothing', ->
@adapter.reply({}, 'nothing')
describe 'topic', ->
it 'is a function', ->
expect(@adapter.topic).to.be.a('function')
it 'does nothing', ->
@adapter.topic({}, 'nothing')
describe 'topic', ->
it 'is a function', ->
expect(@adapter.topic).to.be.a('function')
it 'does nothing', ->
@adapter.topic({}, 'nothing')
describe 'play', ->
it 'is a function', ->
expect(@adapter.play).to.be.a('function')
it 'does nothing', ->
@adapter.play({}, 'nothing')
describe 'run', ->
it 'is a function', ->
expect(@adapter.run).to.be.a('function')
it 'does nothing', ->
@adapter.run()
describe 'close', ->
it 'is a function', ->
expect(@adapter.close).to.be.a('function')
it 'does nothing', ->
@adapter.close()
it 'dispatches received messages to the robot', ->
@robot.receive = sinon.spy()
@adapter = new Adapter(@robot)
@message = sinon.spy()
@adapter.receive(@message)
expect(@robot.receive).to.have.been.calledWith(@message)