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

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'test/node/download-webseed-torrent.js')
-rw-r--r--test/node/download-webseed-torrent.js52
1 files changed, 26 insertions, 26 deletions
diff --git a/test/node/download-webseed-torrent.js b/test/node/download-webseed-torrent.js
index 0fafed0..43bff79 100644
--- a/test/node/download-webseed-torrent.js
+++ b/test/node/download-webseed-torrent.js
@@ -11,41 +11,41 @@ const WebTorrent = require('../../')
// it should be fast to download a small torrent over local HTTP
const WEB_SEED_TIMEOUT_MS = 500
-test('Download using webseed (via .torrent file)', function (t) {
+test('Download using webseed (via .torrent file)', t => {
t.plan(6)
t.timeoutAfter(WEB_SEED_TIMEOUT_MS)
const parsedTorrent = Object.assign({}, fixtures.leaves.parsedTorrent)
- const httpServer = http.createServer(function (req, res) {
+ const httpServer = http.createServer((req, res) => {
const done = finalhandler(req, res)
serveStatic(path.dirname(fixtures.leaves.contentPath))(req, res, done)
})
let client
- httpServer.on('error', function (err) { t.fail(err) })
+ httpServer.on('error', err => { t.fail(err) })
series([
- function (cb) {
+ cb => {
httpServer.listen(cb)
},
- function (cb) {
+ cb => {
parsedTorrent.urlList = [
- 'http://localhost:' + httpServer.address().port + '/' + fixtures.leaves.parsedTorrent.name
+ `http://localhost:${httpServer.address().port}/${fixtures.leaves.parsedTorrent.name}`
]
client = new WebTorrent({ dht: false, tracker: false, lsd: false })
- client.on('error', function (err) { t.fail(err) })
- client.on('warning', function (err) { t.fail(err) })
+ client.on('error', err => { t.fail(err) })
+ client.on('warning', err => { t.fail(err) })
- client.on('torrent', function (torrent) {
+ client.on('torrent', torrent => {
let gotBuffer = false
let torrentDone = false
- torrent.files.forEach(function (file) {
- file.getBuffer(function (err, buf) {
+ torrent.files.forEach(file => {
+ file.getBuffer((err, buf) => {
t.error(err)
t.deepEqual(buf, fixtures.leaves.content, 'downloaded correct content')
gotBuffer = true
@@ -53,7 +53,7 @@ test('Download using webseed (via .torrent file)', function (t) {
})
})
- torrent.once('done', function () {
+ torrent.once('done', () => {
t.pass('client downloaded torrent from webseed')
torrentDone = true
maybeDone()
@@ -66,42 +66,42 @@ test('Download using webseed (via .torrent file)', function (t) {
client.add(parsedTorrent, { store: MemoryChunkStore })
}
- ], function (err) {
+ ], err => {
t.error(err)
- client.destroy(function (err) {
+ client.destroy(err => {
t.error(err, 'client destroyed')
})
- httpServer.close(function () {
+ httpServer.close(() => {
t.pass('http server closed')
})
})
})
-test('Disable webseeds', function (t) {
+test('Disable webseeds', t => {
t.plan(3)
const parsedTorrent = Object.assign({}, fixtures.leaves.parsedTorrent)
- const httpServer = http.createServer(function (req, res) {
+ const httpServer = http.createServer((req, res) => {
t.fail('webseed http server should not get any requests')
})
let client
- httpServer.on('error', function (err) { t.fail(err) })
+ httpServer.on('error', err => { t.fail(err) })
series([
- function (cb) {
+ cb => {
httpServer.listen(cb)
},
- function (cb) {
+ cb => {
parsedTorrent.urlList = [
- 'http://localhost:' + httpServer.address().port + '/' + fixtures.leaves.parsedTorrent.name
+ `http://localhost:${httpServer.address().port}/${fixtures.leaves.parsedTorrent.name}`
]
client = new WebTorrent({ dht: false, tracker: false, lsd: false, webSeeds: false })
- client.on('error', function (err) { t.fail(err) })
- client.on('warning', function (err) { t.fail(err) })
+ client.on('error', err => { t.fail(err) })
+ client.on('warning', err => { t.fail(err) })
client.add(parsedTorrent, { store: MemoryChunkStore })
@@ -109,12 +109,12 @@ test('Disable webseeds', function (t) {
// short time. Here, we wait the same amount of time and make sure no HTTP requests happen.
setTimeout(cb, WEB_SEED_TIMEOUT_MS)
}
- ], function (err) {
+ ], err => {
t.error(err)
- client.destroy(function (err) {
+ client.destroy(err => {
t.error(err, 'client destroyed')
})
- httpServer.close(function () {
+ httpServer.close(() => {
t.pass('http server closed')
})
})