diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2014-09-21 05:41:58 +0400 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2014-09-21 05:41:58 +0400 |
commit | c20ae0fa56384c9a23f9d111ccd0dee73d2adad9 (patch) | |
tree | c19bb103460aee19f62172ddb9981e0ca1a65222 /test/basic.js | |
parent | 93686505fbc90522c75b6c151ec7261aa76098de (diff) |
add test/basic.js back
Diffstat (limited to 'test/basic.js')
-rw-r--r-- | test/basic.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/basic.js b/test/basic.js new file mode 100644 index 0000000..bd332dc --- /dev/null +++ b/test/basic.js @@ -0,0 +1,36 @@ +var BitTorrentClient = require('../') +var parseTorrent = require('parse-torrent') +var test = require('tape') +var fs = require('fs') + +var leaves = fs.readFileSync(__dirname + '/torrents/leaves.torrent') +var leavesTorrent = parseTorrent(leaves) + +test('Test supported torrentInfo types', function (t) { + t.plan(5) + + function verify (client, torrent) { + t.equal(torrent.infoHash, leavesTorrent.infoHash) + client.destroy() + } + + // info hash (as a hex string) + var client1 = new BitTorrentClient({ dht: false, trackers: false }) + verify(client1, client1.add(leavesTorrent.infoHash)) + + // info hash (as a Buffer) + var client2 = new BitTorrentClient({ dht: false, trackers: false }) + verify(client2, client2.add(new Buffer(leavesTorrent.infoHash, 'hex'))) + + // magnet uri (as a utf8 string) + var client3 = new BitTorrentClient({ dht: false, trackers: false }) + verify(client3, client3.add('magnet:?xt=urn:btih:' + leavesTorrent.infoHash)) + + // .torrent file (as a Buffer) + var client4 = new BitTorrentClient({ dht: false, trackers: false }) + verify(client4, client4.add(leaves)) + + // parsed torrent (as an Object) + var client5 = new BitTorrentClient({ dht: false, trackers: false }) + verify(client5, client5.add(leavesTorrent)) +}) |