Welcome to mirror list, hosted at ThFree Co, Russian Federation.

client-remove.js « test - github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6ea47de05a1c415ea04b777b556551bd7d002764 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const fixtures = require('webtorrent-fixtures')
const test = require('tape')
const WebTorrent = require('../index.js')

test('client.remove: remove by Torrent object', 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.parsedTorrent.infoHash)
  t.equal(client.torrents.length, 1)

  torrent.on('infoHash', () => {
    t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)

    client.remove(torrent, err => { t.error(err, 'torrent destroyed') })
    t.equal(client.torrents.length, 0)

    client.destroy(err => { t.error(err, 'client destroyed') })
  })
})