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
path: root/test
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2014-10-06 10:54:26 +0400
committerFeross Aboukhadijeh <feross@feross.org>2014-10-06 10:54:26 +0400
commitaecf7061ecfb9ce8f21d82fcb32d3ea79b441ad5 (patch)
tree02860de2416f6fe7a64c79fa035b7891eda1fc81 /test
parentd7215345c886baaa32128d0608d35723da0ddd7a (diff)
move node-only tests out of basic.js
Diffstat (limited to 'test')
-rw-r--r--test/basic-node.js44
-rw-r--r--test/basic.js34
2 files changed, 45 insertions, 33 deletions
diff --git a/test/basic-node.js b/test/basic-node.js
new file mode 100644
index 0000000..9d18928
--- /dev/null
+++ b/test/basic-node.js
@@ -0,0 +1,44 @@
+var WebTorrent = require('../')
+var fs = require('fs')
+var http = require('http')
+var parseTorrent = require('parse-torrent')
+var portfinder = require('portfinder')
+var test = require('tape')
+
+var leavesPath = __dirname + '/torrents/leaves.torrent'
+var leaves = fs.readFileSync(leavesPath)
+var leavesTorrent = parseTorrent(leaves)
+
+function verify (t, client, torrent) {
+ t.equal(torrent.infoHash, leavesTorrent.infoHash)
+ client.destroy()
+}
+
+test('client.add (http url to a torrent file (string))', function (t) {
+ t.plan(1)
+
+ var server = http.createServer(function (req, res) {
+ res.end(leaves)
+ })
+
+ portfinder.getPort(function (err, port) {
+ if (err) throw err
+ server.listen(port, function () {
+ var url = 'http://127.0.0.1:' + port
+ var client1 = new WebTorrent({ dht: false, trackers: false })
+ client1.add(url, function (torrent) {
+ verify(t, client1, torrent)
+ server.close()
+ })
+ })
+ })
+})
+
+test('client.add (filesystem path to a torrent file (string))', function (t) {
+ t.plan(1)
+
+ var client1 = new WebTorrent({ dht: false, trackers: false })
+ client1.add(leavesPath, function (torrent) {
+ verify(t, client1, torrent)
+ })
+})
diff --git a/test/basic.js b/test/basic.js
index e7aaca5..a413e94 100644
--- a/test/basic.js
+++ b/test/basic.js
@@ -1,12 +1,9 @@
var WebTorrent = require('../')
var fs = require('fs')
-var http = require('http')
var parseTorrent = require('parse-torrent')
-var portfinder = require('portfinder')
var test = require('tape')
-var leavesPath = __dirname + '/torrents/leaves.torrent'
-var leaves = fs.readFileSync(leavesPath)
+var leaves = fs.readFileSync(__dirname + '/torrents/leaves.torrent')
var leavesTorrent = parseTorrent(leaves)
function verify (t, client, torrent) {
@@ -38,32 +35,3 @@ test('client.add (magnet uri, torrent file, info hash, and parsed torrent)', fun
verify(t, client5, client5.add(leavesTorrent))
})
-
-test('client.add (http url to a torrent file (string))', function (t) {
- t.plan(1)
-
- var server = http.createServer(function (req, res) {
- res.end(leaves)
- })
-
- portfinder.getPort(function (err, port) {
- if (err) throw err
- server.listen(port, function () {
- var url = 'http://127.0.0.1:' + port
- var client1 = new WebTorrent({ dht: false, trackers: false })
- client1.add(url, function (torrent) {
- verify(t, client1, torrent)
- server.close()
- })
- })
- })
-})
-
-test('client.add (filesystem path to a torrent file (string))', function (t) {
- t.plan(1)
-
- var client1 = new WebTorrent({ dht: false, trackers: false })
- client1.add(leavesPath, function (torrent) {
- verify(t, client1, torrent)
- })
-})