From 77ca4290a1b5cf7d188e87ef3f281c2bffe33003 Mon Sep 17 00:00:00 2001 From: JamesWang Date: Tue, 26 Sep 2017 12:07:57 +0800 Subject: [PATCH] test: replace request(app.listen()) with request(app.callback()) --- test/application/index.js | 4 ++-- test/application/respond.js | 6 +++--- test/application/use.js | 4 ++-- test/context/cookies.js | 2 +- test/context/onerror.js | 2 +- test/response/attachment.js | 2 +- test/response/header.js | 2 +- test/response/status.js | 4 ++-- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/test/application/index.js b/test/application/index.js index 9fa23b2..51d76ba 100644 --- a/test/application/index.js +++ b/test/application/index.js @@ -19,7 +19,7 @@ describe('app', () => { done(); }); - request(app.listen()) + request(app.callback()) .get('/') .end(() => {}); }); @@ -41,7 +41,7 @@ describe('app', () => { // hackish, but the response should occur in a single tick setImmediate(done); - request(app.listen()) + request(app.callback()) .get('/') .end(() => {}); }); diff --git a/test/application/respond.js b/test/application/respond.js index 6602114..65b3751 100644 --- a/test/application/respond.js +++ b/test/application/respond.js @@ -639,7 +639,7 @@ describe('app.respond', () => { done(); }); - request(app.listen()) + request(app.callback()) .get('/') .end(() => {}); }); @@ -655,7 +655,7 @@ describe('app.respond', () => { throw err; }); - return request(app.listen()) + return request(app.callback()) .get('/') .expect(403, 'sorry!'); }); @@ -671,7 +671,7 @@ describe('app.respond', () => { throw err; }); - return request(app.listen()) + return request(app.callback()) .get('/') .expect(403, 'Forbidden'); }); diff --git a/test/application/use.js b/test/application/use.js index 0f32c7a..4d544b7 100644 --- a/test/application/use.js +++ b/test/application/use.js @@ -80,7 +80,7 @@ describe('app.use(fn)', () => { app.use(ctx => ctx.throw('Not Found', 404)); - return request(app.listen()) + return request(app.callback()) .get('/') .expect(404); }); @@ -92,7 +92,7 @@ describe('app.use(fn)', () => { app.use((ctx, next) => next()); app.use(function * (next){ this.body = 'generator'; }); - return request(app.listen()) + return request(app.callback()) .get('/') .expect(200) .expect('generator'); diff --git a/test/context/cookies.js b/test/context/cookies.js index 31bf0f1..c6daf53 100644 --- a/test/context/cookies.js +++ b/test/context/cookies.js @@ -37,7 +37,7 @@ describe('ctx.cookies.set()', () => { } }); - return request(app.listen()) + return request(app.callback()) .get('/') .expect('.keys required for signed cookies'); }); diff --git a/test/context/onerror.js b/test/context/onerror.js index e43331b..87f7556 100644 --- a/test/context/onerror.js +++ b/test/context/onerror.js @@ -102,7 +102,7 @@ describe('ctx.onerror(err)', () => { ctx.body = 'response'; }); - request(app.listen()) + request(app.callback()) .get('/') .expect('X-Foo', 'Bar') .expect(200, () => {}); diff --git a/test/response/attachment.js b/test/response/attachment.js index 41f4eee..5e0f732 100644 --- a/test/response/attachment.js +++ b/test/response/attachment.js @@ -40,7 +40,7 @@ describe('ctx.attachment([filename])', () => { ctx.body = {foo: 'bar'}; }); - return request(app.listen()) + return request(app.callback()) .get('/') .expect('content-disposition', 'attachment; filename="include-no-ascii-char-???-ok.json"; filename*=UTF-8\'\'include-no-ascii-char-%E4%B8%AD%E6%96%87%E5%90%8D-ok.json') .expect({foo: 'bar'}) diff --git a/test/response/header.js b/test/response/header.js index dabbd87..b78c405 100644 --- a/test/response/header.js +++ b/test/response/header.js @@ -29,7 +29,7 @@ describe('res.header', () => { header = Object.assign({}, ctx.response.header); }); - await request(app.listen()) + await request(app.callback()) .get('/'); assert.deepEqual(header, { 'x-foo': '42' }); diff --git a/test/response/status.js b/test/response/status.js index d2e7884..6b7eb07 100644 --- a/test/response/status.js +++ b/test/response/status.js @@ -67,7 +67,7 @@ describe('res.status=', () => { assert(null == ctx.response.header['transfer-encoding']); }); - const res = await request(app.listen()) + const res = await request(app.callback()) .get('/') .expect(status); @@ -88,7 +88,7 @@ describe('res.status=', () => { ctx.set('Transfer-Encoding', 'chunked'); }); - const res = await request(app.listen()) + const res = await request(app.callback()) .get('/') .expect(status);