From e8dea8e588045b43c7a5d4931cde692fd135a21d Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Wed, 18 May 2016 23:01:52 -0700 Subject: Fixes for PR #799 - Support multiple &xs= params in parallel - Fail on 'error' 'warning' events --- test/node/download-metadata.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/node/download-metadata.js b/test/node/download-metadata.js index 07b605a..59936cb 100644 --- a/test/node/download-metadata.js +++ b/test/node/download-metadata.js @@ -25,9 +25,12 @@ test('Download metadata for magnet URI with xs parameter', function (t) { var client = new WebTorrent({ dht: false, tracker: false }) + client.on('error', function (err) { t.fail(err) }) + client.on('warning', function (err) { t.fail(err) }) + createServer(fixtures.leaves.torrent, function (url, next) { client.add(fixtures.leaves.magnetURI + '&xs=' + encodeURIComponent(url), function (torrent) { - t.equal(torrent.name, 'Leaves of Grass by Walt Whitman.epub') + t.equal(torrent.files[0].name, 'Leaves of Grass by Walt Whitman.epub') client.destroy(function (err) { t.error(err, 'client destroyed') }) next() @@ -40,12 +43,15 @@ test('Download metadata for magnet URI with xs parameter', function (t) { var client = new WebTorrent({ dht: false, tracker: false }) + client.on('error', function (err) { t.fail(err) }) + client.on('warning', function (err) { t.fail(err) }) + createServer(fixtures.leaves.torrent, function (url, next) { var encoded = encodeURIComponent(url) var uri = fixtures.leaves.magnetURI + '&xs=' + encoded + '&xs=' + encoded + '2' client.add(uri, function (torrent) { - t.equal(torrent.name, 'Leaves of Grass by Walt Whitman.epub') + t.equal(torrent.files[0].name, 'Leaves of Grass by Walt Whitman.epub') client.destroy(function (err) { t.error(err, 'client destroyed') }) next() @@ -54,12 +60,17 @@ test('Download metadata for magnet URI with xs parameter', function (t) { }) test('Download metadata magnet URI with unsupported protocol in xs parameter', function (t) { - t.plan(2) + t.plan(1) var client = new WebTorrent({ dht: false, tracker: false }) + + client.on('error', function (err) { t.fail(err) }) + client.on('warning', function (err) { t.fail(err) }) + client.add(fixtures.leaves.magnetURI + '&xs=' + encodeURIComponent('invalidurl:example')) + setTimeout(function () { - t.ok(true, 'no crash') + // no crash by now client.destroy(function (err) { t.error(err, 'client destroyed') }) }, 100) }) -- cgit v1.2.3