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
136 lines (114 loc) · 2.92 KB
/
mocha_test.js
File metadata and controls
136 lines (114 loc) · 2.92 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
var spawn = require('child_process').spawn;
var exec = require('child_process').exec;
var path = require('path');
var net = require('net');
var os = require('os');
var server = global.server;
var fs = require('fs-extra');
var func = require('./' + global.tests_dir +'/start_app/script.js');
var execPath = func.getExecPath();
describe('Startup', function() {
describe('different method of starting app (long-to-run)', function() {
var temp_root = 'tmp-nw';
before(function(done){
this.timeout(10000);
func.copyExecFiles(function() {
func.copySourceFiles();
func.zipSourceFiles(function() {
func.makeExecuableFile();
done();
});
});
})
after(function() {
setTimeout(function() {
fs.remove('tmp-nw', function (er) {
if (er) throw er;
})
}, 1000);
})
it('start from nw that package.json in the same folder', function(done) {
this.timeout(0);
var result = false;
if (os.platform() == 'darwin') {
//mac don't have this method
done();
return;
}
var app = spawn(execPath);
app.on('exit', function() {
result = true;
done();
});
setTimeout(function() {
if (!result) {
done('timeout');
app.kill();
}
}, 10000);
})
it('start from app.nw', function(done) {
this.timeout(0);
var result = false;
var app = spawn(execPath, [path.join('tmp-nw', 'app.nw')]);
app.on('exit', function() {
result = true;
done();
});
setTimeout(function() {
if (!result) {
done('timeout');
app.kill();
}
}, 10000);
})
it('start from folder contains `../`', function(done) {
this.timeout(0);
var result = false;
var app = spawn(execPath, ['../tests/tmp-nw']);
app.on('exit', function() {
result = true;
done();
});
setTimeout(function() {
if (!result) {
done('timeout');
app.kill();
}
}, 10000);
})
it('start from an executable file app.exe', function(done) {
this.timeout(0);
var result = false;
function launch() {
var app = spawn(execPath);
app.on('exit', function() {
result = true;
done();
});
setTimeout(function() {
if (!result) {
done('timeout');
app.kill();
}
}, 10000);
}
if (os.platform() == 'win32') {
execPath = path.join('tmp-nw', 'app.exe');
launch();
}
if (os.platform() == 'linux') {
execPath = path.join('tmp-nw', 'app');
launch();
}
if (os.platform() == 'darwin') {
var app_path = 'tmp-nw/node-webkit.app/Contents/Resources/app.nw';
fs.mkdir(app_path, function(err) {
if(err && err.code !== 'EEXIST') throw err
fs.copy('tmp-nw/index.html', path.join(app_path, 'index.html'));
fs.copy('tmp-nw/package.html', path.join(app_path, 'package.html'), launch);
});
}
})
})
})