Permalink
Browse files

more static() tests

  • Loading branch information...
1 parent 3567ba5 commit 59d1d29473f27a5d7ddd9a11331ebd01460bbb3c @tj tj committed Nov 12, 2011
Showing with 39 additions and 5 deletions.
  1. +1 −0 test/fixtures/foo bar
  2. +1 −0 test/fixtures/users/tobi.txt
  3. +24 −0 test/static.js
  4. +13 −5 test/support/http.js
View
@@ -0,0 +1 @@
+baz
@@ -0,0 +1 @@
+ferret
View
@@ -12,4 +12,28 @@ describe('connect.static()', function(){
.get('/todo.txt')
.expect('- groceries', done);
})
+
+ it('should support nesting', function(done){
+ app.request()
+ .get('/users/tobi.txt')
+ .expect('ferret', done);
+ })
+
+ it('should set Content-Type', function(done){
+ app.request()
+ .get('/todo.txt')
+ .expect('Content-Type', 'text/plain; charset=UTF-8', done);
+ })
+
+ it('should default max-age=0', function(done){
+ app.request()
+ .get('/todo.txt')
+ .expect('Cache-Control', 'public, max-age=0', done);
+ })
+
+ it('should support urlencoded pathnames', function(done){
+ app.request()
+ .get('/foo%20bar')
+ .expect('baz', done);
+ })
})
View
@@ -61,13 +61,21 @@ Request.prototype.request = function(method, path){
};
Request.prototype.expect = function(body, fn){
+ var args = arguments;
this.end(function(res){
- if ('number' == typeof body) {
- res.statusCode.should.equal(body);
- } else {
- res.body.should.equal(body);
+ switch (args.length) {
+ case 3:
+ res.headers.should.have.property(body.toLowerCase(), args[1]);
+ args[2]();
+ break;
+ default:
+ if ('number' == typeof body) {
+ res.statusCode.should.equal(body);
+ } else {
+ res.body.should.equal(body);
+ }
+ fn();
}
- fn();
});
};

0 comments on commit 59d1d29

Please sign in to comment.