diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2016-05-19 09:01:52 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2016-05-19 09:01:52 +0300 |
commit | e8dea8e588045b43c7a5d4931cde692fd135a21d (patch) | |
tree | 4788e98a58dd23bb5e0e5a84fdddd48beae95fc9 /test/node | |
parent | 389402479e9d9b2f5343f3eed6d3f5eb111666df (diff) |
Fixes for PR #799
- Support multiple &xs= params in parallel
- Fail on 'error' 'warning' events
Diffstat (limited to 'test/node')
-rw-r--r-- | test/node/download-metadata.js | 19 |
1 files changed, 15 insertions, 4 deletions
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) }) |