Skip to content

Commit

Permalink
closes #57
Browse files Browse the repository at this point in the history
  • Loading branch information
incompl committed Nov 27, 2013
1 parent 765bd25 commit 45784c9
Showing 1 changed file with 73 additions and 1 deletion.
74 changes: 73 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -840,13 +840,37 @@ module.exports = _.extend(suite, {

},

// unit test for server messageAll.
roomAge: function(test) {

var server = this.server;

test.expect(2);

server.configure({
port: this.port
});

server.run();

var room = server.createRoom();

test.ok(room.age() < 100);

setTimeout(function() {
test.ok(room.age() >= 100);
test.done();
}, 100);

},

messageAll: function(test) {
var server = this.server;
var client1 = suite.createClient();
var client2 = suite.createClient();
var messages = 2;

test.expect(2);

server.configure({
port: this.port,
autoJoinLobby: true,
Expand All @@ -855,6 +879,7 @@ module.exports = _.extend(suite, {
var helloHandler = function(data) {
if (data === 'world') {
messages--;
test.ok(true);
if (messages === 0) {
test.done();
}
Expand Down Expand Up @@ -882,6 +907,53 @@ module.exports = _.extend(suite, {
}, 50);
},

messageMembers: function(test) {
var server = this.server;
var client1 = suite.createClient();
var client2 = suite.createClient();
var messages = 1;

test.expect(1);

server.configure({
port: this.port,
autoJoinLobby: true,
});

var helloHandler = function(data) {
if (data === 'world') {
messages--;
test.ok(true);
if (messages === 0) {
test.done();
}
}
};

client1.configure({
messages: {
hello: helloHandler
}
});

client2.configure({
messages: {
hello: helloHandler
}
});

server.run();
client1.run(this.host);
client2.run(this.host);

setTimeout(function() {
var room = server.createRoom();
var user = server.getUsers()[0];
room.addMember(user);
room.messageMembers('hello', 'world');
}, 50);
},

notifyRoomChanges: function(test) {

var server = this.server;
Expand Down

0 comments on commit 45784c9

Please sign in to comment.