fd8f5ab48e7f9b104ce0bfe10d8f02cf3eb22a6c
[yaffs-website] / node_modules / phridge / test / disposeAll.test.js
1 "use strict";
2
3 var chai = require("chai");
4 var expect = chai.expect;
5 var phridge = require("../lib/main.js");
6 var slow = require("./helpers/slow.js");
7
8 require("./helpers/setup.js");
9
10 describe("disposeAll()", function () {
11
12     it("should exit cleanly all running phantomjs instances", slow(function () {
13         var exited = [];
14
15         return Promise.all([
16             phridge.spawn(),
17             phridge.spawn(),
18             phridge.spawn()
19         ])
20         .then(function (p) {
21             p[0].childProcess.on("exit", function () { exited.push(0); });
22             p[1].childProcess.on("exit", function () { exited.push(1); });
23             p[2].childProcess.on("exit", function () { exited.push(2); });
24
25             return phridge.disposeAll();
26         })
27         .then(function () {
28             exited.sort();
29             expect(exited).to.eql([0, 1, 2]);
30         });
31     }));
32
33 });