diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2014-12-30 06:52:01 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2014-12-30 06:52:01 +0300 |
commit | ffcb0700e73a2fb21ff7d2a1bd3a19340823fcfa (patch) | |
tree | e5c6be77a5f84d7fa5b7711e08c5ef43ba654b15 /test/basic-node.js | |
parent | 3db656bd9b427339bcbd1ec38b0fe2e50d5588e8 (diff) |
add `torrent.magnetURI` getter function
Depends on https://github.com/feross/parse-torrent/pull/8
Diffstat (limited to 'test/basic-node.js')
-rw-r--r-- | test/basic-node.js | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/test/basic-node.js b/test/basic-node.js index 6039405..ad269f0 100644 --- a/test/basic-node.js +++ b/test/basic-node.js @@ -10,9 +10,10 @@ var leaves = fs.readFileSync(leavesPath) var leavesTorrent = parseTorrent(leaves) var leavesBookPath = __dirname + '/content/Leaves of Grass by Walt Whitman.epub' var numbersPath = __dirname + '/content/numbers' +var leavesMagnetURI = 'magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36&dn=Leaves+of+Grass+by+Walt+Whitman.epub&tr=http%3A%2F%2Ftracker.thepiratebay.org%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ffr33domtracker.h33t.com%3A3310%2Fannounce&tr=http%3A%2F%2Ftracker.bittorrent.am%2Fannounce' test('client.add (http url to a torrent file (string))', function (t) { - t.plan(1) + t.plan(2) var server = http.createServer(function (req, res) { res.end(leaves) @@ -25,6 +26,7 @@ test('client.add (http url to a torrent file (string))', function (t) { var client = new WebTorrent({ dht: false, tracker: false }) client.add(url, function (torrent) { t.equal(torrent.infoHash, leavesTorrent.infoHash) + t.equal(torrent.magnetURI, leavesMagnetURI) client.destroy() server.close() }) @@ -33,27 +35,41 @@ test('client.add (http url to a torrent file (string))', function (t) { }) test('client.add (filesystem path to a torrent file (string))', function (t) { - t.plan(1) + t.plan(2) var client = new WebTorrent({ dht: false, tracker: false }) client.add(leavesPath, function (torrent) { t.equal(torrent.infoHash, leavesTorrent.infoHash) + t.equal(torrent.magnetURI, leavesMagnetURI) client.destroy() }) }) test('client.seed (filesystem path to file (string))', function (t) { - t.plan(1) + t.plan(2) + + var opts = { + name: 'Leaves of Grass by Walt Whitman.epub', + announce: [ + 'http://tracker.thepiratebay.org/announce', + 'udp://tracker.openbittorrent.com:80', + 'udp://tracker.ccc.de:80', + 'udp://tracker.publicbt.com:80', + 'udp://fr33domtracker.h33t.com:3310/announce', + 'http://tracker.bittorrent.am/announce' + ] + } var client = new WebTorrent({ dht: false, tracker: false }) - client.seed(leavesBookPath, function (torrent) { + client.seed(leavesBookPath, opts, function (torrent) { t.equal(torrent.infoHash, leavesTorrent.infoHash) + t.equal(torrent.magnetURI, leavesMagnetURI) client.destroy() }) }) test('client.seed (filesystem path to folder (string))', function (t) { - t.plan(1) + t.plan(2) var opts = { pieceLength: 32768, // force piece length to 32KB so info-hash will @@ -66,6 +82,7 @@ test('client.seed (filesystem path to folder (string))', function (t) { var client = new WebTorrent({ dht: false, tracker: false }) client.seed(numbersPath, opts, function (torrent) { t.equal(torrent.infoHash, '80562f38656b385ea78959010e51a2cc9db41ea0') + t.equal(torrent.magnetURI, 'magnet:?xt=urn:btih:80562f38656b385ea78959010e51a2cc9db41ea0&dn=numbers&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.webtorrent.io%3A80&tr=wss%3A%2F%2Ftracker.webtorrent.io') client.destroy() }) }) |