Skip to content

Commit

Permalink
Make the room destroy test more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
DamonOehlman committed Jan 15, 2015
1 parent 5e284a4 commit b2d771a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/room-leave.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,19 @@ var start = module.exports = function(test, board) {
test('close connections', cleanup(board, clients));

test('check room has been destroyed', function(t) {
var room = board.rooms.get(roomId);
var failTimer;

t.plan(1);
t.notOk(board.rooms.get(roomId), 'room has been removed');
if (! room) {
return t.pass('room has been removed');
}

failTimer = setTimeout(t.fail.bind(t, 'room not destroyed'), 500);
board.once('room:destroy', function(room) {
t.equal(room, roomId, 'room has been removed');
clearTimeout(failTimer);
});
});
};

Expand Down

0 comments on commit b2d771a

Please sign in to comment.