Skip to content

Commit 8f8007b

Browse files
committed
test: add test for error throwing when trying to compress non-ES5 syntax
1 parent 029107b commit 8f8007b

File tree

5 files changed

+34
-6
lines changed

5 files changed

+34
-6
lines changed

index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ function gulpInlineSource (options) {
2222
}
2323

2424
var fileOptions = {
25-
rootpath: path.dirname(file.path),
26-
htmlpath: file.path
25+
rootpath: path.dirname(file.path),
26+
htmlpath: file.path
2727
};
2828

2929
if (options) {
30-
for (var i in options) {
31-
fileOptions[i] = options[i];
32-
}
30+
for (var i in options) {
31+
fileOptions[i] = options[i];
32+
}
3333
}
3434

3535
inlineSource(file.contents.toString(), fileOptions, function (err, html) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
"dependencies": {
2222
"gulp-util": "~3.0.6",
23-
"inline-source": "~5.2.1",
23+
"inline-source": "~5.2.6",
2424
"through2": "~2.0.0"
2525
},
2626
"main": "index.js",

test/fixtures/script-es6.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<html>
2+
<head>
3+
<script src="script-es6.js" inline></script>
4+
</head>
5+
<body>
6+
</body>
7+
</html>

test/fixtures/script-es6.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
function test() {
2+
const foo = `lorem ipsum`;
3+
return foo;
4+
}

test/main.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,20 @@ test('inlines assets without minification', function (t) {
6666

6767
compare(stream, 'nominify.html', 'inlined-nominify.html', t);
6868
});
69+
70+
test('throws when trying to compress non-ES5 syntax', function (t) {
71+
t.plan(1);
72+
73+
var stream = inlinesource({ compress: true });
74+
75+
stream.on('error', function (err) {
76+
t.pass();
77+
});
78+
79+
stream.on('finish', function () {
80+
t.end();
81+
});
82+
83+
stream.write(getFixture('script-es6.html'));
84+
stream.end();
85+
});

0 commit comments

Comments
 (0)