From 5c79c0a01424087e4c37776d86ef745191504df4 Mon Sep 17 00:00:00 2001 From: nkavian Date: Fri, 9 Jul 2021 15:00:12 -0700 Subject: feat: support adding paused torrents. (#2004) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Support adding paused torrents. * chore: use arrows, because semantic Co-authored-by: Nas Kavian <> Co-authored-by: Diego Rodríguez Baquero --- test/client-add.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test/client-add.js') diff --git a/test/client-add.js b/test/client-add.js index beced07..90231fc 100644 --- a/test/client-add.js +++ b/test/client-add.js @@ -205,3 +205,24 @@ test('client.add: invalid torrent id: short buffer', function (t) { client.add(Buffer.from('abc')) }) + +test('client.add: paused torrent', function (t) { + t.plan(5) + + const client = new WebTorrent({ dht: false, tracker: false, lsd: false }) + + client.on('error', (err) => t.fail(err)) + client.on('warning', (err) => t.fail(err)) + + const torrent = client.add(fixtures.leaves.magnetURI, { paused: true }) + t.equal(client.torrents.length, 1) + + torrent.on('infoHash', function () { + t.equal(torrent.paused, true) + + client.remove(fixtures.leaves.magnetURI, function (err) { t.error(err, 'torrent destroyed') }) + t.equal(client.torrents.length, 0) + + client.destroy(function (err) { t.error(err, 'client destroyed') }) + }) +}) -- cgit v1.2.3