Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added both use cases

  • Loading branch information...
commit ed49feb4f40e862b975ed6c88cdc4a6c1c41fb96 1 parent f039e1c
guybedford authored
Showing with 31 additions and 9 deletions.
  1. +31 −9 test/integration/node-static-test.js
40 test/integration/node-static-test.js
View
@@ -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);
Please sign in to comment.
Something went wrong with that request. Please try again.