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/client-destroy.js
parent2413dc38fc5a502680324e8e468f22c6706ad204 (diff)
split up tests
Diffstat (limited to 'test/client-destroy.js')
-rw-r--r--test/client-destroy.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/client-destroy.js b/test/client-destroy.js
new file mode 100644
index 0000000..d2e66b8
--- /dev/null
+++ b/test/client-destroy.js
@@ -0,0 +1,42 @@
+var common = require('./common')
+var test = require('tape')
+var WebTorrent = require('../')
+
+test('after client.destroy(), throw on client.add() or client.seed()', function (t) {
+ t.plan(3)
+
+ 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.destroy(function (err) { t.error(err, 'client destroyed') })
+
+ t.throws(function () {
+ client.add('magnet:?xt=urn:btih:' + common.leaves.parsedTorrent.infoHash)
+ })
+ t.throws(function () {
+ client.seed(new Buffer('sup'))
+ })
+})
+
+test('after client.destroy(), no "torrent" or "ready" events emitted', function (t) {
+ 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(common.leaves.torrent, { name: 'leaves' }, function () {
+ t.fail('unexpected "torrent" event (from add)')
+ })
+ client.seed(common.leaves.content, { name: 'leaves' }, function () {
+ t.fail('unexpected "torrent" event (from seed)')
+ })
+ client.on('ready', function () {
+ t.fail('unexpected "ready" event')
+ })
+
+ client.destroy(function (err) { t.error(err, 'client destroyed') })
+})