Skip to content

Commit

Permalink
chore tap 15 (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eomm authored Apr 10, 2021
1 parent ce42790 commit f218d2e
Show file tree
Hide file tree
Showing 18 changed files with 713 additions and 739 deletions.
4 changes: 2 additions & 2 deletions .taprc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
esm: false
ts: false
jsx: false
flow: false
coverage: true
nyc-arg: [--exclude=out]
nyc-arg: [--exclude=out]
check-coverage: false
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
26 changes: 0 additions & 26 deletions tap-snapshots/test-with-snapshot.js-TAP.test.js

This file was deleted.

50 changes: 25 additions & 25 deletions test/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
})
Expand Down Expand Up @@ -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()
})
})
Expand Down Expand Up @@ -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()
})
})
Expand Down Expand Up @@ -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()
})
Expand Down Expand Up @@ -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()
})
})
Expand Down Expand Up @@ -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()
})
})
Expand Down Expand Up @@ -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()
})
Expand Down
92 changes: 46 additions & 46 deletions test/test-art-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
})
Expand Down Expand Up @@ -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()
})
})
Expand Down Expand Up @@ -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()
})
})
Expand Down Expand Up @@ -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()
})
})
Expand Down Expand Up @@ -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()
})
})
Expand Down Expand Up @@ -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()
})
})
Expand Down Expand Up @@ -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()
})
})
Expand Down Expand Up @@ -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()
})
})
Expand Down Expand Up @@ -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()
})
})
Expand Down Expand Up @@ -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()
})
})
Expand Down Expand Up @@ -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()
})
})
Expand All @@ -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()
})
})
Expand Down Expand Up @@ -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()
})
Expand Down
Loading

0 comments on commit f218d2e

Please sign in to comment.