mirror of
https://github.com/apache/cordova-android.git
synced 2026-01-30 00:05:28 +08:00
feat: add listTarget api (#1602)
* feat: add listTarget api * test: write Platform API target list specs
This commit is contained in:
@@ -24,6 +24,8 @@ const EventEmitter = require('events');
|
||||
|
||||
const Api = require('../../lib/Api');
|
||||
const AndroidProject = require('../../lib/AndroidProject');
|
||||
const check_reqs = require('../../lib/check_reqs');
|
||||
const run_mod = require('../../lib/run');
|
||||
|
||||
const PluginInfo = common.PluginInfo;
|
||||
|
||||
@@ -60,4 +62,19 @@ describe('Api', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('listTargets', () => {
|
||||
let api;
|
||||
|
||||
beforeEach(() => {
|
||||
api = new Api('android', FAKE_PROJECT_DIR, new EventEmitter());
|
||||
spyOn(check_reqs, 'run').and.returnValue(Promise.resolve());
|
||||
});
|
||||
it('should call into lib/run module', () => {
|
||||
spyOn(run_mod, 'runListDevices');
|
||||
return api.listTargets().then(() => {
|
||||
expect(run_mod.runListDevices).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -106,4 +106,32 @@ describe('run', () => {
|
||||
.toBeRejectedWithError(/Package type "bundle" is not supported/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('--list option', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(run, 'listDevices').and.returnValue(Promise.resolve());
|
||||
spyOn(run, 'listEmulators').and.returnValue(Promise.resolve());
|
||||
});
|
||||
|
||||
it('should delegate to "listDevices" when the "runListDevices" method options param contains "options.device".', () => {
|
||||
return run.runListDevices({ options: { device: true } }).then(() => {
|
||||
expect(run.listDevices).toHaveBeenCalled();
|
||||
expect(run.listEmulators).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
it('should delegate to "listDevices" when the "runListDevices" method options param contains "options.emulator".', () => {
|
||||
return run.runListDevices({ options: { emulator: true } }).then(() => {
|
||||
expect(run.listDevices).not.toHaveBeenCalled();
|
||||
expect(run.listEmulators).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
it('should delegate to both "listEmulators" and "listDevices" when the "runListDevices" method does not contain "options.device" or "options.emulator".', () => {
|
||||
return run.runListDevices({ options: {} }).then(() => {
|
||||
expect(run.listDevices).toHaveBeenCalled();
|
||||
expect(run.listEmulators).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user