From e7311062793fea1958da4fc9c579777a24a14982 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Wed, 8 Feb 2017 13:11:35 -0800 Subject: [PATCH] test: ensure electron-webrtc is started only for test where it's needed before this change, it was getting initialized immediately, since it was outside a tape test block --- test/server.js | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/test/server.js b/test/server.js index 099b403..3470537 100644 --- a/test/server.js +++ b/test/server.js @@ -2,12 +2,9 @@ var Buffer = require('safe-buffer').Buffer var Client = require('../') var common = require('./common') var test = require('tape') -var wrtc = require('electron-webrtc')() +var electronWebrtc = require('electron-webrtc') -var wrtcReady = false -wrtc.electronDaemon.once('ready', function () { - wrtcReady = true -}) +var wrtc var infoHash = '4cb67059ed6bd08362da625b3ae77f6f4a075705' var peerId = Buffer.from('01234567890123456789') @@ -177,15 +174,11 @@ test('udp server', function (t) { }) test('ws server', function (t) { - if (wrtcReady) { - runTest() - } else { - wrtc.electronDaemon.once('ready', runTest) - } - function runTest () { - t.once('end', function () { - wrtc.close() - }) + wrtc = electronWebrtc() + wrtc.electronDaemon.once('ready', function () { serverTest(t, 'ws', 'inet') - } + }) + t.once('end', function () { + wrtc.close() + }) })