test: fix body test (#1375)

Setting body will set the content-length header. Unless the
corresponding number of bytes are sent the response will
be aborted and not emit 'end'.
master
Robert Nagy 2019-08-23 12:57:56 +02:00 committed by Yiyu He
parent f75d445535
commit 817b498305
1 changed files with 3 additions and 0 deletions

View File

@ -20,6 +20,7 @@ describe('app.respond', () => {
res.statusCode = 200;
setImmediate(() => {
res.setHeader('Content-Type', 'text/plain');
res.setHeader('Content-Length', '3');
res.end('lol');
});
});
@ -41,6 +42,7 @@ describe('app.respond', () => {
const res = ctx.res;
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.setHeader('Content-Length', '3');
res.end('lol');
ctx.set('foo', 'bar');
});
@ -65,6 +67,7 @@ describe('app.respond', () => {
const res = ctx.res;
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.setHeader('Content-Length', '3');
res.end('lol');
ctx.status = 201;
});