Skip to content

Commit

Permalink
refactor throw assertion tests: ava requires a function
Browse files Browse the repository at this point in the history
Regex used:
(t)hrows\(([^(].*)\);
$1hrows(() => $2);
  • Loading branch information
davidgovea committed Feb 14, 2019
1 parent ec34ede commit 5613fdb
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions test/node.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ test('should accept valid auth("user:pass") usage', t => {

test('should allow chaining of `auth` and an HTTP method', async t => {
const api = new Frisbee(options);
await t.notThrows(api.auth('foo', 'bar').get('/'));
await t.notThrows(() => api.auth('foo', 'bar').get('/'));
});

test('should allow removal of auth() header', t => {
Expand All @@ -68,29 +68,29 @@ test('should allow removal of auth() header', t => {

test('should throw an error if we fail to pass a string `path`', async t => {
const api = new Frisbee(options);
const error = await t.throws(api.get({}));
const error = await t.throws(() => api.get({}));
t.is(error.message, '`path` must be a string');
});

test(`should throw an error if we fail to pass an object options`, async t => {
const api = new Frisbee(options);
let error = await t.throws(api.get('', []));
let error = await t.throws(() => api.get('', []));
t.is(error.message, '`options` must be an object');
error = await t.throws(api.get('', 1));
error = await t.throws(() => api.get('', 1));
t.is(error.message, '`options` must be an object');
});

test('should throw an error if we pass a non object `options`', async t => {
const api = new Frisbee(options);
const error = await t.throws(api.get('', false));
const error = await t.throws(() => api.get('', false));
t.is(error.message, '`options` must be an object');
});

test(
oneLine`should automatically set options to an empty object if not set`,
async t => {
const api = new Frisbee(options);
await t.notThrows(api.get(''));
await t.notThrows(() => api.get(''));
}
);

Expand All @@ -99,9 +99,9 @@ test(
if headers with value ""|null|undefined`,
async t => {
const api = new Frisbee(options);
await t.notThrows(api.get('', { headers: { empty: '' } }));
await t.notThrows(api.get('', { headers: { null: null } }));
await t.notThrows(api.get('', { headers: { undefine: undefined } }));
await t.notThrows(() => api.get('', { headers: { empty: '' } }));
await t.notThrows(() => api.get('', { headers: { null: null } }));
await t.notThrows(() => api.get('', { headers: { undefine: undefined } }));
}
);

Expand Down

0 comments on commit 5613fdb

Please sign in to comment.