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>2016-01-14 01:19:44 +0300
committerFeross Aboukhadijeh <feross@feross.org>2016-01-14 01:19:44 +0300
commit218eea5420deb4a9d057cd33105631dffa2a867c (patch)
tree9635ba88f1c9139a2a09dc6ef4361f88d2fa29c8 /test/torrent-destroy.js
parent2413dc38fc5a502680324e8e468f22c6706ad204 (diff)
split up tests
Diffstat (limited to 'test/torrent-destroy.js')
-rw-r--r--test/torrent-destroy.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/torrent-destroy.js b/test/torrent-destroy.js
new file mode 100644
index 0000000..a0a2e5e
--- /dev/null
+++ b/test/torrent-destroy.js
@@ -0,0 +1,24 @@
+var common = require('./common')
+var test = require('tape')
+var WebTorrent = require('../')
+
+test('torrent.destroy: destroy and remove torrent', function (t) {
+ t.plan(5)
+
+ 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 torrent = client.add(common.leaves.parsedTorrent.infoHash)
+ t.equal(client.torrents.length, 1)
+
+ torrent.on('infoHash', function () {
+ t.equal(torrent.infoHash, common.leaves.parsedTorrent.infoHash)
+
+ torrent.destroy(function (err) { t.error(err, 'torrent destroyed') })
+ t.equal(client.torrents.length, 0)
+
+ client.destroy(function (err) { t.error(err, 'client destroyed') })
+ })
+})