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'.
This commit is contained in:
Robert Nagy 2019-08-23 12:57:56 +02:00 committed by Yiyu He
parent f75d445535
commit 817b498305

View file

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