forked from hubotio/hubot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for the respond listener to confirm that the robot responds…
… to ^<name> and ^@<name> messages.
- Loading branch information
Showing
3 changed files
with
27 additions
and
3 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 |
---|---|---|
|
@@ -8,7 +8,7 @@ server = require('http').createServer (req, res) -> | |
res.end "fetched" | ||
|
||
server.listen 9001, -> | ||
assert.equal 6, helper.listeners.length | ||
assert.equal 7, helper.listeners.length | ||
assert.equal 0, helper.sent.length | ||
|
||
helper.adapter.receive 'test' | ||
|
@@ -23,7 +23,6 @@ server.listen 9001, -> | |
assert.equal 3, helper.sent.length | ||
assert.ok helper.sent[2].match(/^(1|2)$/) | ||
|
||
|
||
# Test that when we message a room, the 'recipient' is the robot user and the room attribute is set properly | ||
helper.messageRoom "[email protected]", "Hello room" | ||
assert.equal 4, helper.sent.length | ||
|
@@ -35,11 +34,32 @@ server.listen 9001, -> | |
assert.equal "[email protected]", helper.recipients[4].room | ||
assert.equal "Hello to another room", helper.sent[4] | ||
|
||
|
||
helper.adapter.receive 'foobar' | ||
assert.equal 6, helper.sent.length | ||
assert.equal 'catch-all', helper.sent[5] | ||
|
||
# Testing replies | ||
# ============================ | ||
# Using just the name | ||
helper.adapter.receive "#{helper.name} rsvp" | ||
assert.equal 7, helper.sent.length | ||
assert.equal "responding", helper.sent[6] | ||
|
||
# Using name with @ form | ||
helper.adapter.receive "@#{helper.name} rsvp" | ||
assert.equal 8, helper.sent.length | ||
assert.equal "responding", helper.sent[7] | ||
|
||
# Using just the alias | ||
helper.adapter.receive "#{helper.alias} rsvp" | ||
assert.equal 9, helper.sent.length | ||
assert.equal "responding", helper.sent[8] | ||
|
||
# Using alias with @ form | ||
helper.adapter.receive "@#{helper.alias} rsvp" | ||
assert.equal 10, helper.sent.length | ||
assert.equal "responding", helper.sent[9] | ||
|
||
|
||
# set a callback for when the next message is replied to | ||
helper.cb = (msg) -> | ||
|
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