bug fixes that came up during testing

This commit is contained in:
Brian Mulhall
2020-04-04 13:42:42 -05:00
parent 602f809665
commit c53844b3d4
2 changed files with 8 additions and 19 deletions

View File

@@ -1,25 +1,14 @@
// this test case verifies that terser can minify code we give it
Tinytest.add('minifier-js - verify simple JS minifications work', (test) => {
let terserResult = meteorJsMinify('function add(first,second){return first + second; }\n');
test.equal(terserResult.code, 'function add(n,d){return n+d}');
test.equal(terserResult.minifier, 'terser');
test.equal(terserResult.code, 'function add(n,d){return n+d}');
});
// this test case verifies that when terser can't handle something, babel-minify will step in as a fallback
Tinytest.add('minifier-js - syntax terser cannot handle is handled correctly by babel-minify', (test) => {
let babelResult = meteorJsMinify('let number = 1_000_000_000_000;\n');
test.equal(babelResult.code, 'let number=1e12;');
test.equal(babelResult.minifier, 'babel-minify');
// this feature has been reqested in this issue https://github.com/terser/terser/issues/632
// so when we bump the version and this fails we will know when :)
Tinytest.add('minifier-js - numeric seperator test', (test) => {
test.throws(() => meteorJsMinify('let number = 1_000_000_000_000;\n') );
});
// This test case verifies the behavior when both terser and babel-minfiy fail
Tinytest.add('minifier-js - errors are handled correctly', (test) => {
Tinytest.add('minifier-js - verify error handling is done correctly', (test) => {
test.throws(() => meteorJsMinify('let name = {;\n'));
});

View File

@@ -1,6 +1,6 @@
const terser = Npm.require("terser");
meteorJsMinify = function (source) {
meteorJsMinify = function (source) {
const NODE_ENV = process.env.NODE_ENV || "development";
const terserOptions = {
@@ -23,5 +23,5 @@ meteorJsMinify = function (source) {
// the terser api doesnt throw exceptions, so we throw one ourselves
if (terserResult.error) throw terserResult.error;
return terserResult.code;
return terserResult;
};