-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/*jslint node: true */ | ||
/*jshint esversion: 6 */ | ||
|
||
'use strict'; | ||
|
||
/* global describe, beforeEach, it */ | ||
|
||
const chai = require('chai'); | ||
const sinon = require('sinon'); | ||
chai.use(require('sinon-chai')); | ||
|
||
const expect = chai.expect; | ||
|
||
const HubotIrc = require('../lib/irc'); | ||
|
||
describe('IrcBot', 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 = HubotIrc.use(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 = HubotIrc.use(this.robot); | ||
this.message = sinon.spy(); | ||
|
||
this.adapter.receive(this.message); | ||
|
||
expect(this.robot.receive).to.have.been.calledWith(this.message); | ||
}); | ||
}); |