req.param.js
This file
Path
test/req.param.js
60 lines · 1.2 KiB · JavaScript
Last changed by
updated tests to use "supertest"TJ Holowaychukbefore adoption0f5560e
History of this fileTake it
The walk stopped after 200 commits: lines older than d9aea70 point at it.
removed file heading commentsTJ Holowaychukbefore adoptiond9aea70
lines 1–15why, one step back12var express = require('../')3 , request = require('./support/http');45describe('req', function(){6 describe('.param(name, default)', function(){7 it('should use the default value unless defined', function(done){8 var app = express();910 app.use(function(req, res){11 res.end(req.param('name', 'tj'));12 });1314 request(app)15 .get('/')updated tests to use "supertest"TJ Holowaychukbefore adoption0f5560e
line 16why, one step back16 .expect('tj', done);removed file heading commentsTJ Holowaychukbefore adoptiond9aea70
lines 17–29why, one step back17 })18 })1920 describe('.param(name)', function(){21 it('should check req.query', function(done){22 var app = express();2324 app.use(function(req, res){25 res.end(req.param('name'));26 });2728 request(app)29 .get('/?name=tj')updated tests to use "supertest"TJ Holowaychukbefore adoption0f5560e
line 30why, one step back30 .expect('tj', done);removed file heading commentsTJ Holowaychukbefore adoptiond9aea70
lines 31–43why, one step back31 })32 33 it('should check req.body', function(done){34 var app = express();3536 app.use(express.bodyParser());3738 app.use(function(req, res){39 res.end(req.param('name'));40 });4142 request(app)43 .post('/')updated tests to use "supertest"TJ Holowaychukbefore adoption0f5560e
lines 44–45why, one step back44 .send({ name: 'tj' })45 .expect('tj', done);removed file heading commentsTJ Holowaychukbefore adoptiond9aea70
lines 46–51why, one step back46 })47 48 it('should check req.params', function(done){49 var app = express();5051 app.get('/user/:name', function(req, res){added test to illustrate req.params as an arrayTJ Holowaychukbefore adoptiond5fde6a
line 52why, one step back52 res.end(req.param('filter') + req.param('name'));removed file heading commentsTJ Holowaychukbefore adoptiond9aea70
lines 53–56why, one step back53 });5455 request(app)56 .get('/user/tj')updated tests to use "supertest"TJ Holowaychukbefore adoption0f5560e
line 57why, one step back57 .expect('undefinedtj', done);removed file heading commentsTJ Holowaychukbefore adoptiond9aea70
lines 58–60why, one step back58 })59 })60})