Skip to content
Myr

res.render.js

This file

Path

test/res.render.js

272 lines · 6.3 KiB · JavaScript

Last changed by

update example dependenciesDouglas Christopher Wilsonbefore adoption203fb05

History of this file

Take it

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

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

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 app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 4–8why, one step back
4
5describe('res', function(){6 describe('.render(name)', function(){7 it('should support absolute paths', function(done){8 var app = express();

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 9why, one step back
9

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 10–19why, one step back
10 app.locals.user = { name: 'tobi' };
1112 app.use(function(req, res){13 res.render(__dirname + '/fixtures/user.jade');14 });1516 request(app)17 .get('/')18 .expect('<p>tobi</p>', done);19 })

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 20why, one step back
20

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 21–22why, one step back
21 it('should support absolute paths with "view engine"', function(done){
22 var app = express();

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 23why, one step back
23

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 24–37why, one step back
24 app.locals.user = { name: 'tobi' };
25 app.set('view engine', 'jade');2627 app.use(function(req, res){28 res.render(__dirname + '/fixtures/user');29 });3031 request(app)32 .get('/')33 .expect('<p>tobi</p>', done);34 })3536 it('should expose app.locals', function(done){37 var app = express();

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 38why, one step back
38

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 39–64why, one step back
39 app.set('views', __dirname + '/fixtures');
40 app.locals.user = { name: 'tobi' };4142 app.use(function(req, res){43 res.render('user.jade');44 });4546 request(app)47 .get('/')48 .expect('<p>tobi</p>', done);49 })5051 it('should expose app.locals with `name` property', function(done){52 var app = express();5354 app.set('views', __dirname + '/fixtures');55 app.locals.name = 'tobi';5657 app.use(function(req, res){58 res.render('name.jade');59 });6061 request(app)62 .get('/')63 .expect('<p>tobi</p>', done);64 })

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 65why, one step back
65

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 66–67why, one step back
66 it('should support index.<engine>', function(done){
67 var app = express();

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 68why, one step back
68

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 69–74why, one step back
69 app.set('views', __dirname + '/fixtures');
70 app.set('view engine', 'jade');7172 app.use(function(req, res){73 res.render('blog/post');74 });

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 75why, one step back
75

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 76–79why, one step back
76 request(app)
77 .get('/')78 .expect('<h1>blog post</h1>', done);79 })

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 80why, one step back
80

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 81–83why, one step back
81 describe('when an error occurs', function(){
82 it('should next(err)', function(done){83 var app = express();

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 84why, one step back
84

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 85–89why, one step back
85 app.set('views', __dirname + '/fixtures');
8687 app.use(function(req, res){88 res.render('user.jade');89 });

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 90why, one step back
90

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 91–96why, one step back
91 app.use(function(err, req, res, next){
92 res.end(err.message);93 });9495 request(app)96 .get('/')

update example dependenciesDouglas Christopher Wilsonbefore adoption203fb05

line 97why, one step back
97 .expect(/Cannot read property '[^']+' of undefined/, done);

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 98–99why, one step back
98 })
99 })

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 100why, one step back
100

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 101–103why, one step back
101 describe('when "view engine" is given', function(){
102 it('should render the template', function(done){103 var app = express();

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 104why, one step back
104

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 105–121why, one step back
105 app.set('view engine', 'jade');
106 app.set('views', __dirname + '/fixtures');107108 app.use(function(req, res){109 res.render('email');110 });111112 request(app)113 .get('/')114 .expect('<p>This is an email</p>', done);115 })116 })117 })118119 describe('.render(name, option)', function(){120 it('should render the template', function(done){121 var app = express();

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 122why, one step back
122

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

line 123why, one step back
123 app.set('views', __dirname + '/fixtures');

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 124why, one step back
124

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 125–134why, one step back
125 var user = { name: 'tobi' };
126127 app.use(function(req, res){128 res.render('user.jade', { user: user });129 });130131 request(app)132 .get('/')133 .expect('<p>tobi</p>', done);134 })

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 135why, one step back
135

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 136–137why, one step back
136 it('should expose app.locals', function(done){
137 var app = express();

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 138why, one step back
138

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 139–149why, one step back
139 app.set('views', __dirname + '/fixtures');
140 app.locals.user = { name: 'tobi' };141142 app.use(function(req, res){143 res.render('user.jade');144 });145146 request(app)147 .get('/')148 .expect('<p>tobi</p>', done);149 })

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 150why, one step back
150

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 151–152why, one step back
151 it('should expose res.locals', function(done){
152 var app = express();

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 153why, one step back
153

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 154–164why, one step back
154 app.set('views', __dirname + '/fixtures');
155156 app.use(function(req, res){157 res.locals.user = { name: 'tobi' };158 res.render('user.jade');159 });160161 request(app)162 .get('/')163 .expect('<p>tobi</p>', done);164 })

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 165why, one step back
165

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 166–167why, one step back
166 it('should give precedence to res.locals over app.locals', function(done){
167 var app = express();

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 168why, one step back
168

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 169–183why, one step back
169 app.set('views', __dirname + '/fixtures');
170 app.locals.user = { name: 'tobi' };171172 app.use(function(req, res){173 res.locals.user = { name: 'jane' };174 res.render('user.jade', {});175 });176177 request(app)178 .get('/')179 .expect('<p>jane</p>', done);180 })181182 it('should give precedence to res.render() locals over res.locals', function(done){183 var app = express();

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 184why, one step back
184

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 185–186why, one step back
185 app.set('views', __dirname + '/fixtures');
186 var jane = { name: 'jane' };

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 187why, one step back
187

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 188–196why, one step back
188 app.use(function(req, res){
189 res.locals.user = { name: 'tobi' };190 res.render('user.jade', { user: jane });191 });192193 request(app)194 .get('/')195 .expect('<p>jane</p>', done);196 })

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 197why, one step back
197

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 198–199why, one step back
198 it('should give precedence to res.render() locals over app.locals', function(done){
199 var app = express();

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 200why, one step back
200

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 201–203why, one step back
201 app.set('views', __dirname + '/fixtures');
202 app.locals.user = { name: 'tobi' };203 var jane = { name: 'jane' };

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 204why, one step back
204

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 205–267why, one step back
205 app.use(function(req, res){
206 res.render('user.jade', { user: jane });207 });208209 request(app)210 .get('/')211 .expect('<p>jane</p>', done);212 })213 })214215 describe('.render(name, options, fn)', function(){216 it('should pass the resulting string', function(done){217 var app = express();218219 app.set('views', __dirname + '/fixtures');220221 app.use(function(req, res){222 var tobi = { name: 'tobi' };223 res.render('user.jade', { user: tobi }, function(err, html){224 html = html.replace('tobi', 'loki');225 res.end(html);226 });227 });228229 request(app)230 .get('/')231 .expect('<p>loki</p>', done);232 })233 })234235 describe('.render(name, fn)', function(){236 it('should pass the resulting string', function(done){237 var app = express();238239 app.set('views', __dirname + '/fixtures');240241 app.use(function(req, res){242 res.locals.user = { name: 'tobi' };243 res.render('user.jade', function(err, html){244 html = html.replace('tobi', 'loki');245 res.end(html);246 });247 });248249 request(app)250 .get('/')251 .expect('<p>loki</p>', done);252 })253254 describe('when an error occurs', function(){255 it('should pass it to the callback', function(done){256 var app = express();257258 app.set('views', __dirname + '/fixtures');259260 app.use(function(req, res){261 res.render('user.jade', function(err){262 res.end(err.message);263 });264 });265266 request(app)267 .get('/')

update example dependenciesDouglas Christopher Wilsonbefore adoption203fb05

line 268why, one step back
268 .expect(/Cannot read property '[^']+' of undefined/, done);

remove app.router and refactor middleware processingRoman Shtylmanbefore adoptionf41d09a

lines 269–272why, one step back
269 })
270 })271 })272})