diff options
Diffstat (limited to 'test/mocha')
-rw-r--r-- | test/mocha/cli.js | 21 | ||||
-rw-r--r-- | test/mocha/minify.js | 19 |
2 files changed, 40 insertions, 0 deletions
diff --git a/test/mocha/cli.js b/test/mocha/cli.js index 495b0076..bebd4d9d 100644 --- a/test/mocha/cli.js +++ b/test/mocha/cli.js @@ -49,4 +49,25 @@ describe("bin/uglifyjs", function () { done(); }); }); + it("Should append source map to output when using --source-map-inline", function (done) { + var command = uglifyjscmd + ' test/input/issue-1323/sample.js --source-map-inline'; + + exec(command, function (err, stdout) { + if (err) throw err; + + assert.strictEqual(stdout, "var bar=function(){function foo(bar){return bar}return foo}();\n" + + "//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QvaW5wdXQvaXNzdWUtMTMyMy9zYW1wbGUuanMiXSwibmFtZXMiOlsiYmFyIiwiZm9vIl0sIm1hcHBpbmdzIjoiQUFBQSxHQUFJQSxLQUFNLFdBQ04sUUFBU0MsS0FBS0QsS0FDVixNQUFPQSxLQUdYLE1BQU9DIn0=\n"); + done(); + }); + }); + it("should not append source map to output when not using --source-map-inline", function (done) { + var command = uglifyjscmd + ' test/input/issue-1323/sample.js'; + + exec(command, function (err, stdout) { + if (err) throw err; + + assert.strictEqual(stdout, "var bar=function(){function foo(bar){return bar}return foo}();\n"); + done(); + }); + }); }); diff --git a/test/mocha/minify.js b/test/mocha/minify.js index 2adbadcb..ce5e8497 100644 --- a/test/mocha/minify.js +++ b/test/mocha/minify.js @@ -75,4 +75,23 @@ describe("minify", function() { 'let foo = x => "foo " + x;\nconsole.log(foo("bar"));'); }); }); + + describe("sourceMapInline", function() { + it("should append source map to output js when sourceMapInline is enabled", function() { + var result = Uglify.minify('var a = function(foo) { return foo; };', { + fromString: true, + sourceMapInline: true + }); + var code = result.code; + assert.strictEqual(code, "var a=function(n){return n};\n" + + "//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIj8iXSwibmFtZXMiOlsiYSIsImZvbyJdLCJtYXBwaW5ncyI6IkFBQUEsR0FBSUEsR0FBSSxTQUFTQyxHQUFPLE1BQU9BIn0="); + }); + it("should not append source map to output js when sourceMapInline is not enabled", function() { + var result = Uglify.minify('var a = function(foo) { return foo; };', { + fromString: true + }); + var code = result.code; + assert.strictEqual(code, "var a=function(n){return n};"); + }); + }); }); |