app.use.js
This file
Path
test/app.use.js
68 lines · 1.3 KiB · JavaScript
Last changed by
Fix "trust proxy" setting to inherit when app is mountedDouglas Christopher Wilsonbefore adoptionb40e74d
History of this fileTake it
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
var assert = require('assert');var express = require('..');var request = require('supertest');
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'); });
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){ res.end('forum'); });
app.use('/blog', blog); app.use('/forum', forum);
request(app) .get('/blog') .expect('blog', function(){ request(app) .get('/forum') .expect('forum', done); }); })
it('should set the child\'s .parent', function(){ var blog = express() , app = express();
app.use('/blog', blog); blog.parent.should.equal(app); }) })})