Permalink
Browse files

404 streaming test

  • Loading branch information...
guybedford guybedford
guybedford authored and guybedford committed Dec 17, 2012
1 parent fb495dc commit f039e1c54675521782c4142ad70cec3a88b09c12
Showing with 23 additions and 2 deletions.
  1. +23 −2 test/integration/node-static-test.js
@@ -10,13 +10,17 @@ var suite = vows.describe('node-static');
var TEST_PORT = 8080;
var TEST_SERVER = 'http://localhost:' + TEST_PORT;
var server;
+var callback;
suite.addBatch({
'once an http server is listening': {
topic: function () {
server = require('http').createServer(function (request, response) {
request.addListener('end', function () {
- fileServer.serve(request, response);
+ fileServer.serve(request, response, function(err, result) {
+ if (callback)
+ callback(request, response, err, result);
+ });
});
}).listen(TEST_PORT, this.callback)
},
@@ -25,7 +29,7 @@ suite.addBatch({
* A topic without tests will be not executed */
assert.isTrue(true);
}
- }
+ },
}).addBatch({
'requesting a file not found': {
topic : function(){
@@ -34,6 +38,23 @@ suite.addBatch({
'should respond with 404' : function(error, response, body){
assert.equal(response.statusCode, 404);
}
+ },
+ 'streaming a 404 page': {
+ topic: function(){
+ callback = function(request, response, err, result) {
+ if (err) {
+ response.writeHead(err.status, err.headers);
+ setTimeout(function() {
+ response.end('Custom 404 Stream.')
+ }, 100);
+ }
+ }
+ request.get(TEST_SERVER + '/not-found', this.callback);
+ },
+ 'should respond with the streamed content': function(error, response, body){
+ callback = null;
+ assert.equal(body, 'Custom 404 Stream.');
+ }
}
}).addBatch({
'serving hello.txt': {

0 comments on commit f039e1c

Please sign in to comment.