-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from bartfeenstra/fix-pm
Fix broken private messages, and increase code coverage
- Loading branch information
Showing
3 changed files
with
64 additions
and
7 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
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
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,58 @@ | ||
'use strict' | ||
|
||
/* global describe, beforeEach, afterEach, it, context */ | ||
|
||
const chai = require('chai') | ||
const expect = chai.expect | ||
|
||
chai.use(require('sinon-chai')) | ||
|
||
const Helper = require('hubot-test-helper') | ||
|
||
const helper = new Helper('../src/help.js') | ||
|
||
describe('help', () => describe('message visibility', () => { | ||
beforeEach(function () { | ||
this.timeout(5000) | ||
this.room = helper.createRoom() | ||
}) | ||
|
||
afterEach(function () { | ||
this.room.destroy() | ||
}) | ||
|
||
context('when HUBOT_HELP_REPLY_IN_PRIVATE is unset', () => it('replies in the same room', function (done) { | ||
this.room.user.say('john', '@hubot help help').then(() => { | ||
expect(this.room.messages).to.eql([ | ||
['john', '@hubot help help'], | ||
['hubot', 'hubot help - Displays all of the help commands that this bot knows about.\nhubot help <query> - Displays all help commands that match <query>.'] | ||
]) | ||
}).then(done, done) | ||
})) | ||
})) | ||
|
||
describe('help', () => describe('message visibility', () => { | ||
beforeEach(function () { | ||
process.env.HUBOT_HELP_REPLY_IN_PRIVATE = true | ||
this.room = helper.createRoom() | ||
}) | ||
|
||
afterEach(function () { | ||
delete process.env.HUBOT_HELP_REPLY_IN_PRIVATE | ||
this.room.destroy() | ||
}) | ||
|
||
context('when HUBOT_HELP_REPLY_IN_PRIVATE is set', () => it('replies in a private message', function (done) { | ||
this.room.user.say('john', '@hubot help help').then(() => { | ||
expect(this.room.messages).to.eql([ | ||
['john', '@hubot help help'], | ||
['hubot', '@john I just replied to you in private.'] | ||
]) | ||
expect(this.room.privateMessages).to.eql({ | ||
john: [ | ||
['hubot', 'hubot help - Displays all of the help commands that this bot knows about.\nhubot help <query> - Displays all help commands that match <query>.'] | ||
] | ||
}) | ||
}).then(done, done) | ||
})) | ||
})) |