Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2015-12-19 05:14:13 +0300
committerFeross Aboukhadijeh <feross@feross.org>2015-12-27 23:17:13 +0300
commit1da859430e3a425ea60764327e13f047c3c47766 (patch)
tree3efb7a1e2f832ac9f1bc99e92cb0907ff7392739
parentd6ddf855579c490cf6ce9c8f63c8eb34b6c3eccc (diff)
test: `torrent.announce` must always be an array
-rw-r--r--test/basic.js41
1 files changed, 39 insertions, 2 deletions
diff --git a/test/basic.js b/test/basic.js
index 64472b4..0577d99 100644
--- a/test/basic.js
+++ b/test/basic.js
@@ -116,7 +116,7 @@ test('client.add: parsed torrent, from `parse-torrent`', function (t) {
})
test('client.add: parsed torrent, with string type announce property', function (t) {
- t.plan(6)
+ t.plan(7)
var client = new WebTorrent({ dht: false, tracker: false })
@@ -131,7 +131,44 @@ test('client.add: parsed torrent, with string type announce property', function
torrent.on('infoHash', function () {
t.equal(torrent.infoHash, common.leaves.parsedTorrent.infoHash)
- t.equal(torrent.magnetURI, common.leaves.magnetURI + '&tr=' + encodeURIComponent('http://tracker.local:80'))
+
+ var expectedMagnetURI = common.leaves.magnetURI +
+ '&tr=' + encodeURIComponent('http://tracker.local:80')
+ t.equal(torrent.magnetURI, expectedMagnetURI)
+
+ // `torrent.announce` must always be an array
+ t.deepEqual(torrent.announce, [ 'http://tracker.local:80' ])
+
+ client.remove(common.leaves.parsedTorrent, function (err) { t.error(err, 'torrent destroyed') })
+ t.equal(client.torrents.length, 0)
+
+ client.destroy(function (err) { t.error(err, 'client destroyed') })
+ })
+})
+
+test('client.add: parsed torrent, with array type announce property', function (t) {
+ t.plan(7)
+
+ var client = new WebTorrent({ dht: false, tracker: false })
+
+ client.on('error', function (err) { t.fail(err) })
+ client.on('warning', function (err) { t.fail(err) })
+
+ var parsedTorrent = extend(common.leaves.parsedTorrent)
+ parsedTorrent.announce = [ 'http://tracker.local:80', 'http://tracker.local:81' ]
+
+ var torrent = client.add(parsedTorrent)
+ t.equal(client.torrents.length, 1)
+
+ torrent.on('infoHash', function () {
+ t.equal(torrent.infoHash, common.leaves.parsedTorrent.infoHash)
+
+ var expectedMagnetURI = common.leaves.magnetURI +
+ '&tr=' + encodeURIComponent('http://tracker.local:80') +
+ '&tr=' + encodeURIComponent('http://tracker.local:81')
+ t.equal(torrent.magnetURI, expectedMagnetURI)
+
+ t.deepEqual(torrent.announce, [ 'http://tracker.local:80', 'http://tracker.local:81' ])
client.remove(common.leaves.parsedTorrent, function (err) { t.error(err, 'torrent destroyed') })
t.equal(client.torrents.length, 0)