diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-04-06 16:04:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-06 16:04:15 +0800 |
commit | 923deeff35b708e49c4d8bcfa64dc53832cd4b5a (patch) | |
tree | 838a093941e36f1e4721f69d89300adb07243fb0 /test/mocha/sourcemaps.js | |
parent | 0b62a28b476c443638d9894e14e4c29b2748143c (diff) | |
download | tracifyjs-923deeff35b708e49c4d8bcfa64dc53832cd4b5a.tar.gz tracifyjs-923deeff35b708e49c4d8bcfa64dc53832cd4b5a.zip |
support inline source map from multiple files (#3058)
fixes #145
Diffstat (limited to 'test/mocha/sourcemaps.js')
-rw-r--r-- | test/mocha/sourcemaps.js | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/test/mocha/sourcemaps.js b/test/mocha/sourcemaps.js index 8868c5ae..2f178b27 100644 --- a/test/mocha/sourcemaps.js +++ b/test/mocha/sourcemaps.js @@ -91,24 +91,37 @@ describe("sourcemaps", function() { }); assert.strictEqual(result.code, "var bar=function(bar){return bar};"); assert.strictEqual(warnings.length, 1); - assert.strictEqual(warnings[0], "inline source map not found"); + assert.strictEqual(warnings[0], "inline source map not found: 0"); } finally { Uglify.AST_Node.warn_function = warn_function; } }); - it("Should fail with multiple input and inline source map", function() { - var result = Uglify.minify([ - read("./test/input/issue-520/input.js"), - read("./test/input/issue-520/output.js") - ], { - sourceMap: { - content: "inline", - url: "inline" - } - }); - var err = result.error; - assert.ok(err instanceof Error); - assert.strictEqual(err.stack.split(/\n/)[0], "Error: inline source map only works with singular input"); + it("Should handle multiple input and inline source map", function() { + var warn_function = Uglify.AST_Node.warn_function; + var warnings = []; + Uglify.AST_Node.warn_function = function(txt) { + warnings.push(txt); + }; + try { + var result = Uglify.minify([ + read("./test/input/issue-520/input.js"), + read("./test/input/issue-1323/sample.js"), + ], { + sourceMap: { + content: "inline", + url: "inline", + } + }); + if (result.error) throw result.error; + assert.strictEqual(result.code, [ + "var Foo=function(){console.log(3)};new Foo;var bar=function(o){return o};", + "//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0ZGluIiwiMSJdLCJuYW1lcyI6WyJGb28iLCJjb25zb2xlIiwibG9nIiwiYmFyIl0sIm1hcHBpbmdzIjoiQUFBQSxJQUFNQSxJQUFJLFdBQWdCQyxRQUFRQyxJQUFJLElBQVMsSUFBSUYsSUNBbkQsSUFBSUcsSUFDQSxTQUFjQSxHQUNWLE9BQU9BIn0=", + ].join("\n")); + assert.strictEqual(warnings.length, 1); + assert.strictEqual(warnings[0], "inline source map not found: 1"); + } finally { + Uglify.AST_Node.warn_function = warn_function; + } }); it("Should drop source contents for includeSources=false", function() { var result = Uglify.minify(read("./test/input/issue-520/input.js"), { |