From f218d2eaaec32a76ddbf43bac4edb6b79c6011d1 Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Sat, 10 Apr 2021 23:29:02 +0200 Subject: [PATCH] chore tap 15 (#223) --- .taprc | 4 +- package.json | 2 +- .../test-with-snapshot.js-TAP.test.js | 26 --- .../test-ejs-with-snapshot.js.test.cjs} | 0 test/helper.js | 50 ++--- test/test-art-template.js | 92 ++++----- test/test-dot.js | 92 ++++----- test/test-ejs-with-snapshot.js | 40 ++-- test/test-ejs.js | 174 +++++++++--------- test/test-eta.js | 166 ++++++++--------- test/test-handlebars.js | 138 +++++++------- test/test-liquid.js | 82 ++++----- test/test-marko.js | 106 +++++------ test/test-mustache.js | 130 ++++++------- test/test-nunjucks.js | 90 ++++----- test/test-pug.js | 100 +++++----- test/test-twig.js | 86 ++++----- test/test.js | 74 ++++---- 18 files changed, 713 insertions(+), 739 deletions(-) delete mode 100644 tap-snapshots/test-with-snapshot.js-TAP.test.js rename tap-snapshots/{test-test-ejs-with-snapshot.js-TAP.test.js => test/test-ejs-with-snapshot.js.test.cjs} (100%) diff --git a/.taprc b/.taprc index 514cc782..119e3394 100644 --- a/.taprc +++ b/.taprc @@ -1,6 +1,6 @@ -esm: false ts: false jsx: false flow: false coverage: true -nyc-arg: [--exclude=out] \ No newline at end of file +nyc-arg: [--exclude=out] +check-coverage: false diff --git a/package.json b/package.json index 879d9c50..403569e9 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "simple-get": "^4.0.0", "split2": "^3.2.2", "standard": "^16.0.0", - "tap": "^14.0.0", + "tap": "^15.0.1", "tsd": "^0.14.0", "twig": "^1.13.3", "typescript": "^4.0.2" diff --git a/tap-snapshots/test-with-snapshot.js-TAP.test.js b/tap-snapshots/test-with-snapshot.js-TAP.test.js deleted file mode 100644 index 4aebfa9a..00000000 --- a/tap-snapshots/test-with-snapshot.js-TAP.test.js +++ /dev/null @@ -1,26 +0,0 @@ -/* IMPORTANT - * This snapshot file is auto-generated, but designed for humans. - * It should be checked into source control and tracked carefully. - * Re-generate by setting TAP_SNAPSHOT=1 and running tests. - * Make sure to inspect the output below. Do not ignore changes! - */ -'use strict' -exports['test-with-snapshot.js TAP reply.view with ejs engine, template folder specified, include files (ejs and html) used in template, includeViewExtension property as true; requires TAP snapshots enabled > output 1'] = ` -

text


Other EJS pages with includes:

-` - -exports['test-with-snapshot.js TAP reply.view with ejs engine, templates with folder specified, include files and attributes; requires TAP snapshots enabled; home > output 1'] = ` -

Hello from EJS Templates


-` - -exports['test-with-snapshot.js TAP reply.view with ejs engine, templates with folder specified, include files and attributes; requires TAP snapshots enabled; page with includes > output 1'] = ` -
Sample header (ejs)

Hello from EJS Templates

Sample footer (html) - Back to Home
-` - -exports['test-with-snapshot.js TAP reply.view with ejs engine, templates with folder specified, include files and attributes; requires TAP snapshots enabled; page with one include missing > output 1'] = ` -undefined -` - -exports['test-with-snapshot.js TAP reply.view with ejs engine, templates with folder specified, include files and attributes; requires TAP snapshots enabled; page with one attribute missing > output 1'] = ` -undefined -` diff --git a/tap-snapshots/test-test-ejs-with-snapshot.js-TAP.test.js b/tap-snapshots/test/test-ejs-with-snapshot.js.test.cjs similarity index 100% rename from tap-snapshots/test-test-ejs-with-snapshot.js-TAP.test.js rename to tap-snapshots/test/test-ejs-with-snapshot.js.test.cjs diff --git a/test/helper.js b/test/helper.js index da33af71..ebcd8a9e 100644 --- a/test/helper.js +++ b/test/helper.js @@ -55,10 +55,10 @@ module.exports.dotHtmlMinifierTests = function (t, compileOptions, withMinifierO url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], String(body.length)) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(minifier.minify(dot.process(compileOptions).testdot(data), options), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], String(body.length)) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(minifier.minify(dot.process(compileOptions).testdot(data), options), body.toString()) fastify.close() }) }) @@ -95,10 +95,10 @@ module.exports.etaHtmlMinifierTests = function (t, withMinifierOptions) { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], String(body.length)) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(minifier.minify(eta.render(fs.readFileSync('./templates/index.eta', 'utf8'), data), options), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], String(body.length)) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(minifier.minify(eta.render(fs.readFileSync('./templates/index.eta', 'utf8'), data), options), body.toString()) fastify.close() }) }) @@ -128,7 +128,7 @@ module.exports.handleBarsHtmlMinifierTests = function (t, withMinifierOptions) { t.error(err) fastify.view('./templates/index.html', data).then(compiled => { - t.strictEqual(minifier.minify(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(data), options), compiled) + t.equal(minifier.minify(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(data), options), compiled) fastify.close() }) }) @@ -166,13 +166,13 @@ module.exports.liquidHtmlMinifierTests = function (t, withMinifierOptions) { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], String(body.length)) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], String(body.length)) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') engine.renderFile('./templates/index.liquid', data) .then((html) => { t.error(err) - t.strictEqual(minifier.minify(html, options), body.toString()) + t.equal(minifier.minify(html, options), body.toString()) }) fastify.close() }) @@ -211,11 +211,11 @@ module.exports.nunjucksHtmlMinifierTests = function (t, withMinifierOptions) { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], String(body.length)) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], String(body.length)) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') // Global Nunjucks templates dir changed here. - t.strictEqual(minifier.minify(nunjucks.render('./index.njk', data), options), body.toString()) + t.equal(minifier.minify(nunjucks.render('./index.njk', data), options), body.toString()) fastify.close() }) }) @@ -252,10 +252,10 @@ module.exports.pugHtmlMinifierTests = function (t, withMinifierOptions) { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], String(body.length)) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(minifier.minify(pug.render(fs.readFileSync('./templates/index.pug', 'utf8'), data), options), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], String(body.length)) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(minifier.minify(pug.render(fs.readFileSync('./templates/index.pug', 'utf8'), data), options), body.toString()) fastify.close() }) }) @@ -292,12 +292,12 @@ module.exports.twigHtmlMinifierTests = function (t, withMinifierOptions) { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], String(body.length)) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], String(body.length)) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') Twig.renderFile('./templates/index.twig', data, (err, html) => { t.error(err) - t.strictEqual(minifier.minify(html, options), body.toString()) + t.equal(minifier.minify(html, options), body.toString()) }) fastify.close() }) diff --git a/test/test-art-template.js b/test/test-art-template.js index 672ef2db..3a9a5751 100644 --- a/test/test-art-template.js +++ b/test/test-art-template.js @@ -31,13 +31,13 @@ test('reply.view with art-template engine and custom templates folder', t => { url: 'http://127.0.0.1:10086/' }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') const templatePath = path.join(__dirname, '..', 'templates', 'index.art') - t.strictEqual(art(templatePath, data), body.toString()) + t.equal(art(templatePath, data), body.toString()) fastify.close() }) }) @@ -67,13 +67,13 @@ test('reply.view for art-template without data-parameter and defaultContext', t url: 'http://127.0.0.1:10086/' }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') const templatePath = path.join(__dirname, '..', 'templates', 'index.art') - t.strictEqual(art(templatePath, {}), body.toString()) + t.equal(art(templatePath, {}), body.toString()) fastify.close() }) }) @@ -105,13 +105,13 @@ test('reply.view for art-template without data-parameter but with defaultContext url: 'http://127.0.0.1:10086/' }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') const templatePath = path.join(__dirname, '..', 'templates', 'index.art') - t.strictEqual(art(templatePath, data), body.toString()) + t.equal(art(templatePath, data), body.toString()) fastify.close() }) }) @@ -143,13 +143,13 @@ test('reply.view with art-template engine and defaultContext', t => { url: 'http://127.0.0.1:10086/' }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') const templatePath = path.join(__dirname, '..', 'templates', 'index.art') - t.strictEqual(art(templatePath, data), body.toString()) + t.equal(art(templatePath, data), body.toString()) fastify.close() }) }) @@ -184,13 +184,13 @@ test('reply.view for art-template engine without data-parameter and defaultConte url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') const templatePath = path.join(__dirname, '..', 'templates', 'index.art') - t.strictEqual(art(templatePath, localsData), body.toString()) + t.equal(art(templatePath, localsData), body.toString()) fastify.close() }) }) @@ -226,13 +226,13 @@ test('reply.view for art-template engine without defaultContext but with reply.l url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') const templatePath = path.join(__dirname, '..', 'templates', 'index.art') - t.strictEqual(art(templatePath, data), body.toString()) + t.equal(art(templatePath, data), body.toString()) fastify.close() }) }) @@ -269,13 +269,13 @@ test('reply.view for art-template engine without data-parameter but with reply.l url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') const templatePath = path.join(__dirname, '..', 'templates', 'index.art') - t.strictEqual(art(templatePath, localsData), body.toString()) + t.equal(art(templatePath, localsData), body.toString()) fastify.close() }) }) @@ -313,13 +313,13 @@ test('reply.view for art-template engine with data-parameter and reply.locals an url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') const templatePath = path.join(__dirname, '..', 'templates', 'index.art') - t.strictEqual(art(templatePath, data), body.toString()) + t.equal(art(templatePath, data), body.toString()) fastify.close() }) }) @@ -351,13 +351,13 @@ test('reply.view with art-template engine and full path templates folder', t => url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') const templatePath = path.join(__dirname, '..', 'templates', 'index.art') - t.strictEqual(art(templatePath, data), body.toString()) + t.equal(art(templatePath, data), body.toString()) fastify.close() }) }) @@ -389,13 +389,13 @@ test('reply.view with art-template engine and includeViewExtension is true', t = url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') const templatePath = path.join(__dirname, '..', 'templates', 'index.art') - t.strictEqual(art(templatePath, data), body.toString()) + t.equal(art(templatePath, data), body.toString()) fastify.close() }) }) @@ -430,12 +430,12 @@ test('fastify.view with art-template engine and full path templates folder', t = url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-type'], 'text/plain; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-type'], 'text/plain; charset=utf-8') const templatePath = path.join(__dirname, '..', 'templates', 'index.art') - t.strictEqual(art(templatePath, data), body.toString()) + t.equal(art(templatePath, data), body.toString()) fastify.close() }) }) @@ -457,7 +457,7 @@ test('fastify.view with art-template should throw page missing', t => { fastify.view(null, {}, err => { t.ok(err instanceof Error) - t.is(err.message, 'Missing page') + t.equal(err.message, 'Missing page') fastify.close() }) }) @@ -489,8 +489,8 @@ test('reply.view with art-template should return 500 if render fails', t => { }, (err, response, body) => { const { message } = JSON.parse(body.toString()) t.error(err) - t.strictEqual(response.statusCode, 500) - t.strictEqual('Compile Error', message) + t.equal(response.statusCode, 500) + t.equal('Compile Error', message) fastify.close() }) diff --git a/test/test-dot.js b/test/test-dot.js index bf3e094f..316adec5 100644 --- a/test/test-dot.js +++ b/test/test-dot.js @@ -43,10 +43,10 @@ test('reply.view with dot engine .dot file', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(body.toString(), engine.process({ path: 'templates', destination: 'out' }).testdot(data)) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(body.toString(), engine.process({ path: 'templates', destination: 'out' }).testdot(data)) fastify.close() }) }) @@ -67,7 +67,7 @@ test('reply.view with dot engine .dot file should create non-existent destinatio } }) - t.tearDown(() => rmdirSync('non-existent')) + t.teardown(() => rmdirSync('non-existent')) fastify.get('/', (req, reply) => { reply.view('testdot') @@ -75,7 +75,7 @@ test('reply.view with dot engine .dot file should create non-existent destinatio fastify.listen(0, err => { t.error(err) - t.true(existsSync('non-existent')) + t.ok(existsSync('non-existent')) fastify.close() }) }) @@ -84,7 +84,7 @@ test('reply.view with dot engine .dot file should log WARN if template not found t.plan(2) const splitStream = split(JSON.parse) splitStream.on('data', (line) => { - t.is(line.msg, `WARN: no template found in ${join(__dirname, '..')}`) + t.equal(line.msg, `WARN: no template found in ${join(__dirname, '..')}`) }) const logger = pino({ level: 'warn' }, splitStream) const fastify = Fastify({ @@ -93,7 +93,7 @@ test('reply.view with dot engine .dot file should log WARN if template not found const engine = require('dot') engine.log = false - t.tearDown(() => rmdirSync('empty')) + t.teardown(() => rmdirSync('empty')) fastify.register(require('../index'), { engine: { @@ -105,7 +105,7 @@ test('reply.view with dot engine .dot file should log WARN if template not found }) fastify.listen(0, err => { - t.is(err, err) + t.equal(err, err) fastify.close() }) }) @@ -136,11 +136,11 @@ test('reply.view with dot engine .jst file', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') engine.process(compileOptions) - t.strictEqual(body.toString(), require('../out/testjst')(data)) + t.equal(body.toString(), require('../out/testjst')(data)) fastify.close() }) }) @@ -174,10 +174,10 @@ test('reply.view with dot engine without data-parameter but defaultContext', t = url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(body.toString(), engine.process(compileOptions).testdot(data)) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(body.toString(), engine.process(compileOptions).testdot(data)) fastify.close() }) }) @@ -209,11 +209,11 @@ test('reply.view with dot engine without data-parameter but without defaultConte url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') engine.process(compileOptions) - t.strictEqual(body.toString(), engine.process(compileOptions).testdot()) + t.equal(body.toString(), engine.process(compileOptions).testdot()) fastify.close() }) }) @@ -247,10 +247,10 @@ test('reply.view with dot engine with data-parameter and defaultContext', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(body.toString(), engine.process(compileOptions).testdot(data)) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(body.toString(), engine.process(compileOptions).testdot(data)) fastify.close() }) }) @@ -288,10 +288,10 @@ test('reply.view for dot engine without data-parameter and defaultContext but wi url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(body.toString(), engine.process(compileOptions).testdot(localsData)) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(body.toString(), engine.process(compileOptions).testdot(localsData)) fastify.close() }) }) @@ -330,10 +330,10 @@ test('reply.view for dot engine without defaultContext but with reply.locals and url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(body.toString(), engine.process(compileOptions).testdot(data)) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(body.toString(), engine.process(compileOptions).testdot(data)) fastify.close() }) }) @@ -373,10 +373,10 @@ test('reply.view for dot engine without data-parameter but with reply.locals and url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(body.toString(), engine.process(compileOptions).testdot(localsData)) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(body.toString(), engine.process(compileOptions).testdot(localsData)) fastify.close() }) }) @@ -416,10 +416,10 @@ test('reply.view for dot engine with data-parameter and reply.locals and default url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(body.toString(), engine.process(compileOptions).testdot(data)) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(body.toString(), engine.process(compileOptions).testdot(data)) fastify.close() }) }) @@ -442,7 +442,7 @@ test('fastify.view with dot engine, should throw page missing', t => { fastify.view(null, {}, err => { t.ok(err instanceof Error) - t.is(err.message, 'Missing page') + t.equal(err.message, 'Missing page') fastify.close() }) }) @@ -474,10 +474,10 @@ test('reply.view with dot engine with layout option', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual('header: textfoo text1

foo

footer', body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal('header: textfoo text1

foo

footer', body.toString()) fastify.close() }) }) diff --git a/test/test-ejs-with-snapshot.js b/test/test-ejs-with-snapshot.js index 5e9ada87..f80aaaf2 100644 --- a/test/test-ejs-with-snapshot.js +++ b/test/test-ejs-with-snapshot.js @@ -39,15 +39,15 @@ test('reply.view with ejs engine, template folder specified, include files (ejs url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(response.headers['content-length'], '' + body.length) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.headers['content-length'], '' + body.length) let content = null ejs.renderFile(path.join(templatesFolder, 'index-linking-other-pages.ejs'), data, options, function (err, str) { content = str t.error(err) - t.strictEqual(content.length, body.length) + t.equal(content.length, body.length) }) t.matchSnapshot(content.replace(/\r?\n/g, ''), 'output') // normalize new lines for cross-platform @@ -83,15 +83,15 @@ test('reply.view with ejs engine, templates with folder specified, include files url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(response.headers['content-length'], '' + body.length) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.headers['content-length'], '' + body.length) let content = null ejs.renderFile(path.join(templatesFolder, 'index.ejs'), data, options, function (err, str) { content = str t.error(err) - t.strictEqual(content.length, body.length) + t.equal(content.length, body.length) }) t.matchSnapshot(content.replace(/\r?\n/g, ''), 'output') // normalize new lines for cross-platform @@ -127,15 +127,15 @@ test('reply.view with ejs engine, templates with folder specified, include files url: 'http://localhost:' + fastify.server.address().port + '/include-test' }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(response.headers['content-length'], '' + body.length) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.headers['content-length'], '' + body.length) let content = null ejs.renderFile(path.join(templatesFolder, 'index-with-includes.ejs'), data, options, function (err, str) { content = str t.error(err) - t.strictEqual(content.length, body.length) + t.equal(content.length, body.length) }) t.matchSnapshot(content.replace(/\r?\n/g, ''), 'output') // normalize new lines for cross-platform @@ -171,15 +171,15 @@ test('reply.view with ejs engine, templates with folder specified, include files url: 'http://localhost:' + fastify.server.address().port + '/include-one-include-missing-test' }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 500) - t.strictEqual(response.headers['content-type'], 'application/json; charset=utf-8') - t.strictEqual(response.headers['content-length'], '' + body.length) + t.equal(response.statusCode, 500) + t.equal(response.headers['content-type'], 'application/json; charset=utf-8') + t.equal(response.headers['content-length'], '' + body.length) let content = null ejs.renderFile(path.join(templatesFolder, 'index-with-includes-one-missing.ejs'), data, options, function (err, str) { content = str t.type(err, Error) // expected Error here ... - t.strictEqual(content, undefined) + t.equal(content, undefined) }) t.matchSnapshot(content, 'output') @@ -215,15 +215,15 @@ test('reply.view with ejs engine, templates with folder specified, include files url: 'http://localhost:' + fastify.server.address().port + '/include-one-attribute-missing-test' }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 500) - t.strictEqual(response.headers['content-type'], 'application/json; charset=utf-8') - t.strictEqual(response.headers['content-length'], '' + body.length) + t.equal(response.statusCode, 500) + t.equal(response.headers['content-type'], 'application/json; charset=utf-8') + t.equal(response.headers['content-length'], '' + body.length) let content = null ejs.renderFile(path.join(templatesFolder, 'index-with-includes-and-attribute-missing.ejs'), data, options, function (err, str) { content = str t.type(err, Error) // expected Error here ... - t.strictEqual(content, undefined) + t.equal(content, undefined) }) t.matchSnapshot(content, 'output') diff --git a/test/test-ejs.js b/test/test-ejs.js index 27f51ac0..80953222 100644 --- a/test/test-ejs.js +++ b/test/test-ejs.js @@ -41,10 +41,10 @@ test('reply.view with ejs engine and custom templates folder', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -76,10 +76,10 @@ test('reply.view with ejs engine with layout option', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -111,10 +111,10 @@ test('reply.view with ejs engine and custom ext', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -146,10 +146,10 @@ test('reply.view for ejs without data-parameter but defaultContext', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -181,10 +181,10 @@ test('reply.view for ejs without data-parameter but defaultContext', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -214,10 +214,10 @@ test('reply.view for ejs without data-parameter and without defaultContext', t = url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(ejs.render(fs.readFileSync('./templates/index-bare.html', 'utf8')), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(ejs.render(fs.readFileSync('./templates/index-bare.html', 'utf8')), body.toString()) fastify.close() }) }) @@ -252,10 +252,10 @@ test('reply.view for ejs engine without data-parameter and defaultContext but wi url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(ejs.render(fs.readFileSync('./templates/index-bare.html', 'utf8'), localsData), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(ejs.render(fs.readFileSync('./templates/index-bare.html', 'utf8'), localsData), body.toString()) fastify.close() }) }) @@ -291,10 +291,10 @@ test('reply.view for ejs engine without defaultContext but with reply.locals and url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(ejs.render(fs.readFileSync('./templates/index-bare.html', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(ejs.render(fs.readFileSync('./templates/index-bare.html', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -331,10 +331,10 @@ test('reply.view for ejs engine without data-parameter but with reply.locals and url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(ejs.render(fs.readFileSync('./templates/index-bare.html', 'utf8'), localsData), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(ejs.render(fs.readFileSync('./templates/index-bare.html', 'utf8'), localsData), body.toString()) fastify.close() }) }) @@ -372,10 +372,10 @@ test('reply.view for ejs engine with data-parameter and reply.locals and default url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(ejs.render(fs.readFileSync('./templates/index-bare.html', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(ejs.render(fs.readFileSync('./templates/index-bare.html', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -406,10 +406,10 @@ test('reply.view with ejs engine and full path templates folder', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -439,10 +439,10 @@ test('reply.view with ejs engine', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -473,10 +473,10 @@ test('reply.view with ejs engine and defaultContext', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -510,10 +510,10 @@ test('reply.view with ejs engine and html-minifier', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(minifier.minify(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), minifierOpts), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(minifier.minify(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), minifierOpts), body.toString()) fastify.close() }) }) @@ -544,10 +544,10 @@ test('reply.view with ejs engine and includeViewExtension property as true', t = url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -587,15 +587,15 @@ test('reply.view with ejs engine, template folder specified, include files (ejs url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(response.headers['content-length'], '' + body.length) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.headers['content-length'], '' + body.length) let content = null ejs.renderFile(templatesFolder + '/index-linking-other-pages.ejs', data, options, function (err, str) { content = str t.error(err) - t.strictEqual(content.length, body.length) + t.equal(content.length, body.length) }) fastify.close() @@ -636,15 +636,15 @@ test('reply.view with ejs engine, templates with folder specified, include files url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(response.headers['content-length'], '' + body.length) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.headers['content-length'], '' + body.length) let content = null ejs.renderFile(templatesFolder + '/index.ejs', data, options, function (err, str) { content = str t.error(err) - t.strictEqual(content.length, body.length) + t.equal(content.length, body.length) }) fastify.close() @@ -684,15 +684,15 @@ test('reply.view with ejs engine, templates with folder specified, include files url: 'http://localhost:' + fastify.server.address().port + '/no-data-test' }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(response.headers['content-length'], '' + body.length) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.headers['content-length'], '' + body.length) let content = null ejs.renderFile(templatesFolder + '/index-with-no-data.ejs', null, options, function (err, str) { content = str t.error(err) - t.strictEqual(content.length, body.length) + t.equal(content.length, body.length) }) fastify.close() @@ -734,15 +734,15 @@ test('reply.view with ejs engine, templates with folder specified, include files url: 'http://localhost:' + fastify.server.address().port + '/include-test' }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(response.headers['content-length'], '' + body.length) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.headers['content-length'], '' + body.length) let content = null ejs.renderFile(templatesFolder + '/index-with-includes.ejs', data, options, function (err, str) { content = str t.error(err) - t.strictEqual(content.length, body.length) + t.equal(content.length, body.length) }) fastify.close() @@ -783,15 +783,15 @@ test('reply.view with ejs engine, templates with folder specified, include files url: 'http://localhost:' + fastify.server.address().port + '/include-one-include-missing-test' }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 500) - t.strictEqual(response.headers['content-type'], 'application/json; charset=utf-8') - t.strictEqual(response.headers['content-length'], '' + body.length) + t.equal(response.statusCode, 500) + t.equal(response.headers['content-type'], 'application/json; charset=utf-8') + t.equal(response.headers['content-length'], '' + body.length) let content = null ejs.renderFile(templatesFolder + '/index-with-includes-one-missing.ejs', data, options, function (err, str) { content = str t.type(err, Error) // expected Error here ... - t.strictEqual(content, undefined) + t.equal(content, undefined) }) fastify.close() @@ -832,15 +832,15 @@ test('reply.view with ejs engine, templates with folder specified, include files url: 'http://localhost:' + fastify.server.address().port + '/include-one-attribute-missing-test' }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 500) - t.strictEqual(response.headers['content-type'], 'application/json; charset=utf-8') - t.strictEqual(response.headers['content-length'], '' + body.length) + t.equal(response.statusCode, 500) + t.equal(response.headers['content-type'], 'application/json; charset=utf-8') + t.equal(response.headers['content-length'], '' + body.length) let content = null ejs.renderFile(templatesFolder + '/index-with-includes-and-attribute-missing.ejs', data, options, function (err, str) { content = str t.type(err, Error) // expected Error here ... - t.strictEqual(content, undefined) + t.equal(content, undefined) }) fastify.close() @@ -864,7 +864,7 @@ test('fastify.view with ejs engine, missing template file', t => { fastify.view('./missing.html', {}, err => { t.ok(err instanceof Error) - t.is(err.message, `ENOENT: no such file or directory, open '${path.join(__dirname, '../missing.html')}'`) + t.equal(err.message, `ENOENT: no such file or directory, open '${path.join(__dirname, '../missing.html')}'`) fastify.close() }) }) @@ -888,14 +888,14 @@ test('fastify.view with ejs engine and callback in production mode', t => { fastify.view('templates/index.ejs', data, (err, compiled) => { t.error(err) - t.strictEqual(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), compiled) + t.equal(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), compiled) fastify.ready(err => { t.error(err) fastify.view('templates/index.ejs', data, (err, compiled) => { t.error(err) - t.strictEqual(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), compiled) + t.equal(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), compiled) fastify.close() }) }) diff --git a/test/test-eta.js b/test/test-eta.js index 37ff3c64..163e258b 100644 --- a/test/test-eta.js +++ b/test/test-eta.js @@ -38,10 +38,10 @@ test('reply.view with eta engine and custom templates folder', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(eta.render(fs.readFileSync('./templates/index.eta', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(eta.render(fs.readFileSync('./templates/index.eta', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -73,10 +73,10 @@ test('reply.view with eta engine with layout option', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(eta.render(fs.readFileSync('./templates/index.eta', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(eta.render(fs.readFileSync('./templates/index.eta', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -108,10 +108,10 @@ test('reply.view with eta engine and custom ext', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(eta.render(fs.readFileSync('./templates/index.eta', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(eta.render(fs.readFileSync('./templates/index.eta', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -143,10 +143,10 @@ test('reply.view for eta without data-parameter but defaultContext', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(eta.render(fs.readFileSync('./templates/index.eta', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(eta.render(fs.readFileSync('./templates/index.eta', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -178,10 +178,10 @@ test('reply.view for eta without data-parameter but defaultContext', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(eta.render(fs.readFileSync('./templates/index.eta', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(eta.render(fs.readFileSync('./templates/index.eta', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -210,10 +210,10 @@ test('reply.view for eta without data-parameter and without defaultContext', t = url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(eta.render(fs.readFileSync('./templates/index-bare.html', 'utf8')), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(eta.render(fs.readFileSync('./templates/index-bare.html', 'utf8')), body.toString()) fastify.close() }) }) @@ -248,10 +248,10 @@ test('reply.view for eta engine without data-parameter and defaultContext but wi url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(eta.render(fs.readFileSync('./templates/index-bare.html', 'utf8'), localsData), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(eta.render(fs.readFileSync('./templates/index-bare.html', 'utf8'), localsData), body.toString()) fastify.close() }) }) @@ -287,10 +287,10 @@ test('reply.view for eta engine without defaultContext but with reply.locals and url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(eta.render(fs.readFileSync('./templates/index-bare.html', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(eta.render(fs.readFileSync('./templates/index-bare.html', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -327,10 +327,10 @@ test('reply.view for eta engine without data-parameter but with reply.locals and url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(eta.render(fs.readFileSync('./templates/index-bare.html', 'utf8'), localsData), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(eta.render(fs.readFileSync('./templates/index-bare.html', 'utf8'), localsData), body.toString()) fastify.close() }) }) @@ -368,10 +368,10 @@ test('reply.view for eta engine with data-parameter and reply.locals and default url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(eta.render(fs.readFileSync('./templates/index-bare.html', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(eta.render(fs.readFileSync('./templates/index-bare.html', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -402,10 +402,10 @@ test('reply.view with eta engine and full path templates folder', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(eta.render(fs.readFileSync('./templates/index.eta', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(eta.render(fs.readFileSync('./templates/index.eta', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -435,10 +435,10 @@ test('reply.view with eta engine', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(eta.render(fs.readFileSync('./templates/index.eta', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(eta.render(fs.readFileSync('./templates/index.eta', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -469,10 +469,10 @@ test('reply.view with eta engine and defaultContext', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(eta.render(fs.readFileSync('./templates/index.eta', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(eta.render(fs.readFileSync('./templates/index.eta', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -503,10 +503,10 @@ test('reply.view with eta engine and includeViewExtension property as true', t = url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(eta.render(fs.readFileSync('./templates/index.eta', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(eta.render(fs.readFileSync('./templates/index.eta', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -543,15 +543,15 @@ test('reply.view with eta engine, template folder specified, include files (eta url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(response.headers['content-length'], '' + body.length) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.headers['content-length'], '' + body.length) let content = null eta.renderFile('/index-linking-other-pages.eta', data, options, function (err, str) { content = str t.error(err) - t.strictEqual(content.length, body.length) + t.equal(content.length, body.length) }) fastify.close() @@ -590,9 +590,9 @@ test('reply.view with eta engine, templates with folder specified, include files url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(response.headers['content-length'], '' + body.length) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.headers['content-length'], '' + body.length) let content = null eta.renderFile( @@ -602,7 +602,7 @@ test('reply.view with eta engine, templates with folder specified, include files function (err, str) { content = str t.error(err) - t.strictEqual(content.length, body.length) + t.equal(content.length, body.length) } ) @@ -641,9 +641,9 @@ test('reply.view with eta engine, templates with folder specified, include files url: 'http://localhost:' + fastify.server.address().port + '/no-data-test' }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(response.headers['content-length'], '' + body.length) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.headers['content-length'], '' + body.length) let content = null eta.renderFile( @@ -653,7 +653,7 @@ test('reply.view with eta engine, templates with folder specified, include files function (err, str) { content = str t.error(err) - t.strictEqual(content.length, body.length) + t.equal(content.length, body.length) } ) @@ -694,9 +694,9 @@ test('reply.view with eta engine, templates with folder specified, include files url: 'http://localhost:' + fastify.server.address().port + '/include-test' }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(response.headers['content-length'], '' + body.length) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.headers['content-length'], '' + body.length) let content = null eta.renderFile( @@ -706,7 +706,7 @@ test('reply.view with eta engine, templates with folder specified, include files function (err, str) { content = str t.error(err) - t.strictEqual(content.length, body.length) + t.equal(content.length, body.length) } ) @@ -746,9 +746,9 @@ test('reply.view with eta engine, templates with folder specified, include files url: 'http://localhost:' + fastify.server.address().port + '/include-one-include-missing-test' }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 500) - t.strictEqual(response.headers['content-type'], 'application/json; charset=utf-8') - t.strictEqual(response.headers['content-length'], '' + body.length) + t.equal(response.statusCode, 500) + t.equal(response.headers['content-type'], 'application/json; charset=utf-8') + t.equal(response.headers['content-length'], '' + body.length) let content = null eta.renderFile( @@ -758,7 +758,7 @@ test('reply.view with eta engine, templates with folder specified, include files function (err, str) { content = str t.type(err, Error) // expected Error here ... - t.strictEqual(content, undefined) + t.equal(content, undefined) } ) @@ -785,14 +785,14 @@ test('fastify.view with eta engine and callback in production mode', t => { fastify.view('templates/index.eta', data, (err, compiled) => { t.error(err) - t.strictEqual(eta.render(fs.readFileSync('./templates/index.eta', 'utf8'), data), compiled) + t.equal(eta.render(fs.readFileSync('./templates/index.eta', 'utf8'), data), compiled) fastify.ready(err => { t.error(err) fastify.view('templates/index.eta', data, (err, compiled) => { t.error(err) - t.strictEqual(eta.render(fs.readFileSync('./templates/index.eta', 'utf8'), data), compiled) + t.equal(eta.render(fs.readFileSync('./templates/index.eta', 'utf8'), data), compiled) fastify.close() }) }) @@ -840,9 +840,9 @@ test('fastify.view with eta engine and custom cache', t => { fastify.get('/', (req, reply) => { try { const res = reply.view(tplPath, data) - t.strictEqual(eta.config.templates, pseudoCache, + t.equal(eta.config.templates, pseudoCache, 'Cache instance should be equal to the pre-defined one') - t.notStrictEqual(eta.config.templates.get(tplAbsPath), undefined, + t.not(eta.config.templates.get(tplAbsPath), undefined, 'Template should be pre-cached') return res } catch (e) { @@ -857,10 +857,10 @@ test('fastify.view with eta engine and custom cache', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200, 'Response should be 200') + t.equal(response.statusCode, 200, 'Response should be 200') tplFn(data, eta.config, (err, str) => { t.error(err) - t.strictEqual(str, body.toString(), 'Route should return the same result as cached template function') + t.equal(str, body.toString(), 'Route should return the same result as cached template function') }) fastify.close() }) @@ -882,7 +882,7 @@ test('fastify.view with eta engine, should throw page missing', t => { fastify.view(null, {}, err => { t.ok(err instanceof Error) - t.is(err.message, 'Missing page') + t.equal(err.message, 'Missing page') fastify.close() }) }) diff --git a/test/test-handlebars.js b/test/test-handlebars.js index 0f6d1e5b..aad1813b 100644 --- a/test/test-handlebars.js +++ b/test/test-handlebars.js @@ -27,7 +27,7 @@ test('fastify.view with handlebars engine', t => { t.error(err) fastify.view('./templates/index.html', data).then(compiled => { - t.strictEqual(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(data), compiled) + t.equal(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(data), compiled) fastify.close() }) }) @@ -50,7 +50,7 @@ test('fastify.view for handlebars without data-parameter but defaultContext', t t.error(err) fastify.view('./templates/index.html').then(compiled => { - t.strictEqual(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(data), compiled) + t.equal(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(data), compiled) fastify.close() }) }) @@ -71,7 +71,7 @@ test('fastify.view for handlebars without data-parameter and without defaultCont t.error(err) fastify.view('./templates/index.html').then(compiled => { - t.strictEqual(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(), compiled) + t.equal(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(), compiled) fastify.close() }) }) @@ -95,7 +95,7 @@ test('fastify.view with handlebars engine and defaultContext', t => { t.error(err) fastify.view('./templates/index.html', {}).then(compiled => { - t.strictEqual(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(data), compiled) + t.equal(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(data), compiled) fastify.close() }) }) @@ -130,10 +130,10 @@ test('reply.view for handlebars engine without data-parameter and defaultContext url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(localsData), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(localsData), body.toString()) fastify.close() }) }) @@ -169,10 +169,10 @@ test('reply.view for handlebars engine without defaultContext but with reply.loc url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(data), body.toString()) fastify.close() }) }) @@ -209,10 +209,10 @@ test('reply.view for handlebars engine without data-parameter but with reply.loc url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(localsData), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(localsData), body.toString()) fastify.close() }) }) @@ -250,10 +250,10 @@ test('reply.view for handlebars engine with data-parameter and reply.locals and url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(data), body.toString()) fastify.close() }) }) @@ -276,7 +276,7 @@ test('fastify.view with handlebars engine and callback', t => { fastify.view('./templates/index.html', data, (err, compiled) => { t.error(err) - t.strictEqual(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(data), compiled) + t.equal(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(data), compiled) fastify.close() }) }) @@ -301,7 +301,7 @@ test('fastify.view with handlebars engine with layout option', t => { fastify.view('./templates/index-for-layout.hbs', data, (err, compiled) => { t.error(err) - t.strictEqual(handlebars.compile(fs.readFileSync('./templates/index.hbs', 'utf8'))(data), compiled) + t.equal(handlebars.compile(fs.readFileSync('./templates/index.hbs', 'utf8'))(data), compiled) fastify.close() }) }) @@ -331,10 +331,10 @@ test('reply.view with handlebars engine', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(data), body.toString()) fastify.close() }) }) @@ -362,8 +362,8 @@ test('reply.view with handlebars engine catches render error', t => { url: '/' }, (err, res) => { t.error(err) - t.strictEqual(JSON.parse(res.body).message, 'kaboom') - t.strictEqual(res.statusCode, 500) + t.equal(JSON.parse(res.body).message, 'kaboom') + t.equal(res.statusCode, 500) }) }) @@ -392,10 +392,10 @@ test('reply.view with handlebars engine and defaultContext', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(data), body.toString()) fastify.close() }) }) @@ -426,10 +426,10 @@ test('reply.view with ejs engine and includeViewExtension property as true', t = url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -469,15 +469,15 @@ test('reply.view with ejs engine, template folder specified, include files (ejs url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(response.headers['content-length'], '' + body.length) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.headers['content-length'], '' + body.length) let content = null ejs.renderFile(templatesFolder + '/index-linking-other-pages.ejs', data, options, function (err, str) { content = str t.error(err) - t.strictEqual(content.length, body.length) + t.equal(content.length, body.length) }) fastify.close() @@ -518,15 +518,15 @@ test('reply.view with ejs engine, templates with folder specified, include files url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(response.headers['content-length'], '' + body.length) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.headers['content-length'], '' + body.length) let content = null ejs.renderFile(templatesFolder + '/index.ejs', data, options, function (err, str) { content = str t.error(err) - t.strictEqual(content.length, body.length) + t.equal(content.length, body.length) }) fastify.close() @@ -559,10 +559,10 @@ test('reply.view with handlebars engine and includeViewExtension property as tru url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(handlebars.compile(fs.readFileSync('./templates/index.hbs', 'utf8'))(data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(handlebars.compile(fs.readFileSync('./templates/index.hbs', 'utf8'))(data), body.toString()) fastify.close() }) }) @@ -586,14 +586,14 @@ test('fastify.view with handlebars engine and callback in production mode', t => fastify.view('./templates/index.html', data, (err, compiled) => { t.error(err) - t.strictEqual(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(data), compiled) + t.equal(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(data), compiled) fastify.ready(err => { t.error(err) fastify.view('./templates/index.html', data, (err, compiled) => { t.error(err) - t.strictEqual(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(data), compiled) + t.equal(handlebars.compile(fs.readFileSync('./templates/index.html', 'utf8'))(data), compiled) fastify.close() }) }) @@ -627,10 +627,10 @@ test('reply.view with handlebars engine with partials', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, replyBody) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + replyBody.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(handlebars.compile(fs.readFileSync('./templates/index-with-partials.hbs', 'utf8'))(data), replyBody.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + replyBody.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(handlebars.compile(fs.readFileSync('./templates/index-with-partials.hbs', 'utf8'))(data), replyBody.toString()) fastify.close() }) }) @@ -662,9 +662,9 @@ test('reply.view with handlebars engine with missing partials path', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, replyBody) => { t.error(err) - t.strictEqual(response.statusCode, 500) - t.strictEqual(response.headers['content-length'], String(replyBody.length)) - t.strictEqual(response.headers['content-type'], 'application/json; charset=utf-8') + t.equal(response.statusCode, 500) + t.equal(response.headers['content-length'], String(replyBody.length)) + t.equal(response.headers['content-type'], 'application/json; charset=utf-8') fastify.close() }) @@ -679,11 +679,11 @@ test('reply.view with handlebars engine with partials in production mode should hashlru: function () { return { get: (key) => { - t.is(key, 'handlebars-Partials') + t.equal(key, 'handlebars-Partials') }, set: (key, value) => { - t.is(key, 'handlebars-Partials') - t.strictDeepEqual(value, { body: fs.readFileSync('./templates/body.hbs', 'utf8') }) + t.equal(key, 'handlebars-Partials') + t.strictSame(value, { body: fs.readFileSync('./templates/body.hbs', 'utf8') }) } } } @@ -722,7 +722,7 @@ test('fastify.view with handlebars engine with missing partials path in producti fastify.ready(err => { t.ok(err instanceof Error) - t.is(err.message, `ENOENT: no such file or directory, open '${join(__dirname, '../non-existent')}'`) + t.equal(err.message, `ENOENT: no such file or directory, open '${join(__dirname, '../non-existent')}'`) }) }) @@ -749,10 +749,10 @@ test('reply.view with handlebars engine with layout option', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, replyBody) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + replyBody.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(handlebars.compile(fs.readFileSync('./templates/index.hbs', 'utf8'))({}), replyBody.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + replyBody.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(handlebars.compile(fs.readFileSync('./templates/index.hbs', 'utf8'))({}), replyBody.toString()) fastify.close() }) }) @@ -774,7 +774,7 @@ test('fastify.view with handlebars engine, missing template file', t => { fastify.view('./missing.html', {}, err => { t.ok(err instanceof Error) - t.is(err.message, `ENOENT: no such file or directory, open '${join(__dirname, '../missing.html')}'`) + t.equal(err.message, `ENOENT: no such file or directory, open '${join(__dirname, '../missing.html')}'`) fastify.close() }) }) @@ -796,7 +796,7 @@ test('fastify.view with handlebars engine should throw page missing', t => { fastify.view(null, {}, err => { t.ok(err instanceof Error) - t.is(err.message, 'Missing page') + t.equal(err.message, 'Missing page') fastify.close() }) }) @@ -838,8 +838,8 @@ test('reply.view with handlebars engine should return 500 if template fails in p }, (err, response, body) => { const { message } = JSON.parse(body.toString()) t.error(err) - t.strictEqual(response.statusCode, 500) - t.strictEqual('Template Error', message) + t.equal(response.statusCode, 500) + t.equal('Template Error', message) fastify.close() }) diff --git a/test/test-liquid.js b/test/test-liquid.js index 135bd757..915f820f 100644 --- a/test/test-liquid.js +++ b/test/test-liquid.js @@ -34,13 +34,13 @@ test('reply.view with liquid engine', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') engine.renderFile('./templates/index.liquid', data) .then((html) => { t.error(err) - t.strictEqual(html, body.toString()) + t.equal(html, body.toString()) }) fastify.close() }) @@ -74,13 +74,13 @@ test('reply.view with liquid engine without data-parameter but defaultContext', url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') engine.renderFile('./templates/index.liquid', data) .then((html) => { t.error(err) - t.strictEqual(html, body.toString()) + t.equal(html, body.toString()) }) fastify.close() }) @@ -112,13 +112,13 @@ test('reply.view with liquid engine without data-parameter but without defaultCo url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') engine.renderFile('./templates/index.liquid') .then((html) => { t.error(err) - t.strictEqual(html, body.toString()) + t.equal(html, body.toString()) }) fastify.close() }) @@ -152,13 +152,13 @@ test('reply.view with liquid engine with data-parameter and defaultContext', t = url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') engine.renderFile('./templates/index.liquid', data) .then((html) => { t.error(err) - t.strictEqual(html, body.toString()) + t.equal(html, body.toString()) }) fastify.close() }) @@ -196,13 +196,13 @@ test('reply.view for liquid engine without data-parameter and defaultContext but url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') engine.renderFile('./templates/index.liquid', localsData) .then((html) => { t.error(err) - t.strictEqual(html, body.toString()) + t.equal(html, body.toString()) }) fastify.close() }) @@ -241,13 +241,13 @@ test('reply.view for liquid engine without defaultContext but with reply.locals url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') engine.renderFile('./templates/index.liquid', data) .then((html) => { t.error(err) - t.strictEqual(html, body.toString()) + t.equal(html, body.toString()) }) fastify.close() }) @@ -287,13 +287,13 @@ test('reply.view for liquid engine without data-parameter but with reply.locals url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') engine.renderFile('./templates/index.liquid', localsData) .then((html) => { t.error(err) - t.strictEqual(html, body.toString()) + t.equal(html, body.toString()) }) fastify.close() }) @@ -334,13 +334,13 @@ test('reply.view for liquid engine with data-parameter and reply.locals and defa url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') engine.renderFile('./templates/index.liquid', data) .then((html) => { t.error(err) - t.strictEqual(html, body.toString()) + t.equal(html, body.toString()) }) fastify.close() }) @@ -384,13 +384,13 @@ test('reply.view with liquid engine and custom tag', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') engine.renderFile('./templates/index-with-custom-tag.liquid', data) .then((html) => { t.error(err) - t.strictEqual(html, body.toString()) + t.equal(html, body.toString()) }) fastify.close() }) @@ -423,13 +423,13 @@ test('reply.view with liquid engine and double quoted variable', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') engine.renderFile('./templates/double-quotes-variable.liquid', data) .then((html) => { t.error(err) - t.strictEqual(html, body.toString()) + t.equal(html, body.toString()) }) fastify.close() }) @@ -453,7 +453,7 @@ test('fastify.view with liquid engine, should throw page missing', t => { fastify.view(null, {}, err => { t.ok(err instanceof Error) - t.is(err.message, 'Missing page') + t.equal(err.message, 'Missing page') fastify.close() }) }) diff --git a/test/test-marko.js b/test/test-marko.js index 93abb144..1c5abcab 100644 --- a/test/test-marko.js +++ b/test/test-marko.js @@ -38,10 +38,10 @@ test('reply.view with marko engine', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(marko.load('./templates/index.marko').renderToString(data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(marko.load('./templates/index.marko').renderToString(data), body.toString()) fastify.close() }) }) @@ -72,10 +72,10 @@ test('reply.view for marko without data-parameter but defaultContext', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(marko.load('./templates/index.marko').renderToString(data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(marko.load('./templates/index.marko').renderToString(data), body.toString()) fastify.close() }) }) @@ -104,10 +104,10 @@ test('reply.view for marko without data-parameter but without defaultContext', t url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(marko.load('./templates/index.marko').renderToString(), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(marko.load('./templates/index.marko').renderToString(), body.toString()) fastify.close() }) }) @@ -138,10 +138,10 @@ test('reply.view with marko engine and defaultContext', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(marko.load('./templates/index.marko').renderToString(data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(marko.load('./templates/index.marko').renderToString(data), body.toString()) fastify.close() }) }) @@ -176,10 +176,10 @@ test('reply.view for marko engine without data-parameter and defaultContext but url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(marko.load('./templates/index.marko').renderToString(localsData), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(marko.load('./templates/index.marko').renderToString(localsData), body.toString()) fastify.close() }) }) @@ -215,10 +215,10 @@ test('reply.view for marko engine without defaultContext but with reply.locals a url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(marko.load('./templates/index.marko').renderToString(data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(marko.load('./templates/index.marko').renderToString(data), body.toString()) fastify.close() }) }) @@ -255,10 +255,10 @@ test('reply.view for marko engine without data-parameter but with reply.locals a url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(marko.load('./templates/index.marko').renderToString(localsData), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(marko.load('./templates/index.marko').renderToString(localsData), body.toString()) fastify.close() }) }) @@ -296,10 +296,10 @@ test('reply.view for marko engine with data-parameter and reply.locals and defau url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(marko.load('./templates/index.marko').renderToString(data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(marko.load('./templates/index.marko').renderToString(data), body.toString()) fastify.close() }) }) @@ -333,10 +333,10 @@ test('reply.view with marko engine and html-minifier', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(minifier.minify(marko.load('./templates/index.marko').renderToString(data), minifierOpts), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(minifier.minify(marko.load('./templates/index.marko').renderToString(data), minifierOpts), body.toString()) fastify.close() }) }) @@ -362,7 +362,7 @@ test('fastify.view with marko engine and html-minifier without htmlMinifierOptio fastify.view('templates/index.marko', data, (err, compiled) => { t.error(err) - t.strictEqual(minifier.minify(marko.load('./templates/index.marko').renderToString(data)), compiled) + t.equal(minifier.minify(marko.load('./templates/index.marko').renderToString(data)), compiled) fastify.close() }) @@ -393,9 +393,9 @@ test('reply.view with marko engine, with stream', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-type'], 'application/octet-stream') - t.strictEqual(marko.load('./templates/index.marko').renderToString(data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-type'], 'application/octet-stream') + t.equal(marko.load('./templates/index.marko').renderToString(data), body.toString()) fastify.close() }) }) @@ -430,9 +430,9 @@ test('reply.view with marko engine, with stream and html-minify-stream', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-type'], 'application/octet-stream') - t.strictEqual(minifier.minify(marko.load('./templates/index.marko').renderToString(data), minifierOpts), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-type'], 'application/octet-stream') + t.equal(minifier.minify(marko.load('./templates/index.marko').renderToString(data), minifierOpts), body.toString()) fastify.close() }) }) @@ -466,9 +466,9 @@ test('reply.view with marko engine, with stream and html-minify-stream without h url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-type'], 'application/octet-stream') - t.strictEqual(minifier.minify(marko.load('./templates/index.marko').renderToString(data)), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-type'], 'application/octet-stream') + t.equal(minifier.minify(marko.load('./templates/index.marko').renderToString(data)), body.toString()) fastify.close() }) }) @@ -491,14 +491,14 @@ test('fastify.view with marko engine', t => { fastify.view('templates/index.marko', data, (err, compiled) => { t.error(err) - t.strictEqual(marko.load('./templates/index.marko').renderToString(data), compiled) + t.equal(marko.load('./templates/index.marko').renderToString(data), compiled) fastify.ready(err => { t.error(err) fastify.view('templates/index.marko', data, (err, compiled) => { t.error(err) - t.strictEqual(marko.load('./templates/index.marko').renderToString(data), compiled) + t.equal(marko.load('./templates/index.marko').renderToString(data), compiled) fastify.close() }) }) @@ -536,14 +536,14 @@ test('fastify.view to load template from memory with marko engine', t => { t.error(err) const markoLoaded = marko.load('./templates/index.marko', opts).renderToString(data) - t.strictEqual(markoLoaded, compiled) + t.equal(markoLoaded, compiled) fastify.ready(err => { t.error(err) fastify.view('templates/index.marko', data, (err, compiled) => { t.error(err) const markoLoaded = marko.load('./templates/index.marko', opts).renderToString(data) - t.strictEqual(markoLoaded, compiled) + t.equal(markoLoaded, compiled) fastify.close() }) }) @@ -567,7 +567,7 @@ test('fastify.view with marko should throw page missing', t => { fastify.view(null, {}, err => { t.ok(err instanceof Error) - t.is(err.message, 'Missing page') + t.equal(err.message, 'Missing page') fastify.close() }) }) @@ -601,8 +601,8 @@ test('reply.view with marko engine should return 500 if renderToString fails', t }, (err, response, body) => { const { message } = JSON.parse(body.toString()) t.error(err) - t.strictEqual(response.statusCode, 500) - t.strictEqual('RenderToString Error', message) + t.equal(response.statusCode, 500) + t.equal('RenderToString Error', message) fastify.close() }) diff --git a/test/test-mustache.js b/test/test-mustache.js index 5ae64cf2..0b42680e 100644 --- a/test/test-mustache.js +++ b/test/test-mustache.js @@ -40,10 +40,10 @@ test('reply.view with mustache engine', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(mustache.render(fs.readFileSync('./templates/index.html', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(mustache.render(fs.readFileSync('./templates/index.html', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -74,10 +74,10 @@ test('reply.view for mustache without data-parameter but defaultContext', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(mustache.render(fs.readFileSync('./templates/index.html', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(mustache.render(fs.readFileSync('./templates/index.html', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -107,10 +107,10 @@ test('reply.view for mustache without data-parameter and without defaultContext' url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(mustache.render(fs.readFileSync('./templates/index-bare.html', 'utf8')), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(mustache.render(fs.readFileSync('./templates/index-bare.html', 'utf8')), body.toString()) fastify.close() }) }) @@ -141,10 +141,10 @@ test('reply.view with mustache engine and defaultContext', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(mustache.render(fs.readFileSync('./templates/index.html', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(mustache.render(fs.readFileSync('./templates/index.html', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -179,10 +179,10 @@ test('reply.view for mustache engine without data-parameter and defaultContext b url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(mustache.render(fs.readFileSync('./templates/index.html', 'utf8'), localsData), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(mustache.render(fs.readFileSync('./templates/index.html', 'utf8'), localsData), body.toString()) fastify.close() }) }) @@ -218,10 +218,10 @@ test('reply.view for mustache engine without defaultContext but with reply.local url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(mustache.render(fs.readFileSync('./templates/index.html', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(mustache.render(fs.readFileSync('./templates/index.html', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -258,10 +258,10 @@ test('reply.view for mustache engine without data-parameter but with reply.local url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(mustache.render(fs.readFileSync('./templates/index.html', 'utf8'), localsData), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(mustache.render(fs.readFileSync('./templates/index.html', 'utf8'), localsData), body.toString()) fastify.close() }) }) @@ -299,10 +299,10 @@ test('reply.view for mustache engine with data-parameter and reply.locals and de url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(mustache.render(fs.readFileSync('./templates/index.html', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(mustache.render(fs.readFileSync('./templates/index.html', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -331,10 +331,10 @@ test('reply.view with mustache engine with partials', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, replyBody) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + replyBody.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(mustache.render(fs.readFileSync('./templates/index.mustache', 'utf8'), data, { body: '

{{ text }}

' }), replyBody.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + replyBody.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(mustache.render(fs.readFileSync('./templates/index.mustache', 'utf8'), data, { body: '

{{ text }}

' }), replyBody.toString()) fastify.close() }) }) @@ -374,10 +374,10 @@ test('reply.view with mustache engine with partials in production mode should us url: 'http://localhost:' + fastify.server.address().port }, (err, response, replyBody) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], String(replyBody.length)) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual('
Cached Response
', replyBody.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], String(replyBody.length)) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal('
Cached Response
', replyBody.toString()) fastify.close() }) }) @@ -410,10 +410,10 @@ test('reply.view with mustache engine with partials and html-minifier', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, replyBody) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + replyBody.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(minifier.minify(mustache.render(fs.readFileSync('./templates/index.mustache', 'utf8'), data, { body: '

{{ text }}

' }), minifierOpts), replyBody.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + replyBody.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(minifier.minify(mustache.render(fs.readFileSync('./templates/index.mustache', 'utf8'), data, { body: '

{{ text }}

' }), minifierOpts), replyBody.toString()) fastify.close() }) }) @@ -445,10 +445,10 @@ test('reply.view with mustache engine, template folder specified', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(mustache.render(fs.readFileSync('./templates/index.html', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(mustache.render(fs.readFileSync('./templates/index.html', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -479,10 +479,10 @@ test('reply.view with mustache engine, template folder specified with partials', url: 'http://localhost:' + fastify.server.address().port }, (err, response, replyBody) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + replyBody.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(mustache.render(fs.readFileSync('./templates/index.mustache', 'utf8'), data, { body: '

{{ text }}

' }), replyBody.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + replyBody.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(mustache.render(fs.readFileSync('./templates/index.mustache', 'utf8'), data, { body: '

{{ text }}

' }), replyBody.toString()) fastify.close() }) }) @@ -512,9 +512,9 @@ test('reply.view with mustache engine, missing template file', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 500) - t.strictEqual(response.headers['content-type'], 'application/json; charset=utf-8') - t.strictEqual(response.headers['content-length'], '' + body.length) + t.equal(response.statusCode, 500) + t.equal(response.headers['content-type'], 'application/json; charset=utf-8') + t.equal(response.headers['content-length'], '' + body.length) fastify.close() }) }) @@ -543,9 +543,9 @@ test('reply.view with mustache engine, with partials missing template file', t = url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 500) - t.strictEqual(response.headers['content-type'], 'application/json; charset=utf-8') - t.strictEqual(response.headers['content-length'], '' + body.length) + t.equal(response.statusCode, 500) + t.equal(response.headers['content-type'], 'application/json; charset=utf-8') + t.equal(response.headers['content-length'], '' + body.length) fastify.close() }) }) @@ -574,9 +574,9 @@ test('reply.view with mustache engine, with partials missing partials file', t = url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 500) - t.strictEqual(response.headers['content-type'], 'application/json; charset=utf-8') - t.strictEqual(response.headers['content-length'], '' + body.length) + t.equal(response.statusCode, 500) + t.equal(response.headers['content-type'], 'application/json; charset=utf-8') + t.equal(response.headers['content-length'], '' + body.length) fastify.close() }) }) @@ -605,9 +605,9 @@ test('reply.view with mustache engine, with partials and multiple missing partia url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 500) - t.strictEqual(response.headers['content-type'], 'application/json; charset=utf-8') - t.strictEqual(response.headers['content-length'], '' + body.length) + t.equal(response.statusCode, 500) + t.equal(response.headers['content-type'], 'application/json; charset=utf-8') + t.equal(response.headers['content-length'], '' + body.length) fastify.close() }) }) @@ -629,7 +629,7 @@ test('fastify.view with mustache engine, should throw page missing', t => { fastify.view(null, {}, err => { t.ok(err instanceof Error) - t.is(err.message, 'Missing page') + t.equal(err.message, 'Missing page') fastify.close() }) }) diff --git a/test/test-nunjucks.js b/test/test-nunjucks.js index 3145e1b3..5fc4510e 100644 --- a/test/test-nunjucks.js +++ b/test/test-nunjucks.js @@ -33,10 +33,10 @@ test('reply.view with nunjucks engine and custom templates folder', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(nunjucks.render('./templates/index.njk', data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(nunjucks.render('./templates/index.njk', data), body.toString()) fastify.close() }) }) @@ -67,10 +67,10 @@ test('reply.view for nunjucks engine without data-parameter but defaultContext', url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(nunjucks.render('./templates/index.njk', data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(nunjucks.render('./templates/index.njk', data), body.toString()) fastify.close() }) }) @@ -99,10 +99,10 @@ test('reply.view for nunjucks engine without data-parameter and without defaultC url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(nunjucks.render('./templates/index.njk'), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(nunjucks.render('./templates/index.njk'), body.toString()) fastify.close() }) }) @@ -137,10 +137,10 @@ test('reply.view for nunjucks engine without data-parameter and defaultContext b url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(nunjucks.render('./templates/index.njk', localsData), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(nunjucks.render('./templates/index.njk', localsData), body.toString()) fastify.close() }) }) @@ -176,10 +176,10 @@ test('reply.view for nunjucks engine without defaultContext but with reply.local url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(nunjucks.render('./templates/index.njk', data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(nunjucks.render('./templates/index.njk', data), body.toString()) fastify.close() }) }) @@ -216,10 +216,10 @@ test('reply.view for nunjucks engine without data-parameter but with reply.local url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(nunjucks.render('./templates/index.njk', localsData), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(nunjucks.render('./templates/index.njk', localsData), body.toString()) fastify.close() }) }) @@ -257,10 +257,10 @@ test('reply.view for nunjucks engine with data-parameter and reply.locals and de url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(nunjucks.render('./templates/index.njk', data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(nunjucks.render('./templates/index.njk', data), body.toString()) fastify.close() }) }) @@ -291,11 +291,11 @@ test('reply.view with nunjucks engine and full path templates folder', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') // Global Nunjucks templates dir changed here. - t.strictEqual(nunjucks.render('./index.njk', data), body.toString()) + t.equal(nunjucks.render('./index.njk', data), body.toString()) fastify.close() }) }) @@ -326,11 +326,11 @@ test('reply.view with nunjucks engine and includeViewExtension is true', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') // Global Nunjucks templates dir is `./` here. - t.strictEqual(nunjucks.render('./templates/index.njk', data), body.toString()) + t.equal(nunjucks.render('./templates/index.njk', data), body.toString()) fastify.close() }) }) @@ -365,11 +365,11 @@ test('reply.view with nunjucks engine using onConfigure callback', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') // Global Nunjucks templates dir is `./` here. - t.strictEqual(nunjucks.render('./templates/index-with-global.njk', data), body.toString()) + t.equal(nunjucks.render('./templates/index-with-global.njk', data), body.toString()) t.match(body.toString(), /.*

my global var value<\/p>/) fastify.close() }) @@ -393,14 +393,14 @@ test('fastify.view with nunjucks engine', t => { fastify.view('templates/index.njk', data, (err, compiled) => { t.error(err) - t.strictEqual(nunjucks.render('./templates/index.njk', data), compiled) + t.equal(nunjucks.render('./templates/index.njk', data), compiled) fastify.ready(err => { t.error(err) fastify.view('templates/index.njk', data, (err, compiled) => { t.error(err) - t.strictEqual(nunjucks.render('./templates/index.njk', data), compiled) + t.equal(nunjucks.render('./templates/index.njk', data), compiled) fastify.close() }) }) @@ -424,7 +424,7 @@ test('fastify.view with nunjucks should throw page missing', t => { fastify.view(null, {}, err => { t.ok(err instanceof Error) - t.is(err.message, 'Missing page') + t.equal(err.message, 'Missing page') fastify.close() }) }) @@ -458,8 +458,8 @@ test('fastify.view with nunjucks engine should return 500 if render fails', t => }, (err, response, body) => { const { message } = JSON.parse(body.toString()) t.error(err) - t.strictEqual(response.statusCode, 500) - t.strictEqual('Render Error', message) + t.equal(response.statusCode, 500) + t.equal('Render Error', message) fastify.close() }) diff --git a/test/test-pug.js b/test/test-pug.js index fdde097b..8a8f2ee8 100644 --- a/test/test-pug.js +++ b/test/test-pug.js @@ -34,10 +34,10 @@ test('reply.view with pug engine', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(pug.render(fs.readFileSync('./templates/index.pug', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(pug.render(fs.readFileSync('./templates/index.pug', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -77,10 +77,10 @@ test('reply.view with pug engine in production mode should use cache', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], String(body.length)) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual('

Cached Response
', body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], String(body.length)) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal('
Cached Response
', body.toString()) fastify.close() }) }) @@ -110,10 +110,10 @@ test('reply.view with pug engine and includes', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(pug.renderFile('./templates/sample.pug', data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(pug.renderFile('./templates/sample.pug', data), body.toString()) fastify.close() }) }) @@ -144,10 +144,10 @@ test('reply.view for pug without data-parameter but defaultContext', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(pug.render(fs.readFileSync('./templates/index.pug', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(pug.render(fs.readFileSync('./templates/index.pug', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -176,10 +176,10 @@ test('reply.view for pug without data-parameter and without defaultContext', t = url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(pug.render(fs.readFileSync('./templates/index.pug', 'utf8')), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(pug.render(fs.readFileSync('./templates/index.pug', 'utf8')), body.toString()) fastify.close() }) }) @@ -210,10 +210,10 @@ test('reply.view with pug engine and defaultContext', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(pug.render(fs.readFileSync('./templates/index.pug', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(pug.render(fs.readFileSync('./templates/index.pug', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -248,10 +248,10 @@ test('reply.view for pug engine without data-parameter and defaultContext but wi url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(pug.render(fs.readFileSync('./templates/index.pug', 'utf8'), localsData), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(pug.render(fs.readFileSync('./templates/index.pug', 'utf8'), localsData), body.toString()) fastify.close() }) }) @@ -287,10 +287,10 @@ test('reply.view for pug engine without defaultContext but with reply.locals and url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(pug.render(fs.readFileSync('./templates/index.pug', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(pug.render(fs.readFileSync('./templates/index.pug', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -327,10 +327,10 @@ test('reply.view for pug engine without data-parameter but with reply.locals and url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(pug.render(fs.readFileSync('./templates/index.pug', 'utf8'), localsData), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(pug.render(fs.readFileSync('./templates/index.pug', 'utf8'), localsData), body.toString()) fastify.close() }) }) @@ -368,10 +368,10 @@ test('reply.view for pug engine with data-parameter and reply.locals and default url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(pug.render(fs.readFileSync('./templates/index.pug', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(pug.render(fs.readFileSync('./templates/index.pug', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -402,10 +402,10 @@ test('reply.view with pug engine, will preserve content-type', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/xml') - t.strictEqual(pug.render(fs.readFileSync('./templates/index.pug', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/xml') + t.equal(pug.render(fs.readFileSync('./templates/index.pug', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -427,7 +427,7 @@ test('fastify.view with pug engine, should throw page missing', t => { fastify.view(null, {}, err => { t.ok(err instanceof Error) - t.is(err.message, 'Missing page') + t.equal(err.message, 'Missing page') fastify.close() }) }) @@ -457,9 +457,9 @@ test('reply.view with pug engine, should throw error if non existent template pa url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 500) - t.strictEqual(response.headers['content-type'], 'application/json; charset=utf-8') - t.strictEqual(response.headers['content-length'], String(body.length)) + t.equal(response.statusCode, 500) + t.equal(response.headers['content-type'], 'application/json; charset=utf-8') + t.equal(response.headers['content-length'], String(body.length)) fastify.close() }) }) @@ -491,8 +491,8 @@ test('reply.view with pug engine should return 500 if compile fails', t => { }, (err, response, body) => { const { message } = JSON.parse(body.toString()) t.error(err) - t.strictEqual(response.statusCode, 500) - t.strictEqual('Compile Error', message) + t.equal(response.statusCode, 500) + t.equal('Compile Error', message) fastify.close() }) diff --git a/test/test-twig.js b/test/test-twig.js index aa54116e..394832fc 100644 --- a/test/test-twig.js +++ b/test/test-twig.js @@ -32,12 +32,12 @@ test('reply.view with twig engine', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') Twig.renderFile('./templates/index.twig', data, (err, html) => { t.error(err) - t.strictEqual(html, body.toString()) + t.equal(html, body.toString()) }) fastify.close() }) @@ -68,12 +68,12 @@ test('reply.view with twig engine and simple include', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') Twig.renderFile('./templates/template.twig', data, (err, html) => { t.error(err) - t.strictEqual(html, body.toString()) + t.equal(html, body.toString()) }) fastify.close() }) @@ -105,12 +105,12 @@ test('reply.view for twig without data-parameter but defaultContext', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') Twig.renderFile('./templates/index.twig', data, (err, html) => { t.error(err) - t.strictEqual(html, body.toString()) + t.equal(html, body.toString()) }) fastify.close() }) @@ -140,12 +140,12 @@ test('reply.view for twig without data-parameter and without defaultContext', t url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') Twig.renderFile('./templates/index.twig', (err, html) => { t.error(err) - t.strictEqual(html, body.toString()) + t.equal(html, body.toString()) }) fastify.close() }) @@ -177,12 +177,12 @@ test('reply.view with twig engine and defaultContext', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') Twig.renderFile('./templates/index.twig', data, (err, html) => { t.error(err) - t.strictEqual(html, body.toString()) + t.equal(html, body.toString()) }) fastify.close() }) @@ -218,12 +218,12 @@ test('reply.view for twig engine without data-parameter and defaultContext but w url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') Twig.renderFile('./templates/index.twig', localsData, (err, html) => { t.error(err) - t.strictEqual(html, body.toString()) + t.equal(html, body.toString()) }) fastify.close() }) @@ -260,12 +260,12 @@ test('reply.view for twig engine without defaultContext but with reply.locals an url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') Twig.renderFile('./templates/index.twig', data, (err, html) => { t.error(err) - t.strictEqual(html, body.toString()) + t.equal(html, body.toString()) }) fastify.close() }) @@ -303,12 +303,12 @@ test('reply.view for twig engine without data-parameter but with reply.locals an url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') Twig.renderFile('./templates/index.twig', localsData, (err, html) => { t.error(err) - t.strictEqual(html, body.toString()) + t.equal(html, body.toString()) }) fastify.close() }) @@ -347,12 +347,12 @@ test('reply.view for twig engine with data-parameter and reply.locals and defaul url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') Twig.renderFile('./templates/index.twig', data, (err, html) => { t.error(err) - t.strictEqual(html, body.toString()) + t.equal(html, body.toString()) }) fastify.close() }) @@ -384,12 +384,12 @@ test('reply.view with twig engine, will preserve content-type', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/xml') + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/xml') Twig.renderFile('./templates/index.twig', data, (err, html) => { t.error(err) - t.strictEqual(html, body.toString()) + t.equal(html, body.toString()) }) fastify.close() }) @@ -412,7 +412,7 @@ test('fastify.view with twig engine, should throw page missing', t => { fastify.view(null, {}, err => { t.ok(err instanceof Error) - t.is(err.message, 'Missing page') + t.equal(err.message, 'Missing page') fastify.close() }) }) @@ -444,8 +444,8 @@ test('reply.view with twig engine should return 500 if renderFile fails', t => { }, (err, response, body) => { const { message } = JSON.parse(body.toString()) t.error(err) - t.strictEqual(response.statusCode, 500) - t.strictEqual('RenderFile Error', message) + t.equal(response.statusCode, 500) + t.equal('RenderFile Error', message) fastify.close() }) diff --git a/test/test.js b/test/test.js index 79db3971..6133f70a 100644 --- a/test/test.js +++ b/test/test.js @@ -73,8 +73,8 @@ test('fastify.view.clearCache clears cache', t => { url: 'http://localhost:' + fastify.server.address().port + '/view-cache-test' }, (err, response, body) => { t.error(err) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') fs.writeFileSync(path.join(templatesFolder, 'cache_clear_test.ejs'), '456') const output = body.toString() sget({ @@ -82,19 +82,19 @@ test('fastify.view.clearCache clears cache', t => { url: 'http://localhost:' + fastify.server.address().port + '/view-cache-test' }, (err, response, body) => { t.error(err) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(output, body.toString()) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(output, body.toString()) fastify.view.clearCache() sget({ method: 'GET', url: 'http://localhost:' + fastify.server.address().port + '/view-cache-test' }, (err, response, body) => { t.error(err) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.notStrictEqual(output, body.toString()) - t.contains(body.toString(), '456') + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.not(output, body.toString()) + t.match(body.toString(), '456') fastify.close() }) }) @@ -125,9 +125,9 @@ test('reply.view exist', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.deepEqual(JSON.parse(body), { hello: 'world' }) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.same(JSON.parse(body), { hello: 'world' }) fastify.close() }) }) @@ -159,10 +159,10 @@ test('reply.view can be returned from async function to indicate response proces url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), data), body.toString()) fastify.close() }) }) @@ -199,10 +199,10 @@ test('Possibility to access res.locals variable across all views', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual('ok', body.toString().trim()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal('ok', body.toString().trim()) fastify.close() }) }) @@ -232,10 +232,10 @@ test('Default extension for ejs', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual('ok', body.toString().trim()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal('ok', body.toString().trim()) fastify.close() }) }) @@ -277,20 +277,20 @@ test('reply.view with ejs engine and custom propertyName', t => { headers: { 'user-agent': 'mobile' } }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), { text: 'mobile' }), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), { text: 'mobile' }), body.toString()) sget({ method: 'GET', url: 'http://localhost:' + fastify.server.address().port, headers: { 'user-agent': 'desktop' } }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 200) - t.strictEqual(response.headers['content-length'], '' + body.length) - t.strictEqual(response.headers['content-type'], 'text/html; charset=utf-8') - t.strictEqual(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), { text: 'desktop' }), body.toString()) + t.equal(response.statusCode, 200) + t.equal(response.headers['content-length'], '' + body.length) + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') + t.equal(ejs.render(fs.readFileSync('./templates/index.ejs', 'utf8'), { text: 'desktop' }), body.toString()) fastify.close() }) }) @@ -319,7 +319,7 @@ test('reply.view should return 500 if page is missing', t => { url: 'http://localhost:' + fastify.server.address().port }, (err, response, body) => { t.error(err) - t.strictEqual(response.statusCode, 500) + t.equal(response.statusCode, 500) fastify.close() }) }) @@ -333,7 +333,7 @@ test('register callback should throw if the engine is missing', t => { fastify.ready(err => { t.ok(err instanceof Error) - t.is(err.message, 'Missing engine') + t.equal(err.message, 'Missing engine') }) }) @@ -347,7 +347,7 @@ test('register callback should throw if the engine is not supported', t => { } }).ready(err => { t.ok(err instanceof Error) - t.is(err.message, '\'notSupported\' not yet supported, PR? :)') + t.equal(err.message, '\'notSupported\' not yet supported, PR? :)') }) }) @@ -362,7 +362,7 @@ test('register callback with handlebars engine should throw if layout file does layout: './templates/does-not-exist.hbs' }).ready(err => { t.ok(err instanceof Error) - t.deepEqual('unable to access template "./templates/does-not-exist.hbs"', err.message) + t.same('unable to access template "./templates/does-not-exist.hbs"', err.message) }) }) @@ -377,7 +377,7 @@ test('register callback should throw if layout option provided with wrong engine layout: 'template' }).ready(err => { t.ok(err instanceof Error) - t.is(err.message, 'Only Dot, Handlebars, EJS, and Eta support the "layout" option') + t.equal(err.message, 'Only Dot, Handlebars, EJS, and Eta support the "layout" option') }) })