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
25 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,25 @@ | ||
var io = require('socket.io-client') | ||
, should = require('should') | ||
, chat = require('../lib/chat'); | ||
|
||
describe('chat', function() { | ||
var port = 8081; | ||
it('notifies the users when someone joins the chat') { | ||
var server = chat(port); | ||
var joe = io.connect('http://localhost:' + port); | ||
var jon = io.connect('http://localhost:' + port); | ||
|
||
// we're done after joe and jon are both notified | ||
var notification = 0; | ||
function joined(data) { | ||
notification += 1; | ||
data.username.should.equal('jane'); | ||
if (notification == 2) done(); | ||
} | ||
|
||
joe.on('joined', joined); | ||
jon.on('joined', joined); | ||
var jane = io.connect('http://localhost:' + port); | ||
jane.emit('joined', {username: 'jane'}); | ||
}); | ||
}); |