diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2016-01-14 01:19:44 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2016-01-14 01:19:44 +0300 |
commit | 218eea5420deb4a9d057cd33105631dffa2a867c (patch) | |
tree | 9635ba88f1c9139a2a09dc6ef4361f88d2fa29c8 /test/client-seed.js | |
parent | 2413dc38fc5a502680324e8e468f22c6706ad204 (diff) |
split up tests
Diffstat (limited to 'test/client-seed.js')
-rw-r--r-- | test/client-seed.js | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/test/client-seed.js b/test/client-seed.js new file mode 100644 index 0000000..9548a15 --- /dev/null +++ b/test/client-seed.js @@ -0,0 +1,72 @@ +var common = require('./common') +var test = require('tape') +var WebTorrent = require('../') + +test('client.seed: torrent file (Buffer)', function (t) { + t.plan(6) + + 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.seed(common.leaves.content, { + name: 'Leaves of Grass by Walt Whitman.epub' + }, function (torrent) { + t.equal(client.torrents.length, 1) + t.equal(torrent.infoHash, common.leaves.parsedTorrent.infoHash) + t.equal(torrent.magnetURI, common.leaves.magnetURI) + + client.remove(torrent, function (err) { t.error(err, 'torrent removed') }) + t.equal(client.torrents.length, 0) + + client.destroy(function (err) { t.error(err, 'client destroyed') }) + }) +}) + +test('client.seed: torrent file (Buffer), set name on buffer', function (t) { + t.plan(6) + + 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 buf = new Buffer(common.leaves.content) + buf.name = 'Leaves of Grass by Walt Whitman.epub' + + client.seed(buf, function (torrent) { + t.equal(client.torrents.length, 1) + t.equal(torrent.infoHash, common.leaves.parsedTorrent.infoHash) + t.equal(torrent.magnetURI, common.leaves.magnetURI) + + client.remove(torrent, function (err) { t.error(err, 'torrent removed') }) + t.equal(client.torrents.length, 0) + + client.destroy(function (err) { t.error(err, 'client destroyed') }) + }) +}) + +test('client.seed: torrent file (Blob)', function (t) { + if (typeof Blob === 'undefined') return t.end() + + t.plan(6) + + 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.seed(new Blob([ common.leaves.content ]), { + name: 'Leaves of Grass by Walt Whitman.epub' + }, function (torrent) { + t.equal(client.torrents.length, 1) + t.equal(torrent.infoHash, common.leaves.parsedTorrent.infoHash) + t.equal(torrent.magnetURI, common.leaves.magnetURI) + + client.remove(torrent, function (err) { t.error(err, 'torrent removed') }) + t.equal(client.torrents.length, 0) + + client.destroy(function (err) { t.error(err, 'client destroyed') }) + }) +}) |