-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
/
index.js
54 lines (48 loc) · 2.51 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
it("should contain no comments in out chunk", function() {
var fs = require("fs");
var source = fs.readFileSync(__filename, "utf-8");
source.should.not.match(/[^\"]comment should be stripped test\.1[^\"]/);
source.should.not.match(/[^\"]comment should be stripped test\.2[^\"]/);
source.should.not.match(/[^\"]comment should be stripped test\.3[^\"]/);
});
it("should contain comments in vendors chunk", function() {
var fs = require("fs"),
path = require("path");
var source = fs.readFileSync(path.join(__dirname, "vendors.js"), "utf-8");
source.should.containEql("comment should not be stripped vendors.1");
source.should.containEql("// comment should not be stripped vendors.2");
source.should.containEql(" * comment should not be stripped vendors.3");
});
// this test is based off https://github.com/mishoo/UglifyJS2/blob/master/test/compress/screw-ie8.js
it("should pass mangle options", function() {
var fs = require("fs"),
path = require("path");
var source = fs.readFileSync(path.join(__dirname, "ie8.js"), "utf-8");
source.should.containEql("function r(n){return function(t){try{n()}catch(n){t(n)}}}");
});
it("should extract comments to separate file", function() {
var fs = require("fs"),
path = require("path");
var source = fs.readFileSync(path.join(__dirname, "extract.js.LICENSE"), "utf-8");
source.should.containEql("comment should be extracted extract-test.1");
source.should.not.containEql("comment should be stripped extract-test.2");
source.should.containEql("comment should be extracted extract-test.3");
source.should.not.containEql("comment should be stripped extract-test.4");
});
it("should remove extracted comments and insert a banner", function() {
var fs = require("fs"),
path = require("path");
var source = fs.readFileSync(path.join(__dirname, "extract.js"), "utf-8");
source.should.not.containEql("comment should be extracted extract-test.1");
source.should.not.containEql("comment should be stripped extract-test.2");
source.should.not.containEql("comment should be extracted extract-test.3");
source.should.not.containEql("comment should be stripped extract-test.4");
source.should.containEql("/*! For license information please see extract.js.LICENSE */");
});
it("should pass compress options", function() {
var fs = require("fs"),
path = require("path");
var source = fs.readFileSync(path.join(__dirname, "compress.js"), "utf-8");
source.should.containEql("function e(){var n=2;n=3,console.log(1+n),console.log(n+3),console.log(4),console.log(1+n+3)}");
});
require.include("./test.js");