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>2014-12-17 02:27:00 +0300
committerFeross Aboukhadijeh <feross@feross.org>2014-12-17 02:43:06 +0300
commit9e55cc7eec04e07060f32d1695b44f30a7c25187 (patch)
tree02eb370c356f97733c81649de7edba888839745f /test/basic.js
parent8e6503ab5dcbc698c02de88b5e0f65e015269591 (diff)
add client.seed tests (buffer, blob, path to file)
Diffstat (limited to 'test/basic.js')
-rw-r--r--test/basic.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/basic.js b/test/basic.js
index a413e94..2211593 100644
--- a/test/basic.js
+++ b/test/basic.js
@@ -5,6 +5,7 @@ var test = require('tape')
var leaves = fs.readFileSync(__dirname + '/torrents/leaves.torrent')
var leavesTorrent = parseTorrent(leaves)
+var leavesBook = fs.readFileSync(__dirname + '/content/Leaves of Grass by Walt Whitman.epub')
function verify (t, client, torrent) {
t.equal(torrent.infoHash, leavesTorrent.infoHash)
@@ -33,5 +34,28 @@ test('client.add (magnet uri, torrent file, info hash, and parsed torrent)', fun
// parsed torrent (from parse-torrent)
var client5 = new WebTorrent({ dht: false, trackers: false })
verify(t, client5, client5.add(leavesTorrent))
+})
+
+test('client.seed (Buffer, Blob)', function (t) {
+ t.plan(2)
+ var opts = {
+ name: 'Leaves of Grass by Walt Whitman.epub'
+ }
+
+ // torrent file (Buffer)
+ var client1 = new WebTorrent({ dht: false, trackers: false })
+ client1.seed(leavesBook, opts, function (torrent) {
+ verify(t, client1, torrent)
+ })
+
+ // Blob
+ if (typeof Blob !== 'undefined') {
+ var client2 = new WebTorrent({ dht: false, trackers: false })
+ client2.seed(new Blob([ leavesBook ]), opts, function (torrent) {
+ verify(t, client2, torrent)
+ })
+ } else {
+ t.pass('Skipping Blob test because missing `Blob` constructor')
+ }
})