bootstrap.js
1.72 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
var expect = require('expect.js');
var spawnChild = require('../util/spawn');
describe('the PhantomJS bootstrap script', function () {
it('hooks phantom.onError to emit an error event and exit non-zero',
function (done) {
var child = spawnChild({
spooky_lib: 'invalid'
});
// expect child to exit non-zero
var exited = false;
child.on('exit', function (code) {
expect(code).not.to.be(0);
exited = true;
if (emitted) {
done();
}
});
// expect child to emit an error event
var emitted = false;
child.stdout.once('line', function (line) {
var message = JSON.parse(line);
expect(message.params[0]).to.be('error');
emitted = true;
if (exited) {
done();
}
});
});
it('crashes if passed an unknown transport', function (done) {
var child = spawnChild({
transport: 'invalid'
});
// expect child to exit non-zero
var exited = false;
child.on('exit', function (code) {
expect(code).not.to.be(0);
exited = true;
if (emitted) {
done();
}
});
// expect child to emit an error event
var emitted = false;
child.stdout.once('line', function (line) {
var message = JSON.parse(line);
expect(message.params[0]).to.be('error');
emitted = true;
if (exited) {
done();
}
});
});
});