|
1 | | -it("should contain no comments in out chunk", function() { |
2 | | - var fs = require("fs"); |
3 | | - var source = fs.readFileSync(__filename, "utf-8"); |
| 1 | +it("should contain no comments in out chunk", () => { |
| 2 | + const fs = require("fs"); |
| 3 | + |
| 4 | + const source = fs.readFileSync(__filename, "utf-8"); |
| 5 | + |
4 | 6 | source.should.not.match(/[^\"]comment should be stripped test\.1[^\"]/); |
5 | 7 | source.should.not.match(/[^\"]comment should be stripped test\.2[^\"]/); |
6 | 8 | source.should.not.match(/[^\"]comment should be stripped test\.3[^\"]/); |
7 | 9 | }); |
8 | 10 |
|
9 | 11 | it("should contain comments in vendors chunk", function() { |
10 | | - var fs = require("fs"), |
11 | | - path = require("path"); |
12 | | - var source = fs.readFileSync(path.join(__dirname, "vendors.js"), "utf-8"); |
| 12 | + const fs = require("fs"); |
| 13 | + const path = require("path"); |
| 14 | + |
| 15 | + const source = fs.readFileSync(path.join(__dirname, "vendors.js"), "utf-8"); |
| 16 | + |
13 | 17 | source.should.containEql("comment should not be stripped vendors.1"); |
14 | 18 | source.should.containEql("// comment should not be stripped vendors.2"); |
15 | 19 | source.should.containEql(" * comment should not be stripped vendors.3"); |
16 | 20 | }); |
17 | 21 |
|
18 | | -// this test is based off https://github.com/mishoo/UglifyJS2/blob/master/test/compress/screw-ie8.js |
19 | | -it("should pass mangle options", function() { |
20 | | - var fs = require("fs"), |
21 | | - path = require("path"); |
22 | | - var source = fs.readFileSync(path.join(__dirname, "ie8.js"), "utf-8"); |
23 | | - source.should.containEql("function r(t){return function(n){try{t()}catch(t){n(t)}}}"); |
24 | | -}); |
25 | | - |
26 | 22 | it("should extract comments to separate file", function() { |
27 | | - var fs = require("fs"), |
28 | | - path = require("path"); |
29 | | - var source = fs.readFileSync(path.join(__dirname, "extract.js.LICENSE"), "utf-8"); |
| 23 | + const fs = require("fs"); |
| 24 | + const path = require("path"); |
| 25 | + |
| 26 | + const source = fs.readFileSync(path.join(__dirname, "extract.js.LICENSE"), "utf-8"); |
| 27 | + |
30 | 28 | source.should.containEql("comment should be extracted extract-test.1"); |
31 | 29 | source.should.not.containEql("comment should be stripped extract-test.2"); |
32 | 30 | source.should.containEql("comment should be extracted extract-test.3"); |
33 | 31 | source.should.not.containEql("comment should be stripped extract-test.4"); |
34 | 32 | }); |
35 | 33 |
|
36 | 34 | it("should remove extracted comments and insert a banner", function() { |
37 | | - var fs = require("fs"), |
38 | | - path = require("path"); |
39 | | - var source = fs.readFileSync(path.join(__dirname, "extract.js"), "utf-8"); |
| 35 | + const fs = require("fs"); |
| 36 | + const path = require("path"); |
| 37 | + |
| 38 | + const source = fs.readFileSync(path.join(__dirname, "extract.js"), "utf-8"); |
| 39 | + |
40 | 40 | source.should.not.containEql("comment should be extracted extract-test.1"); |
41 | 41 | source.should.not.containEql("comment should be stripped extract-test.2"); |
42 | 42 | source.should.not.containEql("comment should be extracted extract-test.3"); |
43 | 43 | source.should.not.containEql("comment should be stripped extract-test.4"); |
44 | 44 | source.should.containEql("/*! For license information please see extract.js.LICENSE */"); |
45 | 45 | }); |
46 | 46 |
|
| 47 | +it("should pass mangle options", function() { |
| 48 | + const fs = require("fs"); |
| 49 | + const path = require("path"); |
| 50 | + |
| 51 | + const source = fs.readFileSync(path.join(__dirname, "ie8.js"), "utf-8"); |
| 52 | + |
| 53 | + source.should.containEql("t.exports=function(t){return function(n){try{t()}catch(t){n(t)}}}"); |
| 54 | +}); |
| 55 | + |
47 | 56 | it("should pass compress options", function() { |
48 | | - var fs = require("fs"), |
49 | | - path = require("path"); |
50 | | - var source = fs.readFileSync(path.join(__dirname, "compress.js"), "utf-8"); |
51 | | - source.should.containEql("function e(){var o=2;o=3,console.log(1+o),console.log(o+3),console.log(4),console.log(1+o+3)}"); |
| 57 | + const fs = require("fs"); |
| 58 | + const path = require("path"); |
| 59 | + |
| 60 | + const source = fs.readFileSync(path.join(__dirname, "compress.js"), "utf-8"); |
| 61 | + |
| 62 | + source.should.containEql("o.exports=function(){console.log(4),console.log(6),console.log(4),console.log(7)}"); |
52 | 63 | }); |
53 | 64 |
|
54 | 65 | require.include("./test.js"); |
0 commit comments