Introduce a test that tests the --self build
authorRichard van Velzen <rvanvelzen@experty.com>
Mon, 20 Jun 2016 14:57:40 +0000 (16:57 +0200)
committerRichard van Velzen <rvanvelzen@experty.com>
Fri, 1 Jul 2016 07:46:05 +0000 (09:46 +0200)
test/mocha/cli.js [new file with mode: 0644]

diff --git a/test/mocha/cli.js b/test/mocha/cli.js
new file mode 100644 (file)
index 0000000..38b57cd
--- /dev/null
@@ -0,0 +1,22 @@
+var assert = require("assert");
+var exec = require("child_process").exec;
+
+describe("bin/uglifyjs", function () {
+    it("should produce a functional build when using --self", function (done) {
+        this.timeout(5000);
+
+        var uglifyjs = '"' + process.argv[0] + '" bin/uglifyjs';
+        var command = uglifyjs + ' --self -cm --wrap WrappedUglifyJS';
+
+        exec(command, function (err, stdout) {
+            if (err) throw err;
+
+            eval(stdout);
+
+            assert.strictEqual(typeof WrappedUglifyJS, 'object');
+            assert.strictEqual(true, WrappedUglifyJS.parse('foo;') instanceof WrappedUglifyJS.AST_Node);
+
+            done();
+        });
+    });
+});