|
var request = require('supertest'), |
|
app = require('./app'), |
|
myModule = require('./myModule'), |
|
defaultString = "It Works", |
|
testString = "This is my Test String" |
|
; |
|
|
|
describe("the Server", function() { |
|
it("starts", function(done) { |
|
request(app) |
|
.get("/") |
|
.expect(200) |
|
.end(done) |
|
; |
|
}); |
|
}); |
|
|
|
describe("middleware", function() { |
|
it("returns the default string", function(next) { |
|
myModule().done(function(result) { |
|
if (result != defaultString) { |
|
throw new Error("Expected String to Be ["+defaultString+"], Got ["+result+"]"); |
|
} |
|
}).fail(function(error) { |
|
throw error; |
|
}).always(function() { |
|
next(); |
|
}); |
|
}); |
|
|
|
it("returns the test string", function(next) { |
|
myModule(testString).done(function(result) { |
|
if (result != testString) { |
|
throw new Error("Expected String to Be ["+testString+"], Got ["+result+"]"); |
|
} |
|
}).fail(function(error) { |
|
throw error; |
|
}).always(function() { |
|
next(); |
|
}); |
|
}); |
|
|
|
it("returns the test string in dot notation", function(next) { |
|
myModule({text: testString}).done(function(result) { |
|
if (result != testString) { |
|
throw new Error("Expected String to Be ["+testString+"], Got ["+result+"]"); |
|
} |
|
}).fail(function(error) { |
|
throw error; |
|
}).always(function() { |
|
next(); |
|
}); |
|
}); |
|
|
|
it ("errors when an array is passed", function(next) { |
|
myModule([1,2,3,4,5]).done(function(result) { |
|
throw new Error("Expect an error"); |
|
}).always(function() { |
|
next(); |
|
}); |
|
}); |
|
|
|
it ("errors when an array is passed in dot notation", function(next) { |
|
myModule({text: [1,2,3,4,5]}).done(function(result) { |
|
throw new Error("Expect an error"); |
|
}).always(function() { |
|
next(); |
|
}); |
|
}); |
|
}); |