From f2282dcecc8ea3ea9afff5ecf7f41b764cc8bc9b Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 22 Jul 2016 18:11:18 -0700 Subject: test: make more reliable with once Okay, so this was a timing thing. Basically now noPeers is getting emitted twice because the tracker gets sent a 'started' then a 'completed' message and both times there are no peers in the response. I changed the .on('noPeers') to .once('noPeers') so this will be more reliable. https://github.com/feross/webtorrent/pull/871#discussion_r71963946 --- test/node/download-tracker-magnet.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/node/download-tracker-magnet.js b/test/node/download-tracker-magnet.js index 97062c0..9ffa233 100644 --- a/test/node/download-tracker-magnet.js +++ b/test/node/download-tracker-magnet.js @@ -16,7 +16,7 @@ test('Download using HTTP tracker (via magnet uri)', function (t) { }) function magnetDownloadTest (t, serverType) { - t.plan(11) + t.plan(10) var tracker = new TrackerServer( serverType === 'udp' ? { http: false, ws: false } : { udp: false, ws: false } @@ -60,7 +60,7 @@ function magnetDownloadTest (t, serverType) { 'Leaves of Grass by Walt Whitman.epub' ] - torrent.on('noPeers', function (announceType) { + torrent.once('noPeers', function (announceType) { t.equal(announceType, 'tracker', 'noPeers event seen with correct announceType') }) -- cgit v1.2.3