Skip to content

Commit d7eb121

Browse files
committed
Added e2e tests for commands showsdks, showdevicetypes, start
1 parent aa24830 commit d7eb121

File tree

3 files changed

+47
-17
lines changed

3 files changed

+47
-17
lines changed

spec/commands.spec.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,37 @@
1616
specific language governing permissions and limitations
1717
under the License.
1818
*/
19+
var commands = require('../src/commands');
1920

2021
describe('commands end-to-end', function() {
2122

2223
beforeEach(function() {
24+
commands.init();
2325
});
2426

2527
afterEach(function() {
2628
});
2729

28-
// it('', function(done) {
29-
// });
30-
});
30+
it('command - showsdks', function() {
31+
commands.showsdks({ 'no-output': true });
32+
});
33+
34+
it('command - showdevicetypes', function() {
35+
commands.showdevicetypes({ 'no-output': true });;
36+
});
37+
38+
it('command - launch', function() {
39+
//TODO: - fail();
40+
//TODO: add a fixture Simulator .app to launch
41+
});
42+
43+
it('command - install', function() {
44+
//TODO: - fail();
45+
//TODO: add a fixture Simulator .app to install
46+
});
47+
48+
it('command - start', function() {
49+
var devicetypeid = 'iPhone-6';
50+
commands.start({ 'devicetypeid': devicetypeid });
51+
});
52+
});

src/commands.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,23 @@ var command_lib = {
3636

3737
//jscs:disable disallowUnusedParams
3838
showsdks: function(args) {
39-
lib.showsdks();
39+
args = args || {};
40+
41+
var output = lib.showsdks();
42+
if (!args['no-output']) {
43+
console.log(output);
44+
}
4045
},
4146
//jscs:enable disallowUnusedParams
4247

4348
//jscs:disable disallowUnusedParams
4449
showdevicetypes: function(args) {
45-
lib.showdevicetypes();
50+
args = args || {};
51+
52+
var output = lib.showdevicetypes();
53+
if (!args['no-output']) {
54+
console.log(output);
55+
}
4656
},
4757
//jscs:enable disallowUnusedParams
4858

@@ -82,4 +92,3 @@ var command_lib = {
8292
};
8393

8494
module.exports = command_lib;
85-

src/lib.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -327,13 +327,15 @@ var lib = {
327327
var options = { silent: true, runtimes: true };
328328
var list = simctl.list(options).json;
329329

330-
console.log('Simulator SDK Roots:');
330+
var output = 'Simulator SDK Roots:\n';
331331
list.runtimes.forEach(function(runtime) {
332332
if (runtime.availability === '(available)') {
333-
console.log(util.format('"%s" (%s)', runtime.name, runtime.buildversion));
334-
console.log(util.format('\t(unknown)'));
333+
output += util.format('"%s" (%s)\n', runtime.name, runtime.buildversion);
334+
output += util.format('\t(unknown)\n');
335335
}
336336
});
337+
338+
return output;
337339
},
338340
//jscs:enable disallowUnusedParams
339341

@@ -378,9 +380,12 @@ var lib = {
378380

379381
//jscs:disable disallowUnusedParams
380382
showdevicetypes: function(args) {
383+
var output = '';
381384
this.getdevicetypes().forEach(function(device) {
382-
console.log(device);
385+
output += util.format('%s\n', device);
383386
});
387+
388+
return output;
384389
},
385390
//jscs:enable disallowUnusedParams
386391

@@ -475,13 +480,7 @@ var lib = {
475480
},
476481

477482
start: function(devicetypeid) {
478-
var device = {};
479-
try {
480-
device = getDeviceFromDeviceTypeId(devicetypeid);
481-
} catch (e) {
482-
console.error(e);
483-
}
484-
483+
var device = getDeviceFromDeviceTypeId(devicetypeid);
485484
simctl.extensions.start(device.id);
486485
},
487486

0 commit comments

Comments
 (0)