diff options
author | 1111hui <26634873@qq.com> | 2016-10-29 15:21:28 +0800 |
---|---|---|
committer | Richard van Velzen <rvanvelzen1@gmail.com> | 2016-11-29 20:29:12 +0100 |
commit | 0a35acbbe7e663c643c5b227e455816278e08b89 (patch) | |
tree | 6e1daafa47e2ccc87e973e6a2a95ca62a4003244 /test/mocha | |
parent | 2a9989dd18c01081c486fe9089e3bb64079c773b (diff) | |
download | tracifyjs-0a35acbbe7e663c643c5b227e455816278e08b89.tar.gz tracifyjs-0a35acbbe7e663c643c5b227e455816278e08b89.zip |
feat: add option.outFileName for JS API, if absense, sourceMap.file field will deduced
Diffstat (limited to 'test/mocha')
-rw-r--r-- | test/mocha/minify-file-map.js | 14 | ||||
-rw-r--r-- | test/mocha/minify.js | 3 |
2 files changed, 13 insertions, 4 deletions
diff --git a/test/mocha/minify-file-map.js b/test/mocha/minify-file-map.js index aa42d25a..169e730e 100644 --- a/test/mocha/minify-file-map.js +++ b/test/mocha/minify-file-map.js @@ -7,10 +7,18 @@ describe("Input file as map", function() { '/scripts/foo.js': 'var foo = {"x": 1, y: 2, \'z\': 3};' }; var result = Uglify.minify(jsMap, {fromString: true, outSourceMap: true}); - + var map = JSON.parse(result.map); assert.strictEqual(result.code, 'var foo={x:1,y:2,z:3};'); assert.deepEqual(map.sources, ['/scripts/foo.js']); + assert.strictEqual(map.file, undefined); + + result = Uglify.minify(jsMap, {fromString: true, outFileName: 'out.js'}); + assert.strictEqual(result.map, null); + + result = Uglify.minify(jsMap, {fromString: true, outFileName: 'out.js', outSourceMap: true}); + map = JSON.parse(result.map); + assert.strictEqual(map.file, 'out.js'); }); it("Should accept array of objects and strings", function() { @@ -19,7 +27,7 @@ describe("Input file as map", function() { 'var bar = 15;' ]; var result = Uglify.minify(jsSeq, {fromString: true, outSourceMap: true}); - + var map = JSON.parse(result.map); assert.strictEqual(result.code, 'var foo={x:1,y:2,z:3},bar=15;'); assert.strictEqual(map.sources[0], '/scripts/foo.js'); @@ -31,7 +39,7 @@ describe("Input file as map", function() { 'var bar = 15;' ]; var result = Uglify.minify(jsSeq, {fromString: true, outSourceMap: true, sourceMapIncludeSources: true}); - + var map = JSON.parse(result.map); assert.strictEqual(result.code, 'var foo={x:1,y:2,z:3},bar=15;'); assert.deepEqual(map.sourcesContent, ['var foo = {"x": 1, y: 2, \'z\': 3};', 'var bar = 15;']); diff --git a/test/mocha/minify.js b/test/mocha/minify.js index ce5e8497..70cf73ae 100644 --- a/test/mocha/minify.js +++ b/test/mocha/minify.js @@ -63,13 +63,14 @@ describe("minify", function() { describe("inSourceMap", function() { it("Should read the given string filename correctly when sourceMapIncludeSources is enabled (#1236)", function() { var result = Uglify.minify('./test/input/issue-1236/simple.js', { - outSourceMap: "simple.js.min.map", + outSourceMap: "simple.min.js.map", inSourceMap: "./test/input/issue-1236/simple.js.map", sourceMapIncludeSources: true }); var map = JSON.parse(result.map); + assert.equal(map.file, 'simple.min.js'); assert.equal(map.sourcesContent.length, 1); assert.equal(map.sourcesContent[0], 'let foo = x => "foo " + x;\nconsole.log(foo("bar"));'); |