diff --git a/package.json b/package.json index 7a1f7f9..b65e4bc 100644 --- a/package.json +++ b/package.json @@ -59,11 +59,11 @@ "url-parse-lax": "^1.0.0" }, "devDependencies": { - "ava": "^0.5.0", + "ava": "^0.7.0", "coveralls": "^2.11.4", "get-port": "^2.0.0", "into-stream": "^2.0.0", - "nyc": "^3.2.2", + "nyc": "^4.0.1", "pem": "^1.4.4", "pify": "^2.3.0", "tempfile": "^1.1.1", diff --git a/test/arguments.js b/test/arguments.js index 4221989..6c4ef34 100644 --- a/test/arguments.js +++ b/test/arguments.js @@ -36,8 +36,8 @@ test('options are optional', async t => { t.is((await got(`${s.url}/test`)).body, '/test'); }); -test('options are optional', t => { - got(`${s.url}/test`, function (err, data) { +test.cb('options are optional', t => { + got(`${s.url}/test`, (err, data) => { t.is(data, '/test'); t.end(); }); diff --git a/test/helpers.js b/test/helpers.js index 58bead5..c8d4cb2 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -19,8 +19,8 @@ test.before('setup', async t => { await s.listen(s.port); }); -test('callback mode', t => { - got.get(s.url, function (err, body) { +test.cb('callback mode', t => { + got.get(s.url, (err, body) => { t.ifError(err); t.is(body, 'ok'); t.end(); diff --git a/test/post.js b/test/post.js index 55aadac..5557940 100644 --- a/test/post.js +++ b/test/post.js @@ -1,5 +1,3 @@ -/**/ - import test from 'ava'; import intoStream from 'into-stream'; import got from '../'; diff --git a/test/stream.js b/test/stream.js index d51ad36..0663f53 100644 --- a/test/stream.js +++ b/test/stream.js @@ -35,7 +35,6 @@ test('option.json can not be used', t => { t.throws(() => { got.stream(s.url, {json: true}); }, 'got can not be used as stream when options.json is used'); - t.end(); }); test('callback can not be used', t => { @@ -46,11 +45,9 @@ test('callback can not be used', t => { t.throws(() => { got.stream(s.url, () => {}); }, 'callback can not be used with stream mode'); - - t.end(); }); -test('returns readable stream', t => { +test.cb('returns readable stream', t => { got.stream(s.url) .on('data', data => { t.is(data.toString(), 'ok'); @@ -58,25 +55,25 @@ test('returns readable stream', t => { }); }); -test('returns writeable stream', t => { - t.plan(1); +test.cb('returns writeable stream', t => { got.stream.post(`${s.url}/post`) .on('data', data => { t.is(data.toString(), 'wow'); + t.end(); }) .end('wow'); }); -test('throws on write to stream with body specified', t => { +test.cb('throws on write to stream with body specified', t => { t.throws(() => { got.stream(s.url, {body: 'wow'}).write('wow'); }, 'got\'s stream is not writable when options.body is used'); // wait for request to end - setTimeout(t.end.bind(t), 10); + setTimeout(t.end, 10); }); -test('have request event', t => { +test.cb('have request event', t => { got.stream(s.url) .on('request', req => { t.ok(req); @@ -84,7 +81,7 @@ test('have request event', t => { }); }); -test('have redirect event', t => { +test.cb('have redirect event', t => { got.stream(`${s.url}/redirect`) .on('redirect', res => { t.is(res.headers.location, s.url); @@ -92,7 +89,7 @@ test('have redirect event', t => { }); }); -test('have response event', t => { +test.cb('have response event', t => { got.stream(s.url) .on('response', res => { t.is(res.statusCode, 200); @@ -100,7 +97,7 @@ test('have response event', t => { }); }); -test('have error event', t => { +test.cb('have error event', t => { got.stream(`${s.url}/error`, {retries: 0}) .on('response', () => { t.fail('response event should not be emitted'); @@ -113,7 +110,7 @@ test('have error event', t => { }); }); -test('have error event', t => { +test.cb('have error event', t => { got.stream('.com', {retries: 0}) .on('response', () => { t.fail('response event should not be emitted'); @@ -124,7 +121,7 @@ test('have error event', t => { }); }); -test('accepts option.body as Stream', t => { +test.cb('accepts option.body as Stream', t => { got.stream(`${s.url}/post`, {body: intoStream(['wow'])}) .on('data', chunk => { t.is(chunk.toString(), 'wow');