aboutsummaryrefslogtreecommitdiff
path: root/test/mocha/bug-report.js
blob: 480850df943d0ce98d2db7e783be4f46c91f7cc3 (about) (plain)
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
var assert = require("assert");
var exec = require("child_process").exec;

describe("UGLIFY_BUG_REPORT", function() {
    var env = Object.create(process.env);
    env.UGLIFY_BUG_REPORT = 1;
    it("Should generate bug report via API", function(done) {
        exec('"' + process.argv[0] + '"', { env: env }, function(err, stdout) {
            if (err) throw err;
            assert.strictEqual(stdout, [
                "// UGLIFY_BUG_REPORT",
                "// <<undefined>>",
                "",
                "//-------------------------------------------------------------",
                "// INPUT CODE",
                "...---...",
                "",
            ].join("\n"));
            done();
        }).stdin.end('console.log(require("./").minify("...---...").code);');
    });
    it("Should generate bug report via CLI", function(done) {
        exec('"' + process.argv[0] + '" bin/uglifyjs -mc', { env: env }, function(err, stdout) {
            if (err) throw err;
            assert.strictEqual(stdout, [
                "// UGLIFY_BUG_REPORT",
                "// {",
                '//   "mangle": {},',
                '//   "compress": {}',
                "// }",
                "",
                "//-------------------------------------------------------------",
                "// STDIN",
                "...---...",
                "",
            ].join("\n"));
            done();
        }).stdin.end("...---...");
    });
});