From 857bc17f9910254e20a655658c49e5a118f2a9aa Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Sun, 8 Oct 2017 12:30:58 +0100 Subject: [PATCH] Use create-test-server in test/timeout.js --- test/timeout.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/test/timeout.js b/test/timeout.js index 9870131..ad6f776 100644 --- a/test/timeout.js +++ b/test/timeout.js @@ -1,22 +1,20 @@ import test from 'ava'; import got from '..'; -import {createServer} from './helpers/server'; +import createTestServer from 'create-test-server'; let s; test.before('setup', async () => { - s = await createServer(); + s = await createTestServer(); - s.on('/', (req, res) => { + s.get('/', (req, res) => { res.statusCode = 200; res.end('OK'); }); - - await s.listen(s.port); }); test('timeout option', async t => { - const err = await t.throws(got(`${s.url}/`, { + const err = await t.throws(got(s.url, { timeout: 1, retries: 0 })); @@ -25,7 +23,7 @@ test('timeout option', async t => { }); test('timeout option as object', async t => { - const err = await t.throws(got(`${s.url}/404`, { + const err = await t.throws(got(s.url, { timeout: {socket: 50, request: 1}, retries: 0 })); @@ -34,7 +32,7 @@ test('timeout option as object', async t => { }); test('socket timeout', async t => { - const err = await t.throws(got(`${s.url}/404`, { + const err = await t.throws(got(s.url, { timeout: {socket: 1}, retries: 0 })); @@ -43,7 +41,7 @@ test('socket timeout', async t => { }); test('connection, request timeout', async t => { - const err = await t.throws(got(`${s.url}/404`, { + const err = await t.throws(got(s.url, { timeout: {socket: 50, request: 1}, retries: 0 }));