Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

more static() tests

  • Loading branch information...
commit 59d1d29473f27a5d7ddd9a11331ebd01460bbb3c 1 parent 3567ba5
@tj tj authored
View
1  test/fixtures/foo bar
@@ -0,0 +1 @@
+baz
View
1  test/fixtures/users/tobi.txt
@@ -0,0 +1 @@
+ferret
View
24 test/static.js
@@ -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
18 test/support/http.js
@@ -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();
});
};
Please sign in to comment.
Something went wrong with that request. Please try again.