forked from hubotio/hubot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadapter_test.js
100 lines (77 loc) · 2.26 KB
/
adapter_test.js
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
'use strict'
/* global describe, beforeEach, it */
const chai = require('chai')
const sinon = require('sinon')
chai.use(require('sinon-chai'))
const expect = chai.expect
const Adapter = require('../src/adapter')
describe('Adapter', function () {
beforeEach(function () {
this.robot = {receive: sinon.spy()}
})
// this one is hard, as it requires files
it('can load adapter by name')
describe('Public API', function () {
beforeEach(function () {
this.adapter = new Adapter(this.robot)
})
it('assigns robot', function () {
expect(this.adapter.robot).to.equal(this.robot)
})
describe('send', function () {
it('is a function', function () {
expect(this.adapter.send).to.be.a('function')
})
it('does nothing', function () {
this.adapter.send({}, 'nothing')
})
})
describe('reply', function () {
it('is a function', function () {
expect(this.adapter.reply).to.be.a('function')
})
it('does nothing', function () {
this.adapter.reply({}, 'nothing')
})
})
describe('topic', function () {
it('is a function', function () {
expect(this.adapter.topic).to.be.a('function')
})
it('does nothing', function () {
this.adapter.topic({}, 'nothing')
})
})
describe('play', function () {
it('is a function', function () {
expect(this.adapter.play).to.be.a('function')
})
it('does nothing', function () {
this.adapter.play({}, 'nothing')
})
})
describe('run', function () {
it('is a function', function () {
expect(this.adapter.run).to.be.a('function')
})
it('does nothing', function () {
this.adapter.run()
})
})
describe('close', function () {
it('is a function', function () {
expect(this.adapter.close).to.be.a('function')
})
it('does nothing', function () {
this.adapter.close()
})
})
})
it('dispatches received messages to the robot', function () {
this.robot.receive = sinon.spy()
this.adapter = new Adapter(this.robot)
this.message = sinon.spy()
this.adapter.receive(this.message)
expect(this.robot.receive).to.have.been.calledWith(this.message)
})
})