app.engine.js
This file
Path
test/app.engine.js
58 lines · 1.5 KiB · JavaScript
Last changed by
Merge branch 'view-signature'Tj Holowaychukbefore adoption2d77279
History of this fileTake it
Added app.engine() testsTj Holowaychukbefore adoption66f8ca5
line 1why, one step back1Merge branch 'view-signature'Tj Holowaychukbefore adoption2d77279
lines 2–3why, one step back2var express = require('../')3 , fs = require('fs');Added app.engine() testsTj Holowaychukbefore adoption66f8ca5
line 4why, one step back4Merge branch 'view-signature'Tj Holowaychukbefore adoption2d77279
lines 5–10why, one step back5function render(path, options, fn) {6 fs.readFile(path, 'utf8', function(err, str){7 if (err) return fn(err);8 str = str.replace('{{user.name}}', options.user.name);9 fn(null, str);10 });Added app.engine() testsTj Holowaychukbefore adoption66f8ca5
lines 11–14why, one step back11}1213describe('app', function(){14 describe('.engine(ext, fn)', function(){Added index.<engine> render testTj Holowaychukbefore adoption52e2669
line 15why, one step back15 it('should map a template engine', function(done){Added app.engine() testsTj Holowaychukbefore adoption66f8ca5
lines 16–22why, one step back16 var app = express();1718 app.set('views', __dirname + '/fixtures');19 app.engine('.html', render);20 app.locals.user = { name: 'tobi' };2122 app.render('user.html', function(err, str){Added index.<engine> render testTj Holowaychukbefore adoption52e2669
line 23why, one step back23 if (err) return done(err);Added app.engine() testsTj Holowaychukbefore adoption66f8ca5
line 24why, one step back24 str.should.equal('<p>tobi</p>');Added index.<engine> render testTj Holowaychukbefore adoption52e2669
line 25why, one step back25 done();Added app.engine() testsTj Holowaychukbefore adoption66f8ca5
lines 26–28why, one step back26 })27 })28 Added index.<engine> render testTj Holowaychukbefore adoption52e2669
line 29why, one step back29 it('should work without leading "."', function(done){Added app.engine() testsTj Holowaychukbefore adoption66f8ca5
lines 30–36why, one step back30 var app = express();3132 app.set('views', __dirname + '/fixtures');33 app.engine('html', render);34 app.locals.user = { name: 'tobi' };3536 app.render('user.html', function(err, str){Added index.<engine> render testTj Holowaychukbefore adoption52e2669
line 37why, one step back37 if (err) return done(err);Added app.engine() testsTj Holowaychukbefore adoption66f8ca5
line 38why, one step back38 str.should.equal('<p>tobi</p>');Added index.<engine> render testTj Holowaychukbefore adoption52e2669
line 39why, one step back39 done();Added app.engine() testsTj Holowaychukbefore adoption66f8ca5
lines 40–41why, one step back40 })41 })more testsTj Holowaychukbefore adoptionfdf620b
line 42why, one step back42 Added index.<engine> render testTj Holowaychukbefore adoption52e2669
line 43why, one step back43 it('should work "view engine" setting', function(done){more testsTj Holowaychukbefore adoptionfdf620b
lines 44–51why, one step back44 var app = express();4546 app.set('views', __dirname + '/fixtures');47 app.engine('html', render);48 app.set('view engine', 'html');49 app.locals.user = { name: 'tobi' };5051 app.render('user', function(err, str){Added index.<engine> render testTj Holowaychukbefore adoption52e2669
line 52why, one step back52 if (err) return done(err);more testsTj Holowaychukbefore adoptionfdf620b
line 53why, one step back53 str.should.equal('<p>tobi</p>');Added index.<engine> render testTj Holowaychukbefore adoption52e2669
line 54why, one step back54 done();more testsTj Holowaychukbefore adoptionfdf620b
lines 55–56why, one step back55 })56 })Added app.engine() testsTj Holowaychukbefore adoption66f8ca5
lines 57–58why, one step back57 })58})