Skip to content
Myr

Added res.render() callback tests

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 4d450ea · Browse files · 1 file+44 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+44 added−0 removed

  • tests:+44 added−0 removed

1 file+44 added−0 removed

modified:test/res.render.js+44 added
195 unmodified lines
196 done();197 });198 })199 })200201 describe('.render(name, fn)', function(){202 it('should not respond', function(done){203 var app = express();204205 app.set('views', __dirname + '/fixtures');206207 app.use(function(req, res){208 res.locals.user = { name: 'tobi' };209 res.render('user.jade', function(err, html){210 html = html.replace('tobi', 'loki');211 res.end(html);212 });213 });214215 request(app)216 .get('/')217 .end(function(res){218 res.body.should.equal('<p>loki</p>');219 done();220 });221 })222223 describe('when an error occurs', function(){224 it('should pass it to the callback', function(done){225 var app = express();226227 app.set('views', __dirname + '/fixtures');228229 app.use(function(req, res){230 res.render('user.jade', function(err){231 res.end(err.message);232 });233 });234235 request(app)236 .get('/')237 .end(function(res){238 res.body.should.match(/is not defined/);239 done();240 });241 })242 })243 })244})