From 16b016f61fa1d95b8e0ecd9409911ab5a31286e4 Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Tue, 19 Nov 2013 11:11:26 -0800 Subject: [PATCH] tests: add a 200 HEAD test purpose of this test is to explictly show how to send a 200 response when a body is not expected (ie HEAD) --- test/application.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/application.js b/test/application.js index 3915d1a..bf93c25 100644 --- a/test/application.js +++ b/test/application.js @@ -61,6 +61,34 @@ describe('app.respond', function(){ done(); }); }) + + it('should respond with a 404 if no body was set', function(done){ + var app = koa(); + + app.use(function *(){ + this.status = 200; + }) + + var server = app.listen(); + + request(server) + .head('/') + .expect(404, done); + }) + + it('should respond with a 200 if body = ""', function(done){ + var app = koa(); + + app.use(function *(){ + this.body = ''; + }) + + var server = app.listen(); + + request(server) + .head('/') + .expect(200, done); + }) }) describe('when no middleware are present', function(){