diff options
-rw-r--r-- | lib/torrent.js | 2 | ||||
-rw-r--r-- | test/client-add.js | 21 |
2 files changed, 22 insertions, 1 deletions
diff --git a/lib/torrent.js b/lib/torrent.js index 8b96e14..f60d459 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -97,7 +97,7 @@ class Torrent extends EventEmitter { this.ready = false this.destroyed = false - this.paused = false + this.paused = opts.paused || false this.done = false this.metadata = null 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') }) + }) +}) |