tests: add more tests

This commit is contained in:
Douglas Christopher Wilson 2014-06-06 00:38:14 -04:00
parent 9bf1247716
commit 5019f38e29
4 changed files with 37 additions and 1 deletions

View File

@ -25,6 +25,11 @@ describe('app.router', function(){
[method]('/foo')
.expect('head' == method ? '' : method, done);
})
it('should reject numbers for app.' + method, function(){
var app = express();
app[method].bind(app, '/', 3).should.throw(/Number/);
})
});
})

View File

@ -15,6 +15,11 @@ describe('app', function(){
app.use(blog);
})
it('should reject numbers', function(){
var app = express();
app.use.bind(app, 3).should.throw(/Number/);
})
describe('.use(app)', function(){
it('should mount the app', function(done){
var blog = express()

View File

@ -1,7 +1,7 @@
var express = require('../');
var request = require('supertest');
var assert = require('assert');
var should = require('should');
describe('exports', function(){
it('should expose Router', function(){
@ -50,4 +50,12 @@ describe('exports', function(){
.get('/')
.expect('bar', done);
})
it('should throw on old middlewares', function(){
var error;
try { express.bodyParser; } catch (e) { error = e; }
should(error).have.property('message');
error.message.should.containEql('middleware');
error.message.should.containEql('bodyParser');
})
})

View File

@ -77,6 +77,24 @@ describe('res', function(){
test(app2);
})
describe('with parameters', function(){
var app = express();
app.use(function(req, res, next){
res.format({
'text/plain; charset=utf-8': function(){ res.send('hey') },
'text/html; foo=bar; bar=baz': function(){ res.send('<p>hey</p>') },
'application/json; q=0.5': function(){ res.send({ message: 'hey' }) }
});
});
app.use(function(err, req, res, next){
res.send(err.status, 'Supports: ' + err.types.join(', '));
});
test(app);
})
describe('given .default', function(){
it('should be invoked instead of auto-responding', function(done){
request(app3)