aboutsummaryrefslogtreecommitdiff
path: root/node_modules/express-minify-html/tests/index.js
diff options
context:
space:
mode:
authornanalelfe <nargiza.nosirova@mail.utoronto.ca>2016-07-27 00:03:35 +0000
committernanalelfe <nargiza.nosirova@mail.utoronto.ca>2016-07-27 00:03:35 +0000
commit8beb37ed67b5f2fa0f9aa85499a8f11b39c9d067 (patch)
treebd4b05a1e374b6cb10097bbcfbc12ef51c1cb85b /node_modules/express-minify-html/tests/index.js
parent5e73fe37c32faf821d3d16f0251007e366cb090b (diff)
need pull
Diffstat (limited to 'node_modules/express-minify-html/tests/index.js')
-rw-r--r--node_modules/express-minify-html/tests/index.js79
1 files changed, 79 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);
+});
+