test: replace request(app.listen()) with request(app.callback())
This commit is contained in:
parent
7f577aff2d
commit
77ca4290a1
8 changed files with 13 additions and 13 deletions
|
@ -19,7 +19,7 @@ describe('app', () => {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
request(app.listen())
|
request(app.callback())
|
||||||
.get('/')
|
.get('/')
|
||||||
.end(() => {});
|
.end(() => {});
|
||||||
});
|
});
|
||||||
|
@ -41,7 +41,7 @@ describe('app', () => {
|
||||||
// hackish, but the response should occur in a single tick
|
// hackish, but the response should occur in a single tick
|
||||||
setImmediate(done);
|
setImmediate(done);
|
||||||
|
|
||||||
request(app.listen())
|
request(app.callback())
|
||||||
.get('/')
|
.get('/')
|
||||||
.end(() => {});
|
.end(() => {});
|
||||||
});
|
});
|
||||||
|
|
|
@ -639,7 +639,7 @@ describe('app.respond', () => {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
request(app.listen())
|
request(app.callback())
|
||||||
.get('/')
|
.get('/')
|
||||||
.end(() => {});
|
.end(() => {});
|
||||||
});
|
});
|
||||||
|
@ -655,7 +655,7 @@ describe('app.respond', () => {
|
||||||
throw err;
|
throw err;
|
||||||
});
|
});
|
||||||
|
|
||||||
return request(app.listen())
|
return request(app.callback())
|
||||||
.get('/')
|
.get('/')
|
||||||
.expect(403, 'sorry!');
|
.expect(403, 'sorry!');
|
||||||
});
|
});
|
||||||
|
@ -671,7 +671,7 @@ describe('app.respond', () => {
|
||||||
throw err;
|
throw err;
|
||||||
});
|
});
|
||||||
|
|
||||||
return request(app.listen())
|
return request(app.callback())
|
||||||
.get('/')
|
.get('/')
|
||||||
.expect(403, 'Forbidden');
|
.expect(403, 'Forbidden');
|
||||||
});
|
});
|
||||||
|
|
|
@ -80,7 +80,7 @@ describe('app.use(fn)', () => {
|
||||||
|
|
||||||
app.use(ctx => ctx.throw('Not Found', 404));
|
app.use(ctx => ctx.throw('Not Found', 404));
|
||||||
|
|
||||||
return request(app.listen())
|
return request(app.callback())
|
||||||
.get('/')
|
.get('/')
|
||||||
.expect(404);
|
.expect(404);
|
||||||
});
|
});
|
||||||
|
@ -92,7 +92,7 @@ describe('app.use(fn)', () => {
|
||||||
app.use((ctx, next) => next());
|
app.use((ctx, next) => next());
|
||||||
app.use(function * (next){ this.body = 'generator'; });
|
app.use(function * (next){ this.body = 'generator'; });
|
||||||
|
|
||||||
return request(app.listen())
|
return request(app.callback())
|
||||||
.get('/')
|
.get('/')
|
||||||
.expect(200)
|
.expect(200)
|
||||||
.expect('generator');
|
.expect('generator');
|
||||||
|
|
|
@ -37,7 +37,7 @@ describe('ctx.cookies.set()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return request(app.listen())
|
return request(app.callback())
|
||||||
.get('/')
|
.get('/')
|
||||||
.expect('.keys required for signed cookies');
|
.expect('.keys required for signed cookies');
|
||||||
});
|
});
|
||||||
|
|
|
@ -102,7 +102,7 @@ describe('ctx.onerror(err)', () => {
|
||||||
ctx.body = 'response';
|
ctx.body = 'response';
|
||||||
});
|
});
|
||||||
|
|
||||||
request(app.listen())
|
request(app.callback())
|
||||||
.get('/')
|
.get('/')
|
||||||
.expect('X-Foo', 'Bar')
|
.expect('X-Foo', 'Bar')
|
||||||
.expect(200, () => {});
|
.expect(200, () => {});
|
||||||
|
|
|
@ -40,7 +40,7 @@ describe('ctx.attachment([filename])', () => {
|
||||||
ctx.body = {foo: 'bar'};
|
ctx.body = {foo: 'bar'};
|
||||||
});
|
});
|
||||||
|
|
||||||
return request(app.listen())
|
return request(app.callback())
|
||||||
.get('/')
|
.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('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'})
|
.expect({foo: 'bar'})
|
||||||
|
|
|
@ -29,7 +29,7 @@ describe('res.header', () => {
|
||||||
header = Object.assign({}, ctx.response.header);
|
header = Object.assign({}, ctx.response.header);
|
||||||
});
|
});
|
||||||
|
|
||||||
await request(app.listen())
|
await request(app.callback())
|
||||||
.get('/');
|
.get('/');
|
||||||
|
|
||||||
assert.deepEqual(header, { 'x-foo': '42' });
|
assert.deepEqual(header, { 'x-foo': '42' });
|
||||||
|
|
|
@ -67,7 +67,7 @@ describe('res.status=', () => {
|
||||||
assert(null == ctx.response.header['transfer-encoding']);
|
assert(null == ctx.response.header['transfer-encoding']);
|
||||||
});
|
});
|
||||||
|
|
||||||
const res = await request(app.listen())
|
const res = await request(app.callback())
|
||||||
.get('/')
|
.get('/')
|
||||||
.expect(status);
|
.expect(status);
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ describe('res.status=', () => {
|
||||||
ctx.set('Transfer-Encoding', 'chunked');
|
ctx.set('Transfer-Encoding', 'chunked');
|
||||||
});
|
});
|
||||||
|
|
||||||
const res = await request(app.listen())
|
const res = await request(app.callback())
|
||||||
.get('/')
|
.get('/')
|
||||||
.expect(status);
|
.expect(status);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue