|
|
@ -91,3 +91,18 @@ test('opts.certificate is passed through to createCert()', async t => { |
|
|
|
}); |
|
|
|
t.is(body, 'bar'); |
|
|
|
}); |
|
|
|
|
|
|
|
test('support returning body directly', async t => { |
|
|
|
const server = await createTestServer(); |
|
|
|
|
|
|
|
server.get('/foo', () => 'bar'); |
|
|
|
server.get('/bar', () => ({ foo: 'bar' })); |
|
|
|
server.get('/async', () => Promise.resolve('bar')); |
|
|
|
|
|
|
|
const bodyString = (await got(server.url + '/foo')).body; |
|
|
|
const bodyJson = (await got(server.url + '/bar', { json: true })).body; |
|
|
|
const bodyAsync = (await got(server.url + '/async')).body; |
|
|
|
t.deepEqual(bodyString, 'bar'); |
|
|
|
t.deepEqual(bodyJson, { foo: 'bar' }); |
|
|
|
t.deepEqual(bodyAsync, 'bar'); |
|
|
|
}); |
|
|
|