|
@ -34,7 +34,7 @@ test.before('setup', async () => { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
test('parses response', async t => { |
|
|
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 => { |
|
|
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'); |
|
|
t.fail('Exception was not thrown'); |
|
|
} catch (err) { |
|
|
} catch (err) { |
|
|
t.regex(err.message, /Unexpected token/); |
|
|
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'); |
|
|
t.is(err.path, '/invalid'); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
@ -58,7 +58,7 @@ test('parses non-200 responses', async t => { |
|
|
await got(`${s.url}/non200`, {json: true}); |
|
|
await got(`${s.url}/non200`, {json: true}); |
|
|
t.fail('Exception was not thrown'); |
|
|
t.fail('Exception was not thrown'); |
|
|
} catch (err) { |
|
|
} catch (err) { |
|
|
t.same(err.response.body, {data: 'dog'}); |
|
|
t.deepEqual(err.response.body, {data: 'dog'}); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|