Skip to content
Myr

req.param.js

This file

Path

test/req.param.js

61 lines · 1.3 KiB · JavaScript

Last changed by

deps: update example dependenciesDouglas Christopher Wilsonbefore adoption6ee9433

History of this file

Take it

The walk stopped after 200 commits: lines older than 2e68ddb point at it.

expose connect.middleware using Object.getOwnPropertyDescriptor()Jonathan Ongbefore adoption2e68ddb

lines 1–2why, one step back
1
2var express = require('../')

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 3why, one step back
3 , request = require('supertest')

remove last pieces of connect dependencyRoman Shtylmanbefore adoption1396e08

line 4why, one step back
4 , bodyParser = require('body-parser')

expose connect.middleware using Object.getOwnPropertyDescriptor()Jonathan Ongbefore adoption2e68ddb

lines 5–32why, one step back
5
6describe('req', function(){7 describe('.param(name, default)', function(){8 it('should use the default value unless defined', function(done){9 var app = express();1011 app.use(function(req, res){12 res.end(req.param('name', 'tj'));13 });1415 request(app)16 .get('/')17 .expect('tj', done);18 })19 })2021 describe('.param(name)', function(){22 it('should check req.query', function(done){23 var app = express();2425 app.use(function(req, res){26 res.end(req.param('name'));27 });2829 request(app)30 .get('/?name=tj')31 .expect('tj', done);32 })

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 33why, one step back
33

expose connect.middleware using Object.getOwnPropertyDescriptor()Jonathan Ongbefore adoption2e68ddb

lines 34–36why, one step back
34 it('should check req.body', function(done){
35 var app = express();36

deps: update example dependenciesDouglas Christopher Wilsonbefore adoption6ee9433

line 37why, one step back
37 app.use(bodyParser.json());

expose connect.middleware using Object.getOwnPropertyDescriptor()Jonathan Ongbefore adoption2e68ddb

lines 38–47why, one step back
38
39 app.use(function(req, res){40 res.end(req.param('name'));41 });4243 request(app)44 .post('/')45 .send({ name: 'tj' })46 .expect('tj', done);47 })

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 48why, one step back
48

expose connect.middleware using Object.getOwnPropertyDescriptor()Jonathan Ongbefore adoption2e68ddb

lines 49–61why, one step back
49 it('should check req.params', function(done){
50 var app = express();5152 app.get('/user/:name', function(req, res){53 res.end(req.param('filter') + req.param('name'));54 });5556 request(app)57 .get('/user/tj')58 .expect('undefinedtj', done);59 })60 })61})