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-02-28 06:10:08 +0300
committerFeross Aboukhadijeh <feross@feross.org>2016-02-28 06:10:08 +0300
commitff552814b86d11c171226c20efd9c9d1c3d968be (patch)
tree13721145118b68b20ca6eaa478ba259cab703252 /test/client-add.js
parent0d2dc8c90900d1ea2103f6a457c76c7998eab3a6 (diff)
use webtorrent-fixtures
Diffstat (limited to 'test/client-add.js')
-rw-r--r--test/client-add.js58
1 files changed, 29 insertions, 29 deletions
diff --git a/test/client-add.js b/test/client-add.js
index c13f6a6..d30fea0 100644
--- a/test/client-add.js
+++ b/test/client-add.js
@@ -1,5 +1,5 @@
-var common = require('./common')
var extend = require('xtend')
+var fixtures = require('webtorrent-fixtures')
var test = require('tape')
var WebTorrent = require('../')
@@ -11,14 +11,14 @@ test('client.add: magnet uri, utf-8 string', function (t) {
client.on('error', function (err) { t.fail(err) })
client.on('warning', function (err) { t.fail(err) })
- var torrent = client.add(common.leaves.magnetURI)
+ var torrent = client.add(fixtures.leaves.magnetURI)
t.equal(client.torrents.length, 1)
torrent.on('infoHash', function () {
- t.equal(torrent.infoHash, common.leaves.parsedTorrent.infoHash)
- t.equal(torrent.magnetURI, common.leaves.magnetURI)
+ t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)
+ t.equal(torrent.magnetURI, fixtures.leaves.magnetURI)
- client.remove(common.leaves.magnetURI, function (err) { t.error(err, 'torrent destroyed') })
+ client.remove(fixtures.leaves.magnetURI, function (err) { t.error(err, 'torrent destroyed') })
t.equal(client.torrents.length, 0)
client.destroy(function (err) { t.error(err, 'client destroyed') })
@@ -33,14 +33,14 @@ test('client.add: torrent file, buffer', function (t) {
client.on('error', function (err) { t.fail(err) })
client.on('warning', function (err) { t.fail(err) })
- var torrent = client.add(common.leaves.torrent)
+ var torrent = client.add(fixtures.leaves.torrent)
t.equal(client.torrents.length, 1)
torrent.on('infoHash', function () {
- t.equal(torrent.infoHash, common.leaves.parsedTorrent.infoHash)
- t.equal(torrent.magnetURI, common.leaves.magnetURI)
+ t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)
+ t.equal(torrent.magnetURI, fixtures.leaves.magnetURI)
- client.remove(common.leaves.torrent, function (err) { t.error(err, 'torrent destroyed') })
+ client.remove(fixtures.leaves.torrent, function (err) { t.error(err, 'torrent destroyed') })
t.equal(client.torrents.length, 0)
client.destroy(function (err) { t.error(err, 'client destroyed') })
@@ -55,14 +55,14 @@ test('client.add: info hash, hex string', function (t) {
client.on('error', function (err) { t.fail(err) })
client.on('warning', function (err) { t.fail(err) })
- var torrent = client.add(common.leaves.parsedTorrent.infoHash)
+ var torrent = client.add(fixtures.leaves.parsedTorrent.infoHash)
t.equal(client.torrents.length, 1)
torrent.on('infoHash', function () {
- t.equal(torrent.infoHash, common.leaves.parsedTorrent.infoHash)
- t.equal(torrent.magnetURI, 'magnet:?xt=urn:btih:' + common.leaves.parsedTorrent.infoHash)
+ t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)
+ t.equal(torrent.magnetURI, 'magnet:?xt=urn:btih:' + fixtures.leaves.parsedTorrent.infoHash)
- client.remove(common.leaves.parsedTorrent.infoHash, function (err) { t.error(err, 'torrent destroyed') })
+ client.remove(fixtures.leaves.parsedTorrent.infoHash, function (err) { t.error(err, 'torrent destroyed') })
t.equal(client.torrents.length, 0)
client.destroy(function (err) { t.error(err, 'client destroyed') })
@@ -77,14 +77,14 @@ test('client.add: info hash, buffer', function (t) {
client.on('error', function (err) { t.fail(err) })
client.on('warning', function (err) { t.fail(err) })
- var torrent = client.add(common.leaves.parsedTorrent.infoHashBuffer)
+ var torrent = client.add(fixtures.leaves.parsedTorrent.infoHashBuffer)
t.equal(client.torrents.length, 1)
torrent.on('infoHash', function () {
- t.equal(torrent.infoHash, common.leaves.parsedTorrent.infoHash)
- t.ok(torrent.magnetURI.indexOf('magnet:?xt=urn:btih:' + common.leaves.parsedTorrent.infoHash) === 0)
+ t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)
+ t.ok(torrent.magnetURI.indexOf('magnet:?xt=urn:btih:' + fixtures.leaves.parsedTorrent.infoHash) === 0)
- client.remove(new Buffer(common.leaves.parsedTorrent.infoHash, 'hex'), function (err) { t.error(err, 'torrent destroyed') })
+ client.remove(new Buffer(fixtures.leaves.parsedTorrent.infoHash, 'hex'), function (err) { t.error(err, 'torrent destroyed') })
t.equal(client.torrents.length, 0)
client.destroy(function (err) { t.error(err, 'client destroyed') })
@@ -99,14 +99,14 @@ test('client.add: parsed torrent, from `parse-torrent`', function (t) {
client.on('error', function (err) { t.fail(err) })
client.on('warning', function (err) { t.fail(err) })
- var torrent = client.add(common.leaves.parsedTorrent)
+ var torrent = client.add(fixtures.leaves.parsedTorrent)
t.equal(client.torrents.length, 1)
torrent.on('infoHash', function () {
- t.equal(torrent.infoHash, common.leaves.parsedTorrent.infoHash)
- t.equal(torrent.magnetURI, common.leaves.magnetURI)
+ t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)
+ t.equal(torrent.magnetURI, fixtures.leaves.magnetURI)
- client.remove(common.leaves.parsedTorrent, function (err) { t.error(err, 'torrent destroyed') })
+ client.remove(fixtures.leaves.parsedTorrent, function (err) { t.error(err, 'torrent destroyed') })
t.equal(client.torrents.length, 0)
client.destroy(function (err) { t.error(err, 'client destroyed') })
@@ -121,23 +121,23 @@ test('client.add: parsed torrent, with string type announce property', function
client.on('error', function (err) { t.fail(err) })
client.on('warning', function (err) { t.fail(err) })
- var parsedTorrent = extend(common.leaves.parsedTorrent)
+ var parsedTorrent = extend(fixtures.leaves.parsedTorrent)
parsedTorrent.announce = 'http://tracker.local:80'
var torrent = client.add(parsedTorrent)
t.equal(client.torrents.length, 1)
torrent.on('infoHash', function () {
- t.equal(torrent.infoHash, common.leaves.parsedTorrent.infoHash)
+ t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)
- var expectedMagnetURI = common.leaves.magnetURI +
+ var expectedMagnetURI = fixtures.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') })
+ client.remove(fixtures.leaves.parsedTorrent, function (err) { t.error(err, 'torrent destroyed') })
t.equal(client.torrents.length, 0)
client.destroy(function (err) { t.error(err, 'client destroyed') })
@@ -152,23 +152,23 @@ test('client.add: parsed torrent, with array type announce property', function (
client.on('error', function (err) { t.fail(err) })
client.on('warning', function (err) { t.fail(err) })
- var parsedTorrent = extend(common.leaves.parsedTorrent)
+ var parsedTorrent = extend(fixtures.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)
+ t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)
- var expectedMagnetURI = common.leaves.magnetURI +
+ var expectedMagnetURI = fixtures.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') })
+ client.remove(fixtures.leaves.parsedTorrent, function (err) { t.error(err, 'torrent destroyed') })
t.equal(client.torrents.length, 0)
client.destroy(function (err) { t.error(err, 'client destroyed') })