use exact string matches to test output
This commit is contained in:
parent
c7271e4157
commit
13990aed90
|
|
@ -55,22 +55,18 @@ describe("bin/uglifyjs", function () {
|
||||||
exec(command, function (err, stdout) {
|
exec(command, function (err, stdout) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
|
|
||||||
assert.doesNotThrow(function (){
|
assert.strictEqual(stdout, "var bar=function(){function foo(bar){return bar}return foo}();\n" +
|
||||||
var validate_source_map = /\/\/# sourceMappingURL=data:.*base64,(.*)\s*$/;
|
"//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QvaW5wdXQvaXNzdWUtMTMyMy9zYW1wbGUuanMiXSwibmFtZXMiOlsiYmFyIiwiZm9vIl0sIm1hcHBpbmdzIjoiQUFBQSxHQUFJQSxLQUFNLFdBQ04sUUFBU0MsS0FBS0QsS0FDVixNQUFPQSxLQUdYLE1BQU9DIn0=\n");
|
||||||
var base64 = stdout.match(validate_source_map)[1];
|
|
||||||
|
|
||||||
var buf = new Buffer(base64, 'base64');
|
|
||||||
var map = JSON.parse(buf.toString());
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
it("should not append source map to output when not using --source-map-inline", function (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';
|
var command = uglifyjscmd + ' test/input/issue-1323/sample.js';
|
||||||
|
|
||||||
exec(command, function (err, stdout) {
|
exec(command, function (err, stdout) {
|
||||||
var validate_source_map = /\/\/# sourceMappingURL=data:.*base64,(.*)\s*$/;
|
if (err) throw err;
|
||||||
assert.strictEqual(false, validate_source_map.test(stdout));
|
|
||||||
|
assert.strictEqual(stdout, "var bar=function(){function foo(bar){return bar}return foo}();\n");
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -83,23 +83,15 @@ describe("minify", function() {
|
||||||
sourceMapInline: true
|
sourceMapInline: true
|
||||||
});
|
});
|
||||||
var code = result.code;
|
var code = result.code;
|
||||||
|
assert.strictEqual(code, "var a=function(n){return n};\n" +
|
||||||
assert.doesNotThrow(function() {
|
"//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIj8iXSwibmFtZXMiOlsiYSIsImZvbyJdLCJtYXBwaW5ncyI6IkFBQUEsR0FBSUEsR0FBSSxTQUFTQyxHQUFPLE1BQU9BIn0=");
|
||||||
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() {
|
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; };', {
|
var result = Uglify.minify('var a = function(foo) { return foo; };', {
|
||||||
fromString: true
|
fromString: true
|
||||||
});
|
});
|
||||||
|
|
||||||
var code = result.code;
|
var code = result.code;
|
||||||
var validate_source_map = /\/\/# sourceMappingURL=data:.*base64,(.*)\s*$/;
|
assert.strictEqual(code, "var a=function(n){return n};");
|
||||||
assert.strictEqual(false, validate_source_map.test(code));
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user