add tests about sourceMapInline
This commit is contained in:
parent
d7eaa95949
commit
c7271e4157
7
test/input/issue-1323/sample.js
Normal file
7
test/input/issue-1323/sample.js
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
var bar = (function () {
|
||||||
|
function foo (bar) {
|
||||||
|
return bar;
|
||||||
|
}
|
||||||
|
|
||||||
|
return foo;
|
||||||
|
})();
|
||||||
|
|
@ -49,4 +49,29 @@ describe("bin/uglifyjs", function () {
|
||||||
done();
|
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.doesNotThrow(function (){
|
||||||
|
var validate_source_map = /\/\/# sourceMappingURL=data:.*base64,(.*)\s*$/;
|
||||||
|
var base64 = stdout.match(validate_source_map)[1];
|
||||||
|
|
||||||
|
var buf = new Buffer(base64, 'base64');
|
||||||
|
var map = JSON.parse(buf.toString());
|
||||||
|
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) {
|
||||||
|
var validate_source_map = /\/\/# sourceMappingURL=data:.*base64,(.*)\s*$/;
|
||||||
|
assert.strictEqual(false, validate_source_map.test(stdout));
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -75,4 +75,31 @@ describe("minify", function() {
|
||||||
'let foo = x => "foo " + x;\nconsole.log(foo("bar"));');
|
'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.doesNotThrow(function() {
|
||||||
|
var validate_source_map = /\/\/# sourceMappingURL=data:.*base64,(.*)\s*$/;
|
||||||
|
var base64 = code.match(validate_source_map)[1];
|
||||||
|
|
||||||
|
var buf = new Buffer(base64, 'base64');
|
||||||
|
var map = JSON.parse(buf.toString());
|
||||||
|
})
|
||||||
|
});
|
||||||
|
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;
|
||||||
|
var validate_source_map = /\/\/# sourceMappingURL=data:.*base64,(.*)\s*$/;
|
||||||
|
assert.strictEqual(false, validate_source_map.test(code));
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user