forked from nwjs/nw.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmocha_test.js
More file actions
76 lines (58 loc) · 1.6 KB
/
mocha_test.js
File metadata and controls
76 lines (58 loc) · 1.6 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
67
68
69
70
71
72
73
74
75
76
var spawn = require('child_process').spawn;
var path = require('path');
var net = require('net');
var server = global.server;
var cb;
describe('node-remote', function() {
describe('enable remote site http://127.0.0.1:80/', function() {
var app;
var exec_argv;
var socket;
before(function(done) {
//this.timeout(0);
exec_argv = [path.join('app_tests', 'node-remote'),
'--port',
global.port];
if (global.auto) exec_argv.push('--auto');
server.on('connection', cb = function(s){
socket = s;
s.setEncoding('utf8');
done();
});
app = spawn(process.execPath, exec_argv);
})
after(function(done) {
this.timeout(0);
app.kill();
done();
server.removeListener('connection', cb);
})
afterEach(function(){
socket.removeAllListeners('data');
})
it('http://127.0.0.1/node_remote_test.html should be able call Node',
function(done) {
this.timeout(0);
socket.on('data', function(data) {
if (data == 'ok'){
done();
} else {
done(data);
}
});
socket.write('80');
})
it('http://127.0.0.1:8080/node_remote_test.html should not be able call Node',
function(done) {
this.timeout(0);
socket.on('data', function(data) {
if (data == 'ok'){
done('should not call node');
} else {
done();
}
});
socket.write('8080');
})
})
})