Skip to content

Commit

Permalink
add first socket.io test
Browse files Browse the repository at this point in the history
  • Loading branch information
dmcaulay committed May 15, 2012
1 parent 38b39b2 commit 12ecff1
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/chat-test.js
@@ -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'});
});
});

0 comments on commit 12ecff1

Please sign in to comment.