forked from appium/appium-xcuitest-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add activeAppInfo (appium#1025)
* feat: add activeAppInfo * use const instead of let
- Loading branch information
Showing
5 changed files
with
64 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const extensions = {}, commands = {}; | ||
|
||
/** | ||
* Returns ActiveApp info. | ||
* | ||
* @returns {Object} The response of `/wda/activeAppInfo'` | ||
* @throws {Error} if an error raised by command | ||
*/ | ||
commands.mobileGetActiveAppInfo = async function mobileGetActiveAppInfo () { | ||
return await this.proxyCommand('/wda/activeAppInfo', 'GET'); | ||
}; | ||
|
||
Object.assign(extensions, commands); | ||
export { commands }; | ||
export default extensions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
let extensions = {}, commands = {}; | ||
const extensions = {}, commands = {}; | ||
|
||
/** | ||
* Returns device info. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import chai from 'chai'; | ||
import chaiAsPromised from 'chai-as-promised'; | ||
import sinon from 'sinon'; | ||
import XCUITestDriver from '../../../'; | ||
|
||
chai.should(); | ||
chai.use(chaiAsPromised); | ||
|
||
describe('get activeapp commands', function () { | ||
const driver = new XCUITestDriver(); | ||
// give the driver a spy-able proxy object | ||
driver.wda = {jwproxy: {command: () => {}}}; | ||
let proxyStub; | ||
|
||
this.beforeEach(function () { | ||
proxyStub = sinon.stub(driver.wda.jwproxy, 'command'); | ||
}); | ||
|
||
afterEach(function () { | ||
proxyStub.restore(); | ||
}); | ||
|
||
it('get active app info', async function () { | ||
proxyStub.returns({ | ||
pid: 15438, | ||
name: '', | ||
bundleId: 'com.apple.DocumentsApp', | ||
processArguments: { env: { HAPPY: 'testing' }, args: ['happy', 'testing'] } | ||
}); | ||
|
||
const out = await driver.mobileGetActiveAppInfo(); | ||
out.pid.should.eq(15438); | ||
out.name.should.eq(''); | ||
out.bundleId.should.eq('com.apple.DocumentsApp'); | ||
out.processArguments.env.HAPPY.should.eq('testing'); | ||
out.processArguments.args[0].should.eq('happy'); | ||
out.processArguments.args[1].should.eq('testing'); | ||
}); | ||
|
||
it('get active app info raise an error if the endpoint raises error', async function () { | ||
proxyStub.throws(); | ||
await driver.mobileGetActiveAppInfo().should.eventually.be.rejected; | ||
}); | ||
}); |