Skip to content
Myr

app.engine.js

This file

Path

test/app.engine.js

83 lines · 2.2 KiB · JavaScript

Last changed by

fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359

History of this file

Take it

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

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

line 1why, one step back
1'use strict'

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

line 2why, one step back
2

fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359

line 3why, one step back
3var assert = require('node:assert')

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

line 4why, one step back
4var express = require('../')

fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359

lines 5–6why, one step back
5 , fs = require('node:fs');
6var path = require('node:path')

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

lines 7–20why, one step back
7
8function render(path, options, fn) {9 fs.readFile(path, 'utf8', function(err, str){10 if (err) return fn(err);11 str = str.replace('{{user.name}}', options.user.name);12 fn(null, str);13 });14}1516describe('app', function(){17 describe('.engine(ext, fn)', function(){18 it('should map a template engine', function(done){19 var app = express();20

Merge tag '4.15.2'Douglas Christopher Wilsonbefore adoptione5dbb0c

line 21why, one step back
21 app.set('views', path.join(__dirname, 'fixtures'))

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

lines 22–26why, one step back
22 app.engine('.html', render);
23 app.locals.user = { name: 'tobi' };2425 app.render('user.html', function(err, str){26 if (err) return done(err);

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

line 27why, one step back
27 assert.strictEqual(str, '<p>tobi</p>')

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

lines 28–33why, one step back
28 done();
29 })30 })3132 it('should throw when the callback is missing', function(){33 var app = express();

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

line 34why, one step back
34 assert.throws(function () {

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

line 35why, one step back
35 app.engine('.html', null);

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

line 36why, one step back
36 }, /callback function required/)

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

lines 37–41why, one step back
37 })
3839 it('should work without leading "."', function(done){40 var app = express();41

Merge tag '4.15.2'Douglas Christopher Wilsonbefore adoptione5dbb0c

line 42why, one step back
42 app.set('views', path.join(__dirname, 'fixtures'))

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

lines 43–47why, one step back
43 app.engine('html', render);
44 app.locals.user = { name: 'tobi' };4546 app.render('user.html', function(err, str){47 if (err) return done(err);

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

line 48why, one step back
48 assert.strictEqual(str, '<p>tobi</p>')

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

lines 49–51why, one step back
49 done();
50 })51 })

Merge tag '4.15.4'Douglas Christopher Wilsonbefore adoptionc319fe2

line 52why, one step back
52

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

lines 53–55why, one step back
53 it('should work "view engine" setting', function(done){
54 var app = express();55

Merge tag '4.15.2'Douglas Christopher Wilsonbefore adoptione5dbb0c

line 56why, one step back
56 app.set('views', path.join(__dirname, 'fixtures'))

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

lines 57–62why, one step back
57 app.engine('html', render);
58 app.set('view engine', 'html');59 app.locals.user = { name: 'tobi' };6061 app.render('user', function(err, str){62 if (err) return done(err);

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

line 63why, one step back
63 assert.strictEqual(str, '<p>tobi</p>')

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

lines 64–66why, one step back
64 done();
65 })66 })

Merge tag '4.15.4'Douglas Christopher Wilsonbefore adoptionc319fe2

line 67why, one step back
67

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

lines 68–70why, one step back
68 it('should work "view engine" with leading "."', function(done){
69 var app = express();70

Merge tag '4.15.2'Douglas Christopher Wilsonbefore adoptione5dbb0c

line 71why, one step back
71 app.set('views', path.join(__dirname, 'fixtures'))

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

lines 72–77why, one step back
72 app.engine('.html', render);
73 app.set('view engine', '.html');74 app.locals.user = { name: 'tobi' };7576 app.render('user', function(err, str){77 if (err) return done(err);

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

line 78why, one step back
78 assert.strictEqual(str, '<p>tobi</p>')

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

lines 79–83why, one step back
79 done();
80 })81 })82 })83})