1 | 'use strict'
|
2 |
|
3 |
|
4 |
|
5 | const chai = require('chai')
|
6 | const sinon = require('sinon')
|
7 | chai.use(require('sinon-chai'))
|
8 |
|
9 | const expect = chai.expect
|
10 |
|
11 | const Adapter = require('../src/adapter')
|
12 |
|
13 | describe('Adapter', function () {
|
14 | beforeEach(function () {
|
15 | this.robot = {receive: sinon.spy()}
|
16 | })
|
17 |
|
18 |
|
19 | it('can load adapter by name')
|
20 |
|
21 | describe('Public API', function () {
|
22 | beforeEach(function () {
|
23 | this.adapter = new Adapter(this.robot)
|
24 | })
|
25 |
|
26 | it('assigns robot', function () {
|
27 | expect(this.adapter.robot).to.equal(this.robot)
|
28 | })
|
29 |
|
30 | describe('send', function () {
|
31 | it('is a function', function () {
|
32 | expect(this.adapter.send).to.be.a('function')
|
33 | })
|
34 |
|
35 | it('does nothing', function () {
|
36 | this.adapter.send({}, 'nothing')
|
37 | })
|
38 | })
|
39 |
|
40 | describe('reply', function () {
|
41 | it('is a function', function () {
|
42 | expect(this.adapter.reply).to.be.a('function')
|
43 | })
|
44 |
|
45 | it('does nothing', function () {
|
46 | this.adapter.reply({}, 'nothing')
|
47 | })
|
48 | })
|
49 |
|
50 | describe('topic', function () {
|
51 | it('is a function', function () {
|
52 | expect(this.adapter.topic).to.be.a('function')
|
53 | })
|
54 |
|
55 | it('does nothing', function () {
|
56 | this.adapter.topic({}, 'nothing')
|
57 | })
|
58 | })
|
59 |
|
60 | describe('play', function () {
|
61 | it('is a function', function () {
|
62 | expect(this.adapter.play).to.be.a('function')
|
63 | })
|
64 |
|
65 | it('does nothing', function () {
|
66 | this.adapter.play({}, 'nothing')
|
67 | })
|
68 | })
|
69 |
|
70 | describe('run', function () {
|
71 | it('is a function', function () {
|
72 | expect(this.adapter.run).to.be.a('function')
|
73 | })
|
74 |
|
75 | it('does nothing', function () {
|
76 | this.adapter.run()
|
77 | })
|
78 | })
|
79 |
|
80 | describe('close', function () {
|
81 | it('is a function', function () {
|
82 | expect(this.adapter.close).to.be.a('function')
|
83 | })
|
84 |
|
85 | it('does nothing', function () {
|
86 | this.adapter.close()
|
87 | })
|
88 | })
|
89 | })
|
90 |
|
91 | it('dispatches received messages to the robot', function () {
|
92 | this.robot.receive = sinon.spy()
|
93 | this.adapter = new Adapter(this.robot)
|
94 | this.message = sinon.spy()
|
95 |
|
96 | this.adapter.receive(this.message)
|
97 |
|
98 | expect(this.robot.receive).to.have.been.calledWith(this.message)
|
99 | })
|
100 | })
|