aboutsummaryrefslogtreecommitdiff
path: root/test/mocha
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-04-06 16:04:15 +0800
committerGitHub <noreply@github.com>2018-04-06 16:04:15 +0800
commit923deeff35b708e49c4d8bcfa64dc53832cd4b5a (patch)
tree838a093941e36f1e4721f69d89300adb07243fb0 /test/mocha
parent0b62a28b476c443638d9894e14e4c29b2748143c (diff)
downloadtracifyjs-923deeff35b708e49c4d8bcfa64dc53832cd4b5a.tar.gz
tracifyjs-923deeff35b708e49c4d8bcfa64dc53832cd4b5a.zip
support inline source map from multiple files (#3058)
fixes #145
Diffstat (limited to 'test/mocha')
-rw-r--r--test/mocha/cli.js21
-rw-r--r--test/mocha/sourcemaps.js41
2 files changed, 43 insertions, 19 deletions
diff --git a/test/mocha/cli.js b/test/mocha/cli.js
index a64cb216..8c858bd9 100644
--- a/test/mocha/cli.js
+++ b/test/mocha/cli.js
@@ -244,16 +244,27 @@ describe("bin/uglifyjs", function () {
"//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QvaW5wdXQvaXNzdWUtMTMyMy9zYW1wbGUuanMiXSwibmFtZXMiOlsiYmFyIiwiZm9vIl0sIm1hcHBpbmdzIjoiQUFBQSxJQUFJQSxJQUFNLFdBQ04sU0FBU0MsSUFBS0QsS0FDVixPQUFPQSxJQUdYLE9BQU9DLElBTEQifQ==",
"",
].join("\n"));
- assert.strictEqual(stderr, "WARN: inline source map not found\n");
+ assert.strictEqual(stderr, "WARN: inline source map not found: test/input/issue-1323/sample.js\n");
done();
});
});
- it("Should fail with multiple input and inline source map", function(done) {
- var command = uglifyjscmd + " test/input/issue-520/input.js test/input/issue-520/output.js --source-map content=inline,url=inline";
+ it("Should handle multiple input and inline source map", function(done) {
+ var command = [
+ uglifyjscmd,
+ "test/input/issue-520/input.js",
+ "test/input/issue-1323/sample.js",
+ "--source-map", "content=inline,url=inline",
+ ].join(" ");
exec(command, function (err, stdout, stderr) {
- assert.ok(err);
- assert.strictEqual(stderr.split(/\n/)[0], "ERROR: inline source map only works with singular input");
+ if (err) throw err;
+
+ assert.strictEqual(stdout, [
+ "var Foo=function Foo(){console.log(1+2)};new Foo;var bar=function(){function foo(bar){return bar}return foo}();",
+ "//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0ZGluIiwidGVzdC9pbnB1dC9pc3N1ZS0xMzIzL3NhbXBsZS5qcyJdLCJuYW1lcyI6WyJGb28iLCJjb25zb2xlIiwibG9nIiwiYmFyIiwiZm9vIl0sIm1hcHBpbmdzIjoiQUFBQSxJQUFNQSxJQUFJLFNBQUFBLE1BQWdCQyxRQUFRQyxJQUFJLEVBQUUsSUFBTyxJQUFJRixJQ0FuRCxJQUFJRyxJQUFNLFdBQ04sU0FBU0MsSUFBS0QsS0FDVixPQUFPQSxJQUdYLE9BQU9DLElBTEQifQ==",
+ "",
+ ].join("\n"));
+ assert.strictEqual(stderr, "WARN: inline source map not found: test/input/issue-1323/sample.js\n");
done();
});
});
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"), {