test: replace request(app.listen()) with request(app.callback())

This commit is contained in:
JamesWang 2017-09-26 12:07:57 +08:00 committed by Yiyu He
parent 7f577aff2d
commit 77ca4290a1
8 changed files with 13 additions and 13 deletions

View file

@ -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(() => {});
});

View file

@ -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');
});

View file

@ -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');

View file

@ -37,7 +37,7 @@ describe('ctx.cookies.set()', () => {
}
});
return request(app.listen())
return request(app.callback())
.get('/')
.expect('.keys required for signed cookies');
});

View file

@ -102,7 +102,7 @@ describe('ctx.onerror(err)', () => {
ctx.body = 'response';
});
request(app.listen())
request(app.callback())
.get('/')
.expect('X-Foo', 'Bar')
.expect(200, () => {});

View file

@ -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'})

View file

@ -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' });

View file

@ -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);