diff options
Diffstat (limited to 'node_modules/express-minify-html/tests')
| -rw-r--r-- | node_modules/express-minify-html/tests/index.js | 79 | ||||
| -rw-r--r-- | node_modules/express-minify-html/tests/test.ejs | 20 | ||||
| -rw-r--r-- | node_modules/express-minify-html/tests/test.handlebars | 20 | ||||
| -rw-r--r-- | node_modules/express-minify-html/tests/test.nunjucks | 20 | ||||
| -rw-r--r-- | node_modules/express-minify-html/tests/test.output.html | 1 | ||||
| -rw-r--r-- | node_modules/express-minify-html/tests/test.pug | 13 |
6 files changed, 153 insertions, 0 deletions
diff --git a/node_modules/express-minify-html/tests/index.js b/node_modules/express-minify-html/tests/index.js new file mode 100644 index 0000000..26a20d7 --- /dev/null +++ b/node_modules/express-minify-html/tests/index.js @@ -0,0 +1,79 @@ +'use strict'; + +var express = require('express'); +var request = require('supertest'); +var test = require('tape'); +var fs = require('fs'); + +var minifyHTML = require('../minifier.js'); +var expectedHTML = fs.readFileSync(__dirname + '/test.output.html', 'utf8'); + +var exhbs = require('express-handlebars'); +var hbs = exhbs.create({ + defaultLayout: 'test', + layoutsDir: __dirname +}); + +var nunjucks = require('nunjucks'); +nunjucks.configure(__dirname, { + autoescape: true, + express: app +}); + +var app = express(); + +app.engine('handlebars', hbs.engine); +app.engine('nunjucks', nunjucks.render); + +app.set('views', __dirname); + +app.use(minifyHTML({ + override: true, + htmlMinifier: { + removeComments: true, + collapseWhitespace: true, + collapseBooleanAttributes: true, + removeAttributeQuotes: true, + removeEmptyAttributes: true, + minifyJS: true + } +})); + +app.get('/test', function (req, res, next) { + res.render('test', { hello : 'world' }); +}); + +function checkMinified(t) { + request(app) + .get('/test') + .expect(200) + .end(function (err, res) { + t.equal(res.text, expectedHTML); + t.end(); + }); +}; + +test('Should minify EJS templates', function (t) { + app.set('view engine', 'ejs'); + + checkMinified(t); +}); + +test('Should minify Pug templates', function (t) { + app.set('view engine', 'pug'); + + checkMinified(t); +}); + +test('Should minify Handlebars templates', function (t) { + app.set('view engine', 'handlebars'); + + checkMinified(t); +}); + +test('Should minify Nunjucks templates', function (t) { + app.set('view engine', 'nunjucks'); + + checkMinified(t); +}); + diff --git a/node_modules/express-minify-html/tests/test.ejs b/node_modules/express-minify-html/tests/test.ejs new file mode 100644 index 0000000..8dcc92c --- /dev/null +++ b/node_modules/express-minify-html/tests/test.ejs @@ -0,0 +1,20 @@ +<!DOCTYPE html> +<html> +<!-- This unnecessary HTML comment should probably be removed! --> + <head class="head"> + <meta charset="UTF-8"> + <title>Express minify HTML test</title> + </head> + <body id="body"> + Hello <%= hello %> + </body> + <script type="text/javascript"> + function reallyNiceFunction () { + + + return "Hello!"; + + + }; + </script> +</html> diff --git a/node_modules/express-minify-html/tests/test.handlebars b/node_modules/express-minify-html/tests/test.handlebars new file mode 100644 index 0000000..13ec12e --- /dev/null +++ b/node_modules/express-minify-html/tests/test.handlebars @@ -0,0 +1,20 @@ +<!DOCTYPE html> +<html> +<!-- This unnecessary HTML comment should probably be removed! --> + <head class="head"> + <meta charset="UTF-8"> + <title>Express minify HTML test</title> + </head> + <body id="body"> + Hello {{hello}} + </body> + <script type="text/javascript"> + function reallyNiceFunction () { + + + return "Hello!"; + + + }; + </script> +</html> diff --git a/node_modules/express-minify-html/tests/test.nunjucks b/node_modules/express-minify-html/tests/test.nunjucks new file mode 100644 index 0000000..1920920 --- /dev/null +++ b/node_modules/express-minify-html/tests/test.nunjucks @@ -0,0 +1,20 @@ +<!DOCTYPE html> +<html> +<!-- This unnecessary HTML comment should probably be removed! --> + <head class="head"> + <meta charset="UTF-8"> + <title>Express minify HTML test</title> + </head> + <body id="body"> + Hello {{ hello }} + </body> + <script type="text/javascript"> + function reallyNiceFunction () { + + + return "Hello!"; + + + }; + </script> +</html> diff --git a/node_modules/express-minify-html/tests/test.output.html b/node_modules/express-minify-html/tests/test.output.html new file mode 100644 index 0000000..5fe51af --- /dev/null +++ b/node_modules/express-minify-html/tests/test.output.html @@ -0,0 +1 @@ +<!DOCTYPE html><html><head class=head><meta charset=UTF-8><title>Express minify HTML test</title></head><body id=body>Hello world</body><script type=text/javascript>function reallyNiceFunction(){return"Hello!"}</script></html>
\ No newline at end of file diff --git a/node_modules/express-minify-html/tests/test.pug b/node_modules/express-minify-html/tests/test.pug new file mode 100644 index 0000000..169a517 --- /dev/null +++ b/node_modules/express-minify-html/tests/test.pug @@ -0,0 +1,13 @@ +doctype html +html + // This unnecessary HTML comment should probably be removed! + head.head + meta(charset='UTF-8') + title Express minify HTML test + body#body + | Hello #{hello} + script(type='text/javascript'). + function reallyNiceFunction () { + return "Hello!"; + }; + |
