forked from ionic-team/ionic-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.spec.js
More file actions
146 lines (113 loc) · 4.73 KB
/
shell.spec.js
File metadata and controls
146 lines (113 loc) · 4.73 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
137
138
139
140
141
142
143
144
145
146
var fs = require('fs'),
helpers = require('./helpers'),
path = require('path'),
Q = require('q'),
request = require('request'),
shell = require('shelljs');
var IonicCli = require('../lib/cli');
var IonicAppLib = require('ionic-app-lib');
var Serve = IonicAppLib.serve;
var tmpDir = helpers.tmpDir('create_test');
var appName = 'TestIonic';
var appId = 'org.ionic.testing';
var project = path.join(tmpDir, appName);
var optimist = require('optimist');
var start = IonicAppLib.start;
var utils = IonicAppLib.utils;
var optimistSpy;
// What to test
// * [ ] Start
// * [ ] Serve
// * [ ] Run
// * [ ]
ddescribe('end-to-end', function() {
beforeEach(function() {
jasmine.getEnv().defaultTimeoutInterval = 150000;
// if (optimistSpy) {
// optimistSpy.reset();
// }
optimistSpy = spyOn(optimist, 'boolean');
optimist.boolean.reset();
//Mock out call to get the app directory, return our project
spyOn(utils, 'getProjectDirectory').andReturn(project);
//Disable console.log statements
// spyOn(IonicAppLib.events, 'on');
// spyOn(process.stdout, 'write');
spyOn(IonicAppLib.multibar, 'newBar').andReturn({tick: function(){}});
shell.rm('-rf', project);
shell.mkdir('-p', tmpDir);
//Copy over created project here.
});
afterEach(function() {
process.chdir(path.join(__dirname, '..')); // Needed to rm the dir on Windows.
// shell.rm('-rf', tmpDir);
});
describe('#start', function(){
xit('should start a new app', function(done) {
shell.cd(tmpDir);
shell.exec('echo "yes" | ionic start s1');
// expect(path.join(project, 's1', 'www', 'index.html')).toExist();
// expect(path.join(project, 's1', 'www', 'templates', 'tabs.html')).toExist();
shell.cd(path.join(tmpDir, 's1'));
// var deferred = Q.defer();
// spyOn(Serve, 'showFinishedServeMessage').andReturn(deferred.promise);
Q()
.then(function() {
// var deferred = Q.defer();
// shell.exec('ionic serve -b & ', {async: true});
// deferred.resolve();
// });
// return deferred.promise;
})
.then(function(){
console.log('ionic serve is done');
var deferred = Q.defer();
request({ url: 'http://0.0.0.0:8100' }, function(err, res, body) {
try {
console.log('body returned', body);
deferred.resolve(body);
} catch(e) {
deferred.reject(body);
}
});
return deferred.promise;
})
.then(function(result) {
console.log('result:', result);
expect(result).toBe(true);
})
.catch(function(err){
expect('this').toBe('not this');
})
.fin(done);
});
iit('should start a new app and run it', function() {
shell.cd(tmpDir);
shell.exec('echo "yes" | ionic start ' + appName);
shell.cd(project);
expect(path.join(project, 'www', 'index.html')).toExist();
expect(path.join(project, 'www', 'templates', 'tabs.html')).toExist();
shell.exec('ionic plugin add org.apache.cordova.splashscreen');
expect(path.join(project, 'plugins', 'org.apache.cordova.splashscreen', 'plugin.xml')).toExist();
shell.exec('ionic platform add android');
expect(path.join(project, 'platforms', 'android', 'AndroidManifest.xml')).toExist();
expect(path.join(project, 'resources', 'icon.png')).toExist();
shell.exec('ionic hooks add');
expect(path.join(project, 'hooks', 'after_plugin_add', '010_register_plugin.js')).toExist();
shell.exec('ionic hooks remove');
expect(path.join(project, 'hooks', 'after_plugin_add', '010_register_plugin.js')).not.toExist();
shell.exec('ionic build ios');
expect(path.join(project, 'platforms', 'ios', 'build', 'emulator', [appName, '.app'].join(''), 'config.xml')).toExist();
shell.exec('ionic build android');
//NOTE this expects you're using ant to build. In cordova android 4.0.0 - gradle is used, ant-build wont be there.
expect(path.join(project, 'platforms', 'android', 'ant-build', 'MainActivity-debug.apk')).toExist();
expect(path.join(project, 'platforms', 'android', 'build.xml')).toExist();
shell.exec('ionic browser add crosswalk');
expect(path.join(project, 'engine', 'xwalk-webviews')).toExist();
shell.exec('ionic build android');
expect(path.join(project, 'platforms', 'android', 'gradle.properties')).toExist();
expect(path.join(project, 'platforms', 'android', 'build', 'outputs', 'apk', 'android-armv7-debug.apk')).toExist();
expect(path.join(project, 'platforms', 'android', 'build', 'outputs', 'apk', 'android-x86-debug.apk')).toExist();
});
});
});