From 9a45d07feaa5dbe3304e57d68c06d714ac42e432 Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Tue, 15 Apr 2014 08:37:48 -0700 Subject: [PATCH] add string HEAD support test --- test/application.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/test/application.js b/test/application.js index 962b09f..52ba891 100644 --- a/test/application.js +++ b/test/application.js @@ -163,7 +163,7 @@ describe('app.respond', function(){ }); }) - it('should keep the headers', function(done){ + it('should keep json headers', function(done){ var app = koa(); app.use(function *(){ @@ -184,6 +184,27 @@ describe('app.respond', function(){ }); }) + it('should keep string headers', function(done){ + var app = koa(); + + app.use(function *(){ + this.body = 'hello world'; + }); + + var server = app.listen(); + + request(server) + .head('/') + .expect(200) + .end(function(err, res){ + if (err) return done(err); + res.should.have.header('Content-Type', 'text/plain; charset=utf-8'); + res.should.have.header('Content-Length', '11'); + assert(0 == res.text.length); + done(); + }); + }) + it('should respond with a 404 if no body was set', function(done){ var app = koa();