Skip to content
Myr

res.render.js

This file

Path

test/res.render.js

257 lines · 6.0 KiB · JavaScript

Last changed by

deps: update example dependenciesDouglas Christopher Wilsonbefore adoption766b3ae

History of this file

Take it

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

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

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

remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3

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

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

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 adoption328c6d3

line 9why, one step back
9

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

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 adoption328c6d3

line 20why, one step back
20

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

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 adoption328c6d3

line 23why, one step back
23

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

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 adoption328c6d3

line 38why, one step back
38

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

lines 39–52why, 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 })50 51 it('should support index.<engine>', function(done){52 var app = express();

remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3

line 53why, one step back
53

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

lines 54–59why, one step back
54 app.set('views', __dirname + '/fixtures');
55 app.set('view engine', 'jade');5657 app.use(function(req, res){58 res.render('blog/post');59 });

remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3

line 60why, one step back
60

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

lines 61–64why, one step back
61 request(app)
62 .get('/')63 .expect('<h1>blog post</h1>', done);64 })

remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3

line 65why, one step back
65

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

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

remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3

line 69why, one step back
69

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

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

remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3

line 75why, one step back
75

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

lines 76–81why, one step back
76 app.use(function(err, req, res, next){
77 res.end(err.message);78 });7980 request(app)81 .get('/')

deps: update example dependenciesDouglas Christopher Wilsonbefore adoption766b3ae

line 82why, one step back
82 .expect(/Cannot read property 'name' of undefined/, done);

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

lines 83–84why, one step back
83 })
84 })

remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3

line 85why, one step back
85

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

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

remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3

line 89why, one step back
89

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

lines 90–106why, one step back
90 app.set('view engine', 'jade');
91 app.set('views', __dirname + '/fixtures');9293 app.use(function(req, res){94 res.render('email');95 });9697 request(app)98 .get('/')99 .expect('<p>This is an email</p>', done);100 })101 })102 })103104 describe('.render(name, option)', function(){105 it('should render the template', function(done){106 var app = express();

remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3

line 107why, one step back
107

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

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

remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3

line 109why, one step back
109

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

lines 110–119why, one step back
110 var user = { name: 'tobi' };
111112 app.use(function(req, res){113 res.render('user.jade', { user: user });114 });115116 request(app)117 .get('/')118 .expect('<p>tobi</p>', done);119 })

remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3

line 120why, one step back
120

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

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

remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3

line 123why, one step back
123

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

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

remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3

line 135why, one step back
135

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

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

remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3

line 138why, one step back
138

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

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

remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3

line 150why, one step back
150

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

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

remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3

line 153why, one step back
153

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

lines 154–168why, one step back
154 app.set('views', __dirname + '/fixtures');
155 app.locals.user = { name: 'tobi' };156157 app.use(function(req, res){158 res.locals.user = { name: 'jane' };159 res.render('user.jade', {});160 });161162 request(app)163 .get('/')164 .expect('<p>jane</p>', done);165 })166167 it('should give precedence to res.render() locals over res.locals', function(done){168 var app = express();

remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3

line 169why, one step back
169

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

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

remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3

line 172why, one step back
172

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

lines 173–181why, one step back
173 app.use(function(req, res){
174 res.locals.user = { name: 'tobi' };175 res.render('user.jade', { user: jane });176 });177178 request(app)179 .get('/')180 .expect('<p>jane</p>', done);181 })

remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3

line 182why, one step back
182

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

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

remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3

line 185why, one step back
185

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

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

remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3

line 189why, one step back
189

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

lines 190–252why, one step back
190 app.use(function(req, res){
191 res.render('user.jade', { user: jane });192 });193194 request(app)195 .get('/')196 .expect('<p>jane</p>', done);197 })198 })199200 describe('.render(name, options, fn)', function(){201 it('should pass the resulting string', function(done){202 var app = express();203204 app.set('views', __dirname + '/fixtures');205206 app.use(function(req, res){207 var tobi = { name: 'tobi' };208 res.render('user.jade', { user: tobi }, function(err, html){209 html = html.replace('tobi', 'loki');210 res.end(html);211 });212 });213214 request(app)215 .get('/')216 .expect('<p>loki</p>', done);217 })218 })219220 describe('.render(name, fn)', function(){221 it('should pass the resulting string', function(done){222 var app = express();223224 app.set('views', __dirname + '/fixtures');225226 app.use(function(req, res){227 res.locals.user = { name: 'tobi' };228 res.render('user.jade', function(err, html){229 html = html.replace('tobi', 'loki');230 res.end(html);231 });232 });233234 request(app)235 .get('/')236 .expect('<p>loki</p>', done);237 })238239 describe('when an error occurs', function(){240 it('should pass it to the callback', function(done){241 var app = express();242243 app.set('views', __dirname + '/fixtures');244245 app.use(function(req, res){246 res.render('user.jade', function(err){247 res.end(err.message);248 });249 });250251 request(app)252 .get('/')

deps: update example dependenciesDouglas Christopher Wilsonbefore adoption766b3ae

line 253why, one step back
253 .expect(/Cannot read property 'name' of undefined/, done);

3.5.2Douglas Christopher Wilsonbefore adoptiond581592

lines 254–257why, one step back
254 })
255 })256 })257})