-
Notifications
You must be signed in to change notification settings - Fork 40
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 #53 from davidalpert/message-room
feat: add ability to test robot.messageRoom(...)
- Loading branch information
Showing
4 changed files
with
99 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
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,33 @@ | ||
'use strict' | ||
|
||
const Helper = require('../src/index'); | ||
const helper = new Helper('./scripts/message-room.js'); | ||
|
||
const co = require('co'); | ||
const expect = require('chai').expect; | ||
|
||
describe('message-room', function() { | ||
beforeEach(function() { | ||
this.room = helper.createRoom({name: 'room', httpd: false}); | ||
}); | ||
|
||
context('user asks hubot to announce something', function() { | ||
beforeEach(function() { | ||
return co(function*() { | ||
yield this.room.user.say('alice', '@hubot announce otherRoom: I love hubot!'); | ||
}.bind(this)); | ||
}); | ||
|
||
it('should not post to this channel', function() { | ||
expect(this.room.messages).to.eql([ | ||
['alice', '@hubot announce otherRoom: I love hubot!'] | ||
]); | ||
}); | ||
|
||
it('should post to the other channel', function() { | ||
expect(this.room.robot.messagesTo['otherRoom']).to.eql([ | ||
['hubot', '@alice says: I love hubot!'] | ||
]); | ||
}); | ||
}); | ||
}); |
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,6 @@ | ||
// Description: | ||
// Test script | ||
module.exports = robot => | ||
robot.respond(/announce otherRoom: (.+)$/i, msg => { | ||
robot.messageRoom('otherRoom', '@' + msg.envelope.user.name + ' says: ' + msg.match[1]); | ||
}) |