diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2015-07-27 03:14:49 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2015-07-27 03:14:49 +0300 |
commit | 66ab7d24251a9c2816beca2fc17d9a1785427a49 (patch) | |
tree | bbfe3b75e720b352083483f58dfca7d156102bf6 /test/basic.js | |
parent | d8bceb285aa84ffcd0df2346075d4cd688c4003f (diff) |
stricter tests: 'warning' events are failures
Diffstat (limited to 'test/basic.js')
-rw-r--r-- | test/basic.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/basic.js b/test/basic.js index aab3f72..28988c0 100644 --- a/test/basic.js +++ b/test/basic.js @@ -12,6 +12,10 @@ var leavesMagnetURI = 'magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cf test('client.add/remove: magnet uri, utf-8 string', function (t) { var client = new WebTorrent({ dht: false, tracker: false }) + + client.on('error', function (err) { t.fail(err) }) + client.on('warning', function (err) { t.fail(err) }) + var torrent = client.add('magnet:?xt=urn:btih:' + leavesTorrent.infoHash) t.equal(client.torrents.length, 1) torrent.on('infoHash', function () { @@ -26,6 +30,10 @@ test('client.add/remove: magnet uri, utf-8 string', function (t) { test('client.add/remove: torrent file, buffer', function (t) { var client = new WebTorrent({ dht: false, tracker: false }) + + client.on('error', function (err) { t.fail(err) }) + client.on('warning', function (err) { t.fail(err) }) + var torrent = client.add(leaves) t.equal(client.torrents.length, 1) torrent.on('infoHash', function () { @@ -40,6 +48,10 @@ test('client.add/remove: torrent file, buffer', function (t) { test('client.add/remove: info hash, hex string', function (t) { var client = new WebTorrent({ dht: false, tracker: false }) + + client.on('error', function (err) { t.fail(err) }) + client.on('warning', function (err) { t.fail(err) }) + var torrent = client.add(leavesTorrent.infoHash) t.equal(client.torrents.length, 1) torrent.on('infoHash', function () { @@ -54,6 +66,10 @@ test('client.add/remove: info hash, hex string', function (t) { test('client.add/remove: info hash, buffer', function (t) { var client = new WebTorrent({ dht: false, tracker: false }) + + client.on('error', function (err) { t.fail(err) }) + client.on('warning', function (err) { t.fail(err) }) + var torrent = client.add(new Buffer(leavesTorrent.infoHash, 'hex')) t.equal(client.torrents.length, 1) torrent.on('infoHash', function () { @@ -68,6 +84,10 @@ test('client.add/remove: info hash, buffer', function (t) { test('client.add/remove: parsed torrent, from `parse-torrent`', function (t) { var client = new WebTorrent({ dht: false, tracker: false }) + + client.on('error', function (err) { t.fail(err) }) + client.on('warning', function (err) { t.fail(err) }) + var torrent = client.add(leavesTorrent) t.equal(client.torrents.length, 1) torrent.on('infoHash', function () { @@ -82,6 +102,10 @@ test('client.add/remove: parsed torrent, from `parse-torrent`', function (t) { test('client.add/remove: parsed torrent, with string type announce property', function (t) { var client = new WebTorrent({ dht: false, tracker: false }) + + client.on('error', function (err) { t.fail(err) }) + client.on('warning', function (err) { t.fail(err) }) + var modifiedParsedTorrent = extend(leavesTorrent, { announce: leavesTorrent.announce[0] }) @@ -98,6 +122,10 @@ test('client.add/remove: parsed torrent, with string type announce property', fu test('client.remove: remove by Torrent object', function (t) { var client = new WebTorrent({ dht: false, tracker: false }) + + client.on('error', function (err) { t.fail(err) }) + client.on('warning', function (err) { t.fail(err) }) + var torrent = client.add(leavesTorrent.infoHash) t.equal(client.torrents.length, 1) torrent.on('infoHash', function () { @@ -111,6 +139,10 @@ test('client.remove: remove by Torrent object', function (t) { test('torrent.destroy: destroy and remove torrent', function (t) { var client = new WebTorrent({ dht: false, tracker: false }) + + client.on('error', function (err) { t.fail(err) }) + client.on('warning', function (err) { t.fail(err) }) + var torrent = client.add(leavesTorrent.infoHash) t.equal(client.torrents.length, 1) torrent.on('infoHash', function () { @@ -138,6 +170,10 @@ test('client.seed: torrent file (Buffer)', function (t) { } var client = new WebTorrent({ dht: false, tracker: false }) + + client.on('error', function (err) { t.fail(err) }) + client.on('warning', function (err) { t.fail(err) }) + client.seed(leavesBook, opts, function (torrent) { t.equal(client.torrents.length, 1) t.equal(torrent.infoHash, leavesTorrent.infoHash) @@ -164,6 +200,10 @@ test('client.seed: torrent file (Blob)', function (t) { if (global.Blob !== undefined) { t.plan(4) var client = new WebTorrent({ dht: false, tracker: false }) + + client.on('error', function (err) { t.fail(err) }) + client.on('warning', function (err) { t.fail(err) }) + client.seed(new global.Blob([ leavesBook ]), opts, function (torrent) { t.equal(client.torrents.length, 1) t.equal(torrent.infoHash, leavesTorrent.infoHash) @@ -182,6 +222,10 @@ test('after client.destroy(), throw on client.add() or client.seed()', function t.plan(3) var client = new WebTorrent({ dht: false, tracker: false }) + + client.on('error', function (err) { t.fail(err) }) + client.on('warning', function (err) { t.fail(err) }) + client.destroy(function () { t.pass('client destroyed') }) @@ -197,6 +241,10 @@ test('after client.destroy(), no "torrent" or "ready" events emitted', function t.plan(1) var client = new WebTorrent({ dht: false, tracker: false }) + + client.on('error', function (err) { t.fail(err) }) + client.on('warning', function (err) { t.fail(err) }) + client.add(leaves, { name: 'leaves' }, function () { t.fail('unexpected "torrent" event (from add)') }) |