test: don't rely on setTimeout in testClientStop()

This commit is contained in:
Feross Aboukhadijeh 2017-01-20 18:33:17 -08:00
parent ee45b7947b
commit 1424a00c3a

View File

@ -56,7 +56,7 @@ test('ws: client.start()', function (t) {
}) })
function testClientStop (t, serverType) { function testClientStop (t, serverType) {
t.plan(3) t.plan(4)
common.createServer(t, serverType, function (server, announceUrl) { common.createServer(t, serverType, function (server, announceUrl) {
var client = new Client({ var client = new Client({
@ -73,7 +73,9 @@ function testClientStop (t, serverType) {
client.start() client.start()
setTimeout(function () { client.once('update', function () {
t.pass('client received response to "start" message')
client.stop() client.stop()
client.once('update', function (data) { client.once('update', function (data) {
@ -85,7 +87,7 @@ function testClientStop (t, serverType) {
server.close() server.close()
client.destroy() client.destroy()
}) })
}, 1000) })
}) })
} }