diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2015-12-10 09:31:19 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2015-12-17 14:39:55 +0300 |
commit | dfdf52b747201cdb9f616a2b1f0831e96b250ab6 (patch) | |
tree | 139c69d7377b6b2653598da31a49dfd3ef702a5d /test/basic-node.js | |
parent | 992caf9650a1f6821006387dfaf58f4004b17005 (diff) |
test: put fixtures into single location
Diffstat (limited to 'test/basic-node.js')
-rw-r--r-- | test/basic-node.js | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/test/basic-node.js b/test/basic-node.js index cff40eb..d776a52 100644 --- a/test/basic-node.js +++ b/test/basic-node.js @@ -1,24 +1,14 @@ -var WebTorrent = require('../') -var fs = require('fs') +var common = require('./common') var http = require('http') -var path = require('path') -var parseTorrent = require('parse-torrent') var test = require('tape') - -var leavesPath = path.resolve(__dirname, 'torrents', 'leaves.torrent') -var leaves = fs.readFileSync(leavesPath) -var leavesTorrent = parseTorrent(leaves) -var leavesBookPath = path.resolve(__dirname, 'content', 'Leaves of Grass by Walt Whitman.epub') -var leavesMagnetURI = 'magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36&dn=Leaves+of+Grass+by+Walt+Whitman.epub&tr=http%3A%2F%2Ftracker.bittorrent.am%2Fannounce&tr=http%3A%2F%2Ftracker.thepiratebay.org%2Fannounce&tr=udp%3A%2F%2Ffr33domtracker.h33t.com%3A3310%2Fannounce&tr=udp%3A%2F%2Ftracker.ccc.de%3A80&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80' -var numbersPath = path.resolve(__dirname, 'content', 'numbers') -var folderPath = path.resolve(__dirname, 'content', 'folder') +var WebTorrent = require('../') test('client.add: http url to a torrent file, string', function (t) { t.plan(3) var server = http.createServer(function (req, res) { t.ok(req.headers['user-agent'].indexOf('WebTorrent') !== -1) - res.end(leaves) + res.end(common.leaves.torrent) }) server.listen(0, function () { @@ -30,8 +20,8 @@ test('client.add: http url to a torrent file, string', function (t) { client.on('warning', function (err) { t.fail(err) }) client.add(url, function (torrent) { - t.equal(torrent.infoHash, leavesTorrent.infoHash) - t.equal(torrent.magnetURI, leavesMagnetURI) + t.equal(torrent.infoHash, common.leaves.parsedTorrent.infoHash) + t.equal(torrent.magnetURI, common.leaves.magnetURI) client.destroy() server.close() }) @@ -46,9 +36,9 @@ test('client.add: filesystem path to a torrent file, string', function (t) { client.on('error', function (err) { t.fail(err) }) client.on('warning', function (err) { t.fail(err) }) - client.add(leavesPath, function (torrent) { - t.equal(torrent.infoHash, leavesTorrent.infoHash) - t.equal(torrent.magnetURI, leavesMagnetURI) + client.add(common.leaves.torrentPath, function (torrent) { + t.equal(torrent.infoHash, common.leaves.parsedTorrent.infoHash) + t.equal(torrent.magnetURI, common.leaves.magnetURI) client.destroy() }) }) @@ -73,9 +63,9 @@ test('client.seed: filesystem path to file, string', function (t) { client.on('error', function (err) { t.fail(err) }) client.on('warning', function (err) { t.fail(err) }) - client.seed(leavesBookPath, opts, function (torrent) { - t.equal(torrent.infoHash, leavesTorrent.infoHash) - t.equal(torrent.magnetURI, leavesMagnetURI) + client.seed(common.leaves.contentPath, opts, function (torrent) { + t.equal(torrent.infoHash, common.leaves.parsedTorrent.infoHash) + t.equal(torrent.magnetURI, common.leaves.magnetURI) client.destroy() }) }) @@ -99,7 +89,7 @@ test('client.seed: filesystem path to folder with one file, string', function (t client.on('error', function (err) { t.fail(err) }) client.on('warning', function (err) { t.fail(err) }) - client.seed(folderPath, opts, function (torrent) { + client.seed(common.folder.contentPath, opts, function (torrent) { t.equal(torrent.infoHash, '3a686c32404af0a66913dd5f8d2b40673f8d4490') t.equal(torrent.magnetURI, 'magnet:?xt=urn:btih:3a686c32404af0a66913dd5f8d2b40673f8d4490&dn=folder&tr=udp%3A%2F%2Ftracker.webtorrent.io%3A80') client.destroy() @@ -125,7 +115,7 @@ test('client.seed: filesystem path to folder with multiple files, string', funct client.on('error', function (err) { t.fail(err) }) client.on('warning', function (err) { t.fail(err) }) - client.seed(numbersPath, opts, function (torrent) { + client.seed(common.numbers.contentPath, opts, function (torrent) { t.equal(torrent.infoHash, '80562f38656b385ea78959010e51a2cc9db41ea0') t.equal(torrent.magnetURI, 'magnet:?xt=urn:btih:80562f38656b385ea78959010e51a2cc9db41ea0&dn=numbers&tr=udp%3A%2F%2Ftracker.webtorrent.io%3A80') client.destroy() |