From 9bd878c0150730262a7905de34fd6e69a05dd0ee Mon Sep 17 00:00:00 2001 From: Marshall Thompson Date: Wed, 11 Feb 2015 22:56:58 -0700 Subject: [PATCH] Keep tests from calling done() twice. --- test/providers/primus.test.js | 8 +++++++- test/providers/socketio.test.js | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/test/providers/primus.test.js b/test/providers/primus.test.js index ca1069e07b..4f629429fa 100644 --- a/test/providers/primus.test.js +++ b/test/providers/primus.test.js @@ -438,10 +438,16 @@ describe('Primus provider', function () { socket.send('tasks::remove', 1, {}, function() {}); socket.send('tasks::remove', 23, {}, function() {}); + var ready = false; + socket.on('tasks removed', function (data) { service.removed = oldRemoved; assert.equal(data.id, 23); - done(); + console.log('Ready: ' + ready); + if (ready) { + done(); + } + ready = true; }); }); }); diff --git a/test/providers/socketio.test.js b/test/providers/socketio.test.js index 674b73f914..f60085f262 100644 --- a/test/providers/socketio.test.js +++ b/test/providers/socketio.test.js @@ -437,10 +437,15 @@ describe('SocketIO provider', function () { socket.emit('tasks::remove', 1, {}, function() {}); socket.emit('tasks::remove', 23, {}, function() {}); + var ready = false; + socket.on('tasks removed', function (data) { service.removed = oldRemoved; assert.equal(data.id, 23); - done(); + if (ready) { + done(); + } + ready = true; }); }); });