diff --git a/package.json b/package.json index 8aad372..35a9fa9 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "url-parse-lax": "^1.0.0" }, "devDependencies": { - "ava": "^0.13.0", + "ava": "^0.14.0", "coveralls": "^2.11.4", "get-port": "^2.0.0", "into-stream": "^2.0.0", diff --git a/test/error.js b/test/error.js index e81cdae..7630e48 100644 --- a/test/error.js +++ b/test/error.js @@ -20,10 +20,10 @@ test('properties', async t => { await got(s.url); t.fail('Exception was not thrown'); } catch (err) { - t.ok(err); - t.ok(err.response); - t.ok(!err.propertyIsEnumerable('response')); - t.ok(!err.hasOwnProperty('code')); + t.truthy(err); + t.truthy(err.response); + t.truthy(!err.propertyIsEnumerable('response')); + t.truthy(!err.hasOwnProperty('code')); t.is(err.message, 'Response code 404 (Not Found)'); t.is(err.host, `${s.host}:${s.port}`); t.is(err.method, 'GET'); @@ -35,7 +35,7 @@ test('dns message', async t => { await got('.com', {retries: 0}); t.fail('Exception was not thrown'); } catch (err) { - t.ok(err); + t.truthy(err); t.regex(err.message, /getaddrinfo ENOTFOUND/); t.is(err.host, '.com'); t.is(err.method, 'GET'); diff --git a/test/gzip.js b/test/gzip.js index 07466c4..f9d6e46 100644 --- a/test/gzip.js +++ b/test/gzip.js @@ -49,7 +49,7 @@ test('handles gzip error', async t => { }); test('preserve headers property', async t => { - t.ok((await got(s.url)).headers); + t.truthy((await got(s.url)).headers); }); test('do not break HEAD responses', async t => { diff --git a/test/helpers.js b/test/helpers.js index b07bf11..778a6db 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -33,7 +33,7 @@ test('promise mode', async t => { await got.get('.com', {retries: 0}); t.fail('Exception was not thrown'); } catch (err) { - t.ok(err); + t.truthy(err); } }); diff --git a/test/http.js b/test/http.js index b9bdf4e..cb6b075 100644 --- a/test/http.js +++ b/test/http.js @@ -53,7 +53,7 @@ test('error with code', async t => { test('buffer on encoding === null', async t => { const data = (await got(s.url, {encoding: null})).body; - t.ok(Buffer.isBuffer(data)); + t.truthy(Buffer.isBuffer(data)); }); test('timeout option', async t => { diff --git a/test/https.js b/test/https.js index 01945b5..5d818a7 100644 --- a/test/https.js +++ b/test/https.js @@ -39,7 +39,7 @@ test.before('setup', async () => { }); test('make request to https server without ca', async t => { - t.ok((await got(s.url, {rejectUnauthorized: false})).body); + t.truthy((await got(s.url, {rejectUnauthorized: false})).body); }); test('make request to https server with ca', async t => { diff --git a/test/json.js b/test/json.js index 617bc12..5ac0551 100644 --- a/test/json.js +++ b/test/json.js @@ -34,7 +34,7 @@ test.before('setup', async () => { }); test('parses response', async t => { - t.same((await got(s.url, {json: true})).body, {data: 'dog'}); + t.deepEqual((await got(s.url, {json: true})).body, {data: 'dog'}); }); test('not parses responses without a body', async t => { @@ -48,7 +48,7 @@ test('wraps parsing errors', async t => { t.fail('Exception was not thrown'); } catch (err) { t.regex(err.message, /Unexpected token/); - t.ok(err.message.indexOf(err.hostname) !== -1, err.message); + t.truthy(err.message.indexOf(err.hostname) !== -1, err.message); t.is(err.path, '/invalid'); } }); @@ -58,7 +58,7 @@ test('parses non-200 responses', async t => { await got(`${s.url}/non200`, {json: true}); t.fail('Exception was not thrown'); } catch (err) { - t.same(err.response.body, {data: 'dog'}); + t.deepEqual(err.response.body, {data: 'dog'}); } }); diff --git a/test/redirects.js b/test/redirects.js index 65f856d..320850d 100644 --- a/test/redirects.js +++ b/test/redirects.js @@ -123,7 +123,7 @@ test('redirect only GET and HEAD requests', async t => { }); test('redirects from http to https works', async t => { - t.ok((await got(`${http.url}/httpToHttps`, {rejectUnauthorized: false})).body); + t.truthy((await got(`${http.url}/httpToHttps`, {rejectUnauthorized: false})).body); }); test('redirects works with lowercase method', async t => { diff --git a/test/retry.js b/test/retry.js index d8045d9..6d0872c 100644 --- a/test/retry.js +++ b/test/retry.js @@ -40,7 +40,7 @@ test('can be disabled with option', async t => { await got(`${s.url}/try-me`, {timeout: 500, retries: 0}); t.fail(); } catch (err) { - t.ok(err); + t.truthy(err); t.is(trys, 1); } }); @@ -54,18 +54,18 @@ test('falsy value prevents retries', async t => { try { await got(`${s.url}/long`, {timeout: 100, retries: () => 0}); } catch (err) { - t.ok(err); + t.truthy(err); } }); test('falsy value prevents retries #2', async t => { try { await got(`${s.url}/long`, {timeout: 100, retries: (iter, err) => { - t.ok(err); + t.truthy(err); return false; }}); } catch (err) { - t.ok(err); + t.truthy(err); } }); diff --git a/test/stream.js b/test/stream.js index b7b9359..530dd59 100644 --- a/test/stream.js +++ b/test/stream.js @@ -66,7 +66,7 @@ test.cb('throws on write to stream with body specified', t => { test.cb('have request event', t => { got.stream(s.url) .on('request', req => { - t.ok(req); + t.truthy(req); t.end(); }); }); @@ -95,7 +95,7 @@ test.cb('have error event', t => { .on('error', (err, data, res) => { t.is(err.message, 'Response code 404 (Not Found)'); t.is(null, data); - t.ok(res); + t.truthy(res); t.end(); }); });