var fixtures = require('webtorrent-fixtures') var test = require('tape') var WebTorrent = require('../') test('torrent.destroy: destroy and remove torrent', function (t) { t.plan(5) 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(fixtures.leaves.parsedTorrent.infoHash) t.equal(client.torrents.length, 1) torrent.on('infoHash', function () { t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash) torrent.destroy(function (err) { t.error(err, 'torrent destroyed') }) t.equal(client.torrents.length, 0) client.destroy(function (err) { t.error(err, 'client destroyed') }) }) })