Browse files

Updated to count messages and connects

  • Loading branch information...
1 parent ca5d229 commit 31a89ac23289f17153d40f50a7b358d686654b56 @3rd-Eden 3rd-Eden committed Jul 8, 2011
Showing with 26 additions and 6 deletions.
  1. +9 −3 support/test-runner/app.js
  2. +17 −3 test/socket.test.js
View
12 support/test-runner/app.js
@@ -180,9 +180,15 @@ suite('socket.test.js', function () {
});
server('test different namespace connection methods', function (io) {
- io.of('/a').on('connection', function (socket) {});
- io.of('/b').on('connection', function (socket) {});
- io.of('/c').on('connection', function (socket) {});
+ io.of('/a').on('connection', function (socket) {
+ socket.send('a');
+ });
+ 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) {
View
20 test/socket.test.js
@@ -140,28 +140,42 @@
'test different namespace connection methods': function (next) {
var io = create('/a')
, connect = 0
+ , message = 0
, socket = io.socket;
function finish () {
socket.of('').disconnect();
connect.should().equal(3);
+ message.should().equal(3);
next();
}
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) {
throw new Error(msg || 'Received an error');
});
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) {
throw new Error(msg || 'Received an error');
});
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) {
throw new Error(msg || 'Received an error');
});

0 comments on commit 31a89ac

Please sign in to comment.