Version 1
[yaffs-website] / node_modules / phridge / test / disposeAll.test.js
diff --git a/node_modules/phridge/test/disposeAll.test.js b/node_modules/phridge/test/disposeAll.test.js
new file mode 100644 (file)
index 0000000..fd8f5ab
--- /dev/null
@@ -0,0 +1,33 @@
+"use strict";
+
+var chai = require("chai");
+var expect = chai.expect;
+var phridge = require("../lib/main.js");
+var slow = require("./helpers/slow.js");
+
+require("./helpers/setup.js");
+
+describe("disposeAll()", function () {
+
+    it("should exit cleanly all running phantomjs instances", slow(function () {
+        var exited = [];
+
+        return Promise.all([
+            phridge.spawn(),
+            phridge.spawn(),
+            phridge.spawn()
+        ])
+        .then(function (p) {
+            p[0].childProcess.on("exit", function () { exited.push(0); });
+            p[1].childProcess.on("exit", function () { exited.push(1); });
+            p[2].childProcess.on("exit", function () { exited.push(2); });
+
+            return phridge.disposeAll();
+        })
+        .then(function () {
+            exited.sort();
+            expect(exited).to.eql([0, 1, 2]);
+        });
+    }));
+
+});