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