cleanup tests

This commit is contained in:
Feross Aboukhadijeh 2014-11-26 20:11:49 +08:00
parent 1ca387f2fe
commit 32b622aa51
4 changed files with 9 additions and 12 deletions

View File

@ -43,8 +43,8 @@ test('large torrent: client.start()', function (t) {
client.start() client.start()
client.once('peer', function (addr) { client.once('peer', function () {
t.pass('there is at least one peer') // TODO: this shouldn't rely on an external server! t.pass('there is at least one peer')
client.stop() client.stop()

View File

@ -1,5 +1,4 @@
var Client = require('../') var Client = require('../')
var fs = require('fs')
var magnet = require('magnet-uri') var magnet = require('magnet-uri')
var portfinder = require('portfinder') var portfinder = require('portfinder')
var Server = require('../').Server var Server = require('../').Server
@ -44,8 +43,8 @@ test('magnet + udp: client.start/update/stop()', function (t) {
client.start() client.start()
client.once('peer', function (addr) { client.once('peer', function () {
t.pass('there is at least one peer') // TODO: this shouldn't rely on an external server! t.pass('there is at least one peer')
client.update() client.update()

View File

@ -31,7 +31,7 @@ function testClientStart (t, serverType) {
t.equal(typeof data.incomplete, 'number') t.equal(typeof data.incomplete, 'number')
}) })
client.once('peer', function (addr) { client.once('peer', function () {
t.pass('there is at least one peer') t.pass('there is at least one peer')
client.stop() client.stop()
@ -186,7 +186,7 @@ function testClientAnnounceWithNumWant (t, serverType) {
}) })
client1.start() client1.start()
client1.once('update', function (data) { client1.once('update', function () {
var client2 = new Client(peerId2, port + 1, parsedTorrent) var client2 = new Client(peerId2, port + 1, parsedTorrent)
client2.on('error', function (err) { client2.on('error', function (err) {
t.error(err) t.error(err)

View File

@ -7,7 +7,6 @@ var fs = require('fs')
var http = require('http') var http = require('http')
var parseTorrent = require('parse-torrent') var parseTorrent = require('parse-torrent')
var portfinder = require('portfinder') var portfinder = require('portfinder')
var querystring = require('querystring')
var Server = require('../').Server var Server = require('../').Server
var test = require('tape') var test = require('tape')
@ -28,7 +27,6 @@ var peerId = new Buffer('01234567890123456789')
function testSingle (t, serverType) { function testSingle (t, serverType) {
commonTest.createServer(t, serverType, function (server, announceUrl) { commonTest.createServer(t, serverType, function (server, announceUrl) {
var scrapeUrl = announceUrl.replace('announce', 'scrape')
server.once('listening', function () { server.once('listening', function () {
Client.scrape(announceUrl, infoHash1, function (err, data) { Client.scrape(announceUrl, infoHash1, function (err, data) {
t.error(err) t.error(err)
@ -118,7 +116,7 @@ test('server: multiple info_hash scrape', function (t) {
t.end() t.end()
}) })
})) }))
}).on('error', function (e) { }).on('error', function (err) {
t.error(err) t.error(err)
}) })
}) })
@ -151,7 +149,7 @@ test('server: all info_hash scrape', function (t) {
}) })
client.start() client.start()
server.once('start', function (data) { server.once('start', function () {
// now do a scrape of everything by omitting the info_hash param // now do a scrape of everything by omitting the info_hash param
http.get(scrapeUrl, function (res) { http.get(scrapeUrl, function (res) {
@ -172,7 +170,7 @@ test('server: all info_hash scrape', function (t) {
t.end() t.end()
}) })
})) }))
}).on('error', function (e) { }).on('error', function (err) {
t.error(err) t.error(err)
}) })
}) })