From b2d771a965b29f1569d1ef10f5bf99284b89f5ae Mon Sep 17 00:00:00 2001 From: Damon Oehlman Date: Thu, 15 Jan 2015 19:05:15 +1100 Subject: [PATCH] Make the room destroy test more robust --- test/room-leave.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/room-leave.js b/test/room-leave.js index a93a571..f7edd27 100644 --- a/test/room-leave.js +++ b/test/room-leave.js @@ -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); + }); }); };