UNPKG

imubot

Version:
82 lines (57 loc) 1.86 kB
chai = require 'chai' sinon = require 'sinon' chai.use require 'sinon-chai' expect = chai.expect Adapter = require '../src/adapter.coffee' describe 'Adapter', -> beforeEach -> @bot = receive: sinon.spy() # this one is hard, as it requires files it "can load adapter by name" describe 'Public API', -> beforeEach -> @adapter = new Adapter(@bot) it 'assigns bot', -> expect(@adapter.bot).to.equal(@bot) 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 bot', -> @bot.receive = sinon.spy() @adapter = new Adapter(@bot) @message = sinon.spy() @adapter.receive(@message) expect(@bot.receive).to.have.been.calledWith(@message)