forked from nwjs/nw.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmocha_test.js
51 lines (38 loc) · 996 Bytes
/
mocha_test.js
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
var path = require('path');
var assert = require('assert');
var fs = require('fs-extra');
var curDir = fs.realpathSync('.');
describe('new-instance', function() {
var server, child, result = false;
before(function(done) {
server = createTCPServer(13013);
done();
});
after(function () {
server.close();
});
it('new window has different pid', function(done) {
this.timeout(0);
var result = false;
var times = 0;
var pid1, pid2;
child = spawnChildProcess(path.join(curDir, 'internal'));
server.on('connection', function(socket) {
socket.setEncoding('utf8');
socket.on('data', function(data) {
if (times == 0) {
pid1 = data;
times += 1;
} else {
pid2 = data;
if (pid1 != pid2) {
done();
} else {
done('they are in the same process');
}
child.kill();
}
});
});
});
});