[Pkg-javascript-commits] [node-static] 94/151: 404 streaming test

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Tue Jan 7 23:18:01 UTC 2014


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch master
in repository node-static.

commit f039e1c54675521782c4142ad70cec3a88b09c12
Author: guybedford <guybedford at Guys-MacBook-Air-2.local>
Date:   Mon Dec 17 00:01:34 2012 +0000

    404 streaming test
---
 test/integration/node-static-test.js | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/test/integration/node-static-test.js b/test/integration/node-static-test.js
index 22afbef..c6a4c26 100644
--- a/test/integration/node-static-test.js
+++ b/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': {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-static.git



More information about the Pkg-javascript-commits mailing list