[Pkg-javascript-commits] [node-static] 95/151: added both use cases

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 ed49feb4f40e862b975ed6c88cdc4a6c1c41fb96
Author: guybedford <guybedford at Guys-MacBook-Air-2.local>
Date:   Mon Dec 17 00:11:41 2012 +0000

    added both use cases
---
 test/integration/node-static-test.js | 40 ++++++++++++++++++++++++++++--------
 1 file changed, 31 insertions(+), 9 deletions(-)

diff --git a/test/integration/node-static-test.js b/test/integration/node-static-test.js
index c6a4c26..ae6d732 100644
--- a/test/integration/node-static-test.js
+++ b/test/integration/node-static-test.js
@@ -13,13 +13,15 @@ var server;
 var callback;
 
 suite.addBatch({
-  'once an http server is listening': {
+  'once an http server is listening with a callback': {
     topic: function () {
       server = require('http').createServer(function (request, response) {
         request.addListener('end', function () {
           fileServer.serve(request, response, function(err, result) {
             if (callback)
               callback(request, response, err, result);
+            else
+              request.end();
           });
         });
       }).listen(TEST_PORT, this.callback)
@@ -31,14 +33,6 @@ suite.addBatch({
     }
   },
 }).addBatch({
-    'requesting a file not found': {
-      topic : function(){
-        request.get(TEST_SERVER + '/not-found', this.callback);
-      }, 
-      '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) {
@@ -51,12 +45,40 @@ suite.addBatch({
         }
         request.get(TEST_SERVER + '/not-found', this.callback);
       },
+      'should respond with 404' : function(error, response, body){
+        assert.equal(response.statusCode, 404);
+      },
       'should respond with the streamed content': function(error, response, body){
         callback = null;
         assert.equal(body, 'Custom 404 Stream.');
       }
     }
 }).addBatch({
+  'once an http server is listening without a callback': {
+    topic: function () {
+      server.close();
+      server = require('http').createServer(function (request, response) {
+        request.addListener('end', function () {
+          fileServer.serve(request, response);
+        });
+      }).listen(TEST_PORT, this.callback)
+    },
+    'should be listening' : function(){
+      /* This test is necessary to ensure the topic execution.
+       * A topic without tests will be not executed */
+      assert.isTrue(true);
+    }
+  }
+}).addBatch({
+    'requesting a file not found': {
+      topic : function(){
+        request.get(TEST_SERVER + '/not-found', this.callback);
+      }, 
+      'should respond with 404' : function(error, response, body){
+        assert.equal(response.statusCode, 404);
+      }
+    }
+}).addBatch({
   'serving hello.txt': {
     topic : function(){
       request.get(TEST_SERVER + '/hello.txt', this.callback);

-- 
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