Arquivos
express/test/res.locals.js
Roman Shtylman 4983c38298 change res.locals to a plain js object.
Anyone who wants something fancier should use modules.

- fixes annoyance with not being able to set 'name' property on locals
2014-01-27 19:17:29 -05:00

42 linhas
777 B
JavaScript

var express = require('../')
, request = require('./support/http');
describe('res', function(){
describe('.locals', function(){
it('should be empty by default', function(done){
var app = express();
app.use(function(req, res){
Object.keys(res.locals).should.eql([]);
res.end();
});
request(app)
.get('/')
.expect(200, done);
})
})
it('should work when mounted', function(done){
var app = express();
var blog = express();
app.use(blog);
blog.use(function(req, res, next){
res.locals.foo = 'bar';
next();
});
app.use(function(req, res){
res.locals.foo.should.equal('bar');
res.end();
});
request(app)
.get('/')
.expect(200, done);
})
})