Skip to content

Commit e8f630c

Browse files
committed
test(cli): fix race in command tests
1 parent 546d856 commit e8f630c

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

spec/cli.spec.js

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,11 @@ describe('Cli', function() {
159159
var processArgs = [ 'node', '/usr/local/bin/ionic', 'start', 's1', '-w', '--appname', 'asdf'];
160160

161161
var promise = IonicCli.run(processArgs);
162+
var _fakeTask = fakeTask;
162163

163164
promise.then(function(){
164-
expect(fakeTask.prototype.run).toHaveBeenCalled();
165-
var taskArgs = fakeTask.prototype.run.mostRecentCall.args;
165+
expect(_fakeTask.prototype.run).toHaveBeenCalled();
166+
var taskArgs = _fakeTask.prototype.run.mostRecentCall.args;
166167

167168
var taskArgv = taskArgs[1];
168169
expect(taskArgv._.length).toBe(2);
@@ -185,10 +186,11 @@ describe('Cli', function() {
185186
var processArgs = [ 'node', '/usr/local/bin/ionic', 'serve', '--nogulp', '--all', '--browser', 'firefox'];
186187

187188
var promise = IonicCli.run(processArgs);
189+
var _fakeTask = fakeTask;
188190

189191
promise.then(function(){
190-
expect(fakeTask.prototype.run).toHaveBeenCalled();
191-
var taskArgs = fakeTask.prototype.run.mostRecentCall.args;
192+
expect(_fakeTask.prototype.run).toHaveBeenCalled();
193+
var taskArgs = _fakeTask.prototype.run.mostRecentCall.args;
192194

193195
var taskArgv = taskArgs[1];
194196
// console.log('taskArgv', taskArgv);
@@ -209,9 +211,11 @@ describe('Cli', function() {
209211
var processArgs = [ 'node', '/usr/local/bin/ionic', 'upload', '--email', '[email protected]', '--password', 'pass', '--note', note];
210212

211213
var promise = IonicCli.run(processArgs);
214+
var _fakeTask = fakeTask;
215+
212216
promise.then(function(){
213-
expect(fakeTask.prototype.run).toHaveBeenCalled();
214-
var taskArgs = fakeTask.prototype.run.mostRecentCall.args;
217+
expect(_fakeTask.prototype.run).toHaveBeenCalled();
218+
var taskArgs = _fakeTask.prototype.run.mostRecentCall.args;
215219

216220
var taskArgv = taskArgs[1];
217221

@@ -228,10 +232,11 @@ describe('Cli', function() {
228232
var processArgs = [ 'node', '/usr/local/bin/ionic', 'login', '--email', '[email protected]', '--password', 'pass'];
229233

230234
var promise = IonicCli.run(processArgs);
235+
var _fakeTask = fakeTask;
231236

232237
promise.then(function(){
233-
expect(fakeTask.prototype.run).toHaveBeenCalled();
234-
var taskArgs = fakeTask.prototype.run.mostRecentCall.args;
238+
expect(_fakeTask.prototype.run).toHaveBeenCalled();
239+
var taskArgs = _fakeTask.prototype.run.mostRecentCall.args;
235240

236241
var taskArgv = taskArgs[1];
237242

@@ -247,10 +252,11 @@ describe('Cli', function() {
247252
var processArgs = [ 'node', '/usr/local/bin/ionic', 'run', 'ios', '--livereload', '--port', '5000', '-r', '35730', '--consolelogs', '--serverlogs', '--device'];
248253

249254
var promise = IonicCli.run(processArgs);
255+
var _fakeTask = fakeTask;
250256

251257
promise.then(function(){
252-
expect(fakeTask.prototype.run).toHaveBeenCalled();
253-
var taskArgs = fakeTask.prototype.run.mostRecentCall.args;
258+
expect(_fakeTask.prototype.run).toHaveBeenCalled();
259+
var taskArgs = _fakeTask.prototype.run.mostRecentCall.args;
254260

255261
var taskArgv = taskArgs[1];
256262

@@ -270,10 +276,11 @@ describe('Cli', function() {
270276
var processArgs = [ 'node', '/usr/local/bin/ionic', 'emulate', 'android', '--livereload', '--address', 'localhost', '--port', '5000', '-r', '35730', '--consolelogs', '--serverlogs'];
271277

272278
var promise = IonicCli.run(processArgs);
279+
var _fakeTask = fakeTask;
273280

274281
promise.then(function(){
275-
expect(fakeTask.prototype.run).toHaveBeenCalled();
276-
var taskArgs = fakeTask.prototype.run.mostRecentCall.args;
282+
expect(_fakeTask.prototype.run).toHaveBeenCalled();
283+
var taskArgs = _fakeTask.prototype.run.mostRecentCall.args;
277284

278285
var taskArgv = taskArgs[1];
279286
//should only have serve in the command args
@@ -293,10 +300,11 @@ describe('Cli', function() {
293300
var processArgs = [ 'node', '/usr/local/bin/ionic', 'state', 'save', '--plugins'];
294301

295302
var promise = IonicCli.run(processArgs);
303+
var _fakeTask = fakeTask;
296304

297305
promise.then(function(){
298-
expect(fakeTask.prototype.run).toHaveBeenCalled();
299-
var taskArgs = fakeTask.prototype.run.mostRecentCall.args;
306+
expect(_fakeTask.prototype.run).toHaveBeenCalled();
307+
var taskArgs = _fakeTask.prototype.run.mostRecentCall.args;
300308

301309
var taskArgv = taskArgs[1];
302310

@@ -313,10 +321,11 @@ describe('Cli', function() {
313321
var processArgs = [ 'node', '/usr/local/bin/ionic', 'plugin', 'add', 'org.apache.cordova.splashscreen', '--nosave', '--searchpath', '../'];
314322

315323
var promise = IonicCli.run(processArgs);
324+
var _fakeTask = fakeTask;
316325

317326
promise.then(function(){
318-
expect(fakeTask.prototype.run).toHaveBeenCalled();
319-
var taskArgs = fakeTask.prototype.run.mostRecentCall.args;
327+
expect(_fakeTask.prototype.run).toHaveBeenCalled();
328+
var taskArgs = _fakeTask.prototype.run.mostRecentCall.args;
320329

321330
var taskArgv = taskArgs[1];
322331

@@ -335,10 +344,11 @@ describe('Cli', function() {
335344
var processArgs = [ 'node', '/usr/local/bin/ionic', 'build', 'ios', '--nohooks'];
336345

337346
var promise = IonicCli.run(processArgs);
347+
var _fakeTask = fakeTask;
338348

339349
promise.then(function(){
340-
expect(fakeTask.prototype.run).toHaveBeenCalled();
341-
var taskArgs = fakeTask.prototype.run.mostRecentCall.args;
350+
expect(_fakeTask.prototype.run).toHaveBeenCalled();
351+
var taskArgs = _fakeTask.prototype.run.mostRecentCall.args;
342352

343353
var taskArgv = taskArgs[1];
344354

0 commit comments

Comments
 (0)