diff --git a/package.json b/package.json index 524e2dd..27267d3 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "node": ">=0.10.0" }, "scripts": { - "test": "tape test/test-*.js | tap-dot", + "test": "tap test/test-*.js", "coverage": "istanbul cover tape --report html -- test/test-*.js" }, "files": [ @@ -57,7 +57,6 @@ "from2-array": "0.0.3", "istanbul": "^0.3.13", "pem": "^1.4.4", - "tap-dot": "^1.0.0", - "tape": "^3.5.0" + "tap": "^1.0.0" } } diff --git a/test/test-arguments.js b/test/test-arguments.js index 1c954f2..d4d9486 100644 --- a/test/test-arguments.js +++ b/test/test-arguments.js @@ -1,5 +1,5 @@ 'use strict'; -var tape = require('tape'); +var test = require('tap').test; var got = require('../'); var server = require('./server.js'); var s = server.createServer(); @@ -12,20 +12,20 @@ s.on('/?test=wow', function (req, res) { res.end(req.url); }); -tape('setup', function (t) { +test('setup', function (t) { s.listen(s.port, function () { t.end(); }); }); -tape('url argument is required', function (t) { +test('url argument is required', function (t) { t.throws(function () { got(); }, /Parameter `url` must be a string or object, not undefined/); t.end(); }); -tape('accepts url.parse object as first argument', function (t) { +test('accepts url.parse object as first argument', function (t) { got({host: s.host, port: s.port, path: '/test'}, function (err, data) { t.error(err); t.equal(data, '/test'); @@ -33,7 +33,7 @@ tape('accepts url.parse object as first argument', function (t) { }); }); -tape('overrides querystring from opts', function (t) { +test('overrides querystring from opts', function (t) { got(s.url + '/?test=doge', {query: {test: 'wow'}}, function (err, data) { t.error(err); t.equal(data, '/?test=wow'); @@ -41,7 +41,7 @@ tape('overrides querystring from opts', function (t) { }); }); -tape('cleanup', function (t) { +test('cleanup', function (t) { s.close(); t.end(); }); diff --git a/test/test-error.js b/test/test-error.js index 2ae0239..fee3bb9 100644 --- a/test/test-error.js +++ b/test/test-error.js @@ -1,5 +1,5 @@ 'use strict'; -var tape = require('tape'); +var test = require('tap').test; var got = require('../'); var server = require('./server.js'); var s = server.createServer(); @@ -9,13 +9,13 @@ s.on('/', function (req, res) { res.end('not'); }); -tape('setup', function (t) { +test('setup', function (t) { s.listen(s.port, function () { t.end(); }); }); -tape('error message', function (t) { +test('error message', function (t) { got(s.url, function (err) { t.ok(err); t.equal(err.message, 'GET http://localhost:6767 response code is 404 (Not Found)'); @@ -23,7 +23,7 @@ tape('error message', function (t) { }); }); -tape('dns error message', function (t) { +test('dns error message', function (t) { got('.com', function (err) { t.ok(err); t.equal(err.message, 'Request to http://.com failed'); @@ -33,14 +33,14 @@ tape('dns error message', function (t) { }); }); -tape('options.body error message', function (t) { +test('options.body error message', function (t) { t.throws(function () { got(s.url, {body: {}}); }, /options.body must be a ReadableStream, string or Buffer/); t.end(); }); -tape('cleanup', function (t) { +test('cleanup', function (t) { s.close(); t.end(); }); diff --git a/test/test-gzip.js b/test/test-gzip.js index 7391ce6..a04bfd4 100644 --- a/test/test-gzip.js +++ b/test/test-gzip.js @@ -1,6 +1,6 @@ 'use strict'; var zlib = require('zlib'); -var tape = require('tape'); +var test = require('tap').test; var got = require('../'); var server = require('./server.js'); var s = server.createServer(); @@ -22,13 +22,13 @@ s.on('/corrupted', function (req, res) { res.end('Not gzipped content'); }); -tape('setup', function (t) { +test('setup', function (t) { s.listen(s.port, function () { t.end(); }); }); -tape('ungzip content', function (t) { +test('ungzip content', function (t) { got(s.url, function (err, data) { t.error(err); t.equal(data, testContent); @@ -36,7 +36,7 @@ tape('ungzip content', function (t) { }); }); -tape('ungzip error', function (t) { +test('ungzip error', function (t) { got(s.url + '/corrupted', function (err) { t.ok(err); t.equal(err.message, 'Reading ' + s.url + '/corrupted response failed'); @@ -44,7 +44,7 @@ tape('ungzip error', function (t) { }); }); -tape('preserve headers property', function (t) { +test('preserve headers property', function (t) { got(s.url, function (err, data, res) { t.error(err); t.ok(res.headers); @@ -52,7 +52,7 @@ tape('preserve headers property', function (t) { }); }); -tape('cleanup', function (t) { +test('cleanup', function (t) { s.close(); t.end(); }); diff --git a/test/test-headers.js b/test/test-headers.js index 5424b24..fb81af2 100644 --- a/test/test-headers.js +++ b/test/test-headers.js @@ -1,5 +1,5 @@ 'use strict'; -var tape = require('tape'); +var test = require('tap').test; var got = require('../'); var server = require('./server.js'); var s = server.createServer(); @@ -8,13 +8,13 @@ s.on('/', function (req, res) { res.end(JSON.stringify(req.headers)); }); -tape('setup', function (t) { +test('setup', function (t) { s.listen(s.port, function () { t.end(); }); }); -tape('send user-agent header by default', function (t) { +test('send user-agent header by default', function (t) { got(s.url, function (err, data) { var headers = JSON.parse(data); @@ -23,7 +23,7 @@ tape('send user-agent header by default', function (t) { }); }); -tape('send accept-encoding header by default', function (t) { +test('send accept-encoding header by default', function (t) { got(s.url, function (err, data) { var headers = JSON.parse(data); @@ -32,14 +32,14 @@ tape('send accept-encoding header by default', function (t) { }); }); -tape('send accept header with json option', function (t) { +test('send accept header with json option', function (t) { got(s.url, {json: true}, function (err, headers) { t.equal(headers.accept, 'application/json'); t.end(); }); }); -tape('send host header by default', function (t) { +test('send host header by default', function (t) { got(s.url, function (err, data) { var headers = JSON.parse(data); @@ -48,7 +48,7 @@ tape('send host header by default', function (t) { }); }); -tape('transform headers names to lowercase', function (t) { +test('transform headers names to lowercase', function (t) { got(s.url, {headers: {'USER-AGENT': 'test'}}, function (err, data) { var headers = JSON.parse(data); @@ -57,7 +57,7 @@ tape('transform headers names to lowercase', function (t) { }); }); -tape('cleanup', function (t) { +test('cleanup', function (t) { s.close(); t.end(); }); diff --git a/test/test-helpers.js b/test/test-helpers.js index a71077c..0bdf2d1 100644 --- a/test/test-helpers.js +++ b/test/test-helpers.js @@ -1,5 +1,5 @@ 'use strict'; -var tape = require('tape'); +var test = require('tap').test; var got = require('../'); var server = require('./server.js'); var s = server.createServer(); @@ -8,13 +8,13 @@ s.on('/', function (req, res) { res.end('ok'); }); -tape('setup', function (t) { +test('setup', function (t) { s.listen(s.port, function () { t.end(); }); }); -tape('callback mode', {timeout: 1000}, function (t) { +test('callback mode', {timeout: 1000}, function (t) { got.get(s.url, function (err, data) { t.error(err); t.equal(data, 'ok'); @@ -22,7 +22,7 @@ tape('callback mode', {timeout: 1000}, function (t) { }); }); -tape('stream mode', {timeout: 1000}, function (t) { +test('stream mode', {timeout: 1000}, function (t) { got.get(s.url) .on('data', function (data) { t.equal(data.toString(), 'ok'); @@ -30,7 +30,7 @@ tape('stream mode', {timeout: 1000}, function (t) { }); }); -tape('cleanup', function (t) { +test('cleanup', function (t) { s.close(); t.end(); }); diff --git a/test/test-http.js b/test/test-http.js index 1dec893..df909a4 100644 --- a/test/test-http.js +++ b/test/test-http.js @@ -1,5 +1,5 @@ 'use strict'; -var tape = require('tape'); +var test = require('tap').test; var got = require('../'); var server = require('./server.js'); var s = server.createServer(); @@ -23,13 +23,13 @@ s.on('/?recent=true', function (req, res) { res.end('recent'); }); -tape('setup', function (t) { +test('setup', function (t) { s.listen(s.port, function () { t.end(); }); }); -tape('callback mode', function (t) { +test('callback mode', function (t) { got(s.url, function (err, data) { t.error(err); t.equal(data, 'ok'); @@ -37,7 +37,7 @@ tape('callback mode', function (t) { }); }); -tape('protocol-less URLs', function (t) { +test('protocol-less URLs', function (t) { got(s.url.replace(/^http:\/\//, ''), function (err, data) { t.error(err); t.equal(data, 'ok'); @@ -45,7 +45,7 @@ tape('protocol-less URLs', function (t) { }); }); -tape('empty response', function (t) { +test('empty response', function (t) { got(s.url + '/empty', function (err, data) { t.error(err); t.equal(data, ''); @@ -53,7 +53,7 @@ tape('empty response', function (t) { }); }); -tape('error with code', function (t) { +test('error with code', function (t) { got(s.url + '/404', function (err, data) { t.ok(err); t.equal(err.code, 404); @@ -62,7 +62,7 @@ tape('error with code', function (t) { }); }); -tape('buffer on encoding === null', function (t) { +test('buffer on encoding === null', function (t) { got(s.url, {encoding: null}, function (err, data) { t.error(err); t.ok(Buffer.isBuffer(data)); @@ -70,7 +70,7 @@ tape('buffer on encoding === null', function (t) { }); }); -tape('stream mode', function (t) { +test('stream mode', function (t) { got(s.url) .on('data', function (data) { t.equal(data.toString(), 'ok'); @@ -78,7 +78,7 @@ tape('stream mode', function (t) { }); }); -tape('emit response object to stream', function (t) { +test('emit response object to stream', function (t) { got(s.url) .on('response', function (res) { t.ok(res); @@ -87,7 +87,7 @@ tape('emit response object to stream', function (t) { }); }); -tape('proxy errors to the stream', function (t) { +test('proxy errors to the stream', function (t) { got(s.url + '/404') .on('error', function (err, data, res) { t.equal(err.code, 404); @@ -97,7 +97,7 @@ tape('proxy errors to the stream', function (t) { }); }); -tape('timeout option', function (t) { +test('timeout option', function (t) { got(s.url + '/404', {timeout: 1}) .on('error', function (err) { t.equal(err.code, 'ETIMEDOUT'); @@ -105,7 +105,7 @@ tape('timeout option', function (t) { }); }); -tape('query option', function (t) { +test('query option', function (t) { t.plan(2); got(s.url, {query: {recent: true}}, function (err, data) { @@ -117,7 +117,7 @@ tape('query option', function (t) { }); }); -tape('cleanup', function (t) { +test('cleanup', function (t) { s.close(); t.end(); }); diff --git a/test/test-https.js b/test/test-https.js index a6d21e3..594820e 100644 --- a/test/test-https.js +++ b/test/test-https.js @@ -1,5 +1,5 @@ 'use strict'; -var tape = require('tape'); +var test = require('tap').test; var pem = require('pem'); var got = require('../'); var server = require('./server.js'); @@ -10,7 +10,7 @@ var cert; var caRootKey; var caRootCert; -tape('root pem', function (t) { +test('root pem', function (t) { pem.createCertificate({ days: 1, selfSigned: true @@ -21,7 +21,7 @@ tape('root pem', function (t) { }); }); -tape('pem', function (t) { +test('pem', function (t) { pem.createCertificate({ serviceCertificate: caRootCert, serviceKey: caRootKey, @@ -40,7 +40,7 @@ tape('pem', function (t) { }); }); -tape('setup', function (t) { +test('setup', function (t) { s = server.createSSLServer(server.portSSL + 1, { key: key, cert: cert @@ -55,7 +55,7 @@ tape('setup', function (t) { }); }); -tape('make request to https server', function (t) { +test('make request to https server', function (t) { got('https://google.com', { strictSSL: true }, function (err, data) { @@ -65,7 +65,7 @@ tape('make request to https server', function (t) { }); }); -tape('make request to https server with ca', function (t) { +test('make request to https server with ca', function (t) { got(s.url, { strictSSL: true, ca: caRootCert, @@ -77,7 +77,7 @@ tape('make request to https server with ca', function (t) { }); }); -tape('cleanup', function (t) { +test('cleanup', function (t) { s.close(); t.end(); }); diff --git a/test/test-json.js b/test/test-json.js index 4427d2e..cd67fd1 100644 --- a/test/test-json.js +++ b/test/test-json.js @@ -1,5 +1,5 @@ 'use strict'; -var tape = require('tape'); +var test = require('tap').test; var got = require('../'); var server = require('./server.js'); var s = server.createServer(); @@ -22,20 +22,20 @@ s.on('/non200-invalid', function (req, res) { res.end('Internal error'); }); -tape('setup', function (t) { +test('setup', function (t) { s.listen(s.port, function () { t.end(); }); }); -tape('json option can not be used in stream mode', function (t) { +test('json option can not be used in stream mode', function (t) { t.throws(function () { got(s.url, {json: true}); }, 'got can not be used as stream when options.json is used'); t.end(); }); -tape('json option should parse response', function (t) { +test('json option should parse response', function (t) { got(s.url, {json: true}, function (err, json) { t.error(err); t.deepEqual(json, {data: 'dog'}); @@ -43,7 +43,7 @@ tape('json option should parse response', function (t) { }); }); -tape('json option wrap parsing errors', function (t) { +test('json option wrap parsing errors', function (t) { got(s.url + '/invalid', {json: true}, function (err) { t.ok(err); t.equal(err.message, 'Parsing ' + s.url + '/invalid response failed'); @@ -53,7 +53,7 @@ tape('json option wrap parsing errors', function (t) { }); }); -tape('json option should parse non-200 responses', function (t) { +test('json option should parse non-200 responses', function (t) { got(s.url + '/non200', {json: true}, function (err, json) { t.ok(err); t.deepEqual(json, {data: 'dog'}); @@ -61,7 +61,7 @@ tape('json option should parse non-200 responses', function (t) { }); }); -tape('json option should catch errors on invalid non-200 responses', function (t) { +test('json option should catch errors on invalid non-200 responses', function (t) { got(s.url + '/non200-invalid', {json: true}, function (err, json) { t.ok(err); t.deepEqual(json, 'Internal error'); @@ -74,7 +74,7 @@ tape('json option should catch errors on invalid non-200 responses', function (t }); }); -tape('cleanup', function (t) { +test('cleanup', function (t) { s.close(); t.end(); }); diff --git a/test/test-post.js b/test/test-post.js index 00a889b..c10c04a 100644 --- a/test/test-post.js +++ b/test/test-post.js @@ -1,5 +1,5 @@ 'use strict'; -var tape = require('tape'); +var test = require('tap').test; var from2Array = require('from2-array'); var got = require('../'); var server = require('./server.js'); @@ -18,13 +18,13 @@ s.on('/empty', function (req, res) { res.end(); }); -tape('setup', function (t) { +test('setup', function (t) { s.listen(s.port, function () { t.end(); }); }); -tape('GET can have body', function (t) { +test('GET can have body', function (t) { t.plan(3); var stream = from2Array(['wow']); @@ -39,7 +39,7 @@ tape('GET can have body', function (t) { }); }); -tape('send data from options with post request', function (t) { +test('send data from options with post request', function (t) { t.plan(3); got(s.url, {body: 'wow'}, function (err, data) { @@ -55,14 +55,14 @@ tape('send data from options with post request', function (t) { }); }); -tape('works with empty post response', function (t) { +test('works with empty post response', function (t) { got(s.url + '/empty', {body: 'wow'}, function (err, data) { t.equal(data, ''); t.end(); }); }); -tape('return readable stream', function (t) { +test('return readable stream', function (t) { got.post(s.url, {body: from2Array(['wow'])}) .on('data', function (data) { t.equal(data.toString(), 'wow'); @@ -70,7 +70,7 @@ tape('return readable stream', function (t) { }); }); -tape('return writeable stream', function (t) { +test('return writeable stream', function (t) { got.post(s.url) .on('data', function (data) { t.equal(data.toString(), 'wow'); @@ -79,14 +79,14 @@ tape('return writeable stream', function (t) { .end('wow'); }); -tape('throws on write to stream with body specified', function (t) { +test('throws on write to stream with body specified', function (t) { t.throws(function () { got(s.url, {body: 'wow'}).write('wow'); }); setTimeout(t.end.bind(t), 10); // wait for request to end }); -tape('cleanup', function (t) { +test('cleanup', function (t) { s.close(); t.end(); }); diff --git a/test/test-redirects.js b/test/test-redirects.js index 471de03..187d40f 100644 --- a/test/test-redirects.js +++ b/test/test-redirects.js @@ -1,5 +1,5 @@ 'use strict'; -var tape = require('tape'); +var test = require('tap').test; var got = require('../'); var server = require('./server.js'); var s = server.createServer(); @@ -36,13 +36,13 @@ s.on('/', function (req, res) { res.end('reached'); }); -tape('setup', function (t) { +test('setup', function (t) { s.listen(s.port, function () { t.end(); }); }); -tape('follows redirect', function (t) { +test('follows redirect', function (t) { got(s.url + '/finite', function (err, data) { t.error(err); t.equal(data, 'reached'); @@ -50,7 +50,7 @@ tape('follows redirect', function (t) { }); }); -tape('follows relative redirect', function (t) { +test('follows relative redirect', function (t) { got(s.url + '/relative', function (err, data) { t.error(err); t.equal(data, 'reached'); @@ -58,7 +58,7 @@ tape('follows relative redirect', function (t) { }); }); -tape('throws on endless redirect', function (t) { +test('throws on endless redirect', function (t) { got(s.url + '/endless', function (err) { t.ok(err, 'should get error'); t.equal(err.message, 'Redirected 10 times. Aborting.'); @@ -66,7 +66,7 @@ tape('throws on endless redirect', function (t) { }); }); -tape('query in options are not breaking redirects', function (t) { +test('query in options are not breaking redirects', function (t) { got(s.url + '/relativeQuery', {query: 'bang'}, function (err, data) { t.error(err); t.equal(data, 'reached'); @@ -74,7 +74,7 @@ tape('query in options are not breaking redirects', function (t) { }); }); -tape('host+path in options are not breaking redirects', function (t) { +test('host+path in options are not breaking redirects', function (t) { got(s.url + '/relative', {host: s.url, path: '/relative'}, function (err, data) { t.error(err); t.equal(data, 'reached'); @@ -82,7 +82,7 @@ tape('host+path in options are not breaking redirects', function (t) { }); }); -tape('redirect only GET and HEAD requests', function (t) { +test('redirect only GET and HEAD requests', function (t) { got(s.url + '/relative', {body: 'wow'}, function (err, data) { t.equal(err.message, 'POST http://localhost:6767/relative response code is 302 (Found)'); t.equal(err.code, 302); @@ -90,7 +90,7 @@ tape('redirect only GET and HEAD requests', function (t) { }); }); -tape('redirect event', function (t) { +test('redirect event', function (t) { got(s.url + '/endless') .on('redirect', function (res, opts) { t.equal(res.headers.location, s.url + '/endless'); @@ -102,7 +102,7 @@ tape('redirect event', function (t) { }); }); -tape('cleanup', function (t) { +test('cleanup', function (t) { s.close(); t.end(); });