app.response.js
This file
Path
test/app.response.js
50 lines · 1.0 KiB · JavaScript
Last changed by
make sure req/res protos are app-specificTj Holowaychukbefore adoptione27b224
History of this fileTake it
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
var express = require('../') , request = require('./support/http');
describe('app', function(){ describe('.response', function(){ it('should extend the response prototype', function(done){ var app = express();
app.response.shout = function(str){ this.send(str.toUpperCase()); };
app.use(function(req, res){ res.shout('hey'); });
request(app) .get('/') .end(function(res){ res.body.should.equal('HEY'); done(); }); }) it('should not be influenced by other app protos', function(done){ var app = express() , app2 = express();
app.response.shout = function(str){ this.send(str.toUpperCase()); }; app2.response.shout = function(str){ this.send(str); };
app.use(function(req, res){ res.shout('hey'); });
request(app) .get('/') .end(function(res){ res.body.should.equal('HEY'); done(); }); }) })})