Files
express/test/app.use.js

68 lines
1.3 KiB
JavaScript
Raw Normal View History

2011-11-24 13:49:27 -08:00
var express = require('../')
2014-03-05 22:06:14 -08:00
, request = require('supertest');
2011-11-24 13:49:27 -08:00
describe('app', function(){
it('should emit "mount" when mounted', function(done){
var blog = express()
, app = express();
blog.on('mount', function(arg){
arg.should.equal(app);
done();
});
app.use(blog);
})
describe('.use(app)', function(){
it('should mount the app', function(done){
var blog = express()
, app = express();
blog.get('/blog', function(req, res){
res.end('blog');
});
2014-03-05 22:06:14 -08:00
2011-11-24 13:51:04 -08:00
app.use(blog);
request(app)
.get('/blog')
.expect('blog', done);
})
it('should support mount-points', function(done){
var blog = express()
, forum = express()
, app = express();
blog.get('/', function(req, res){
res.end('blog');
});
forum.get('/', function(req, res){
2011-11-24 13:49:27 -08:00
res.end('forum');
});
2011-11-24 13:51:04 -08:00
app.use('/blog', blog);
app.use('/forum', forum);
2011-11-24 13:49:27 -08:00
request(app)
.get('/blog')
.expect('blog', function(){
request(app)
.get('/forum')
.expect('forum', done);
});
})
2011-11-24 14:04:37 -08:00
it('should set the child\'s .parent', function(){
var blog = express()
, app = express();
app.use('/blog', blog);
blog.parent.should.equal(app);
})
})
2011-11-24 13:49:27 -08:00
})