Skip to content

Commit

Permalink
Updated to count messages and connects
Browse files Browse the repository at this point in the history
  • Loading branch information
3rd-Eden committed Jul 7, 2011
1 parent ca5d229 commit 31a89ac
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
12 changes: 9 additions & 3 deletions support/test-runner/app.js
Expand Up @@ -180,9 +180,15 @@ suite('socket.test.js', function () {
}); });


server('test different namespace connection methods', function (io) { server('test different namespace connection methods', function (io) {
io.of('/a').on('connection', function (socket) {}); io.of('/a').on('connection', function (socket) {
io.of('/b').on('connection', function (socket) {}); socket.send('a');
io.of('/c').on('connection', function (socket) {}); });
io.of('/b').on('connection', function (socket) {
socket.send('b');
});
io.of('/c').on('connection', function (socket) {
socket.send('c');
});
}); });


server('test disconnecting from namespaces', function (io) { server('test disconnecting from namespaces', function (io) {
Expand Down
20 changes: 17 additions & 3 deletions test/socket.test.js
Expand Up @@ -140,28 +140,42 @@
'test different namespace connection methods': function (next) { 'test different namespace connection methods': function (next) {
var io = create('/a') var io = create('/a')
, connect = 0 , connect = 0
, message = 0
, socket = io.socket; , socket = io.socket;


function finish () { function finish () {
socket.of('').disconnect(); socket.of('').disconnect();
connect.should().equal(3); connect.should().equal(3);
message.should().equal(3);
next(); next();
} }


io.on('connect', function () { io.on('connect', function () {
if (++connect === 3) finish(); ++connect;
}).on('message', function (data) {
data.should().eql('a');

if (++message === 3) finish();
}).on('error', function (msg) { }).on('error', function (msg) {
throw new Error(msg || 'Received an error'); throw new Error(msg || 'Received an error');
}); });


socket.of('/b').on('connect', function () { socket.of('/b').on('connect', function () {
if (++connect === 3) finish(); ++connect;
}).on('message', function (data) {
data.should().eql('b');

if (++message === 3) finish();
}).on('error', function (msg) { }).on('error', function (msg) {
throw new Error(msg || 'Received an error'); throw new Error(msg || 'Received an error');
}); });


io.of('/c').on('connect', function () { io.of('/c').on('connect', function () {
if (++connect === 3) finish(); ++connect;
}).on('message', function (data) {
data.should().eql('c');

if (++message === 3) finish();
}).on('error', function (msg) { }).on('error', function (msg) {
throw new Error(msg || 'Received an error'); throw new Error(msg || 'Received an error');
}); });
Expand Down

0 comments on commit 31a89ac

Please sign in to comment.