-
-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathbasic.js
More file actions
35 lines (29 loc) · 968 Bytes
/
basic.js
File metadata and controls
35 lines (29 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import fixtures from 'webtorrent-fixtures'
import http from 'http'
import { remote } from '../../index.js'
import test from 'tape'
fixtures.leaves.parsedTorrent.infoHashBuffer = new Uint8Array(fixtures.leaves.parsedTorrent.infoHashBuffer)
fixtures.leaves.parsedTorrent.version = 'v1'
test('http url to a torrent file, string', t => {
t.plan(3)
const server = http.createServer((req, res) => {
t.pass('server got request')
res.end(fixtures.leaves.torrent)
})
server.listen(0, () => {
const port = server.address().port
const url = `http://127.0.0.1:${port}`
remote(url, (err, parsedTorrent) => {
t.error(err)
t.deepEqual(parsedTorrent, fixtures.leaves.parsedTorrent)
server.close()
})
})
})
test('filesystem path to a torrent file, string', t => {
t.plan(2)
remote(fixtures.leaves.torrentPath, (err, parsedTorrent) => {
t.error(err)
t.deepEqual(parsedTorrent, fixtures.leaves.parsedTorrent)
})
})