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
Added app.{request,response}Tj Holowaychukbefore adoption94d1e94
lines 1–24why, one step back12var express = require('../')3 , request = require('./support/http');45describe('app', function(){6 describe('.response', function(){7 it('should extend the response prototype', function(done){8 var app = express();910 app.response.shout = function(str){11 this.send(str.toUpperCase());12 };1314 app.use(function(req, res){15 res.shout('hey');16 });1718 request(app)19 .get('/')20 .end(function(res){21 res.body.should.equal('HEY');22 done();23 });24 })Added res proto mutation testTj Holowaychukbefore adoption4f087df
line 25why, one step back25 make sure req/res protos are app-specificTj Holowaychukbefore adoptione27b224
line 26why, one step back26 it('should not be influenced by other app protos', function(done){Added res proto mutation testTj Holowaychukbefore adoption4f087df
lines 27–48why, one step back27 var app = express()28 , app2 = express();2930 app.response.shout = function(str){31 this.send(str.toUpperCase());32 };33 34 app2.response.shout = function(str){35 this.send(str);36 };3738 app.use(function(req, res){39 res.shout('hey');40 });4142 request(app)43 .get('/')44 .end(function(res){45 res.body.should.equal('HEY');46 done();47 });48 })Added app.{request,response}Tj Holowaychukbefore adoption94d1e94
lines 49–50why, one step back49 })50})