From aefb47b384dccc60e9b56d6accdbeed02b0cc5d3 Mon Sep 17 00:00:00 2001 From: Bruno Alassia Date: Mon, 30 Mar 2020 07:57:00 -0300 Subject: [PATCH] feat: include sensorSet to mobile commands (#378) --- .gitignore | 1 + lib/commands/general.js | 1 + test/unit/commands/general-specs.js | 10 ++++++++++ 3 files changed, 12 insertions(+) diff --git a/.gitignore b/.gitignore index beca3ded3..c120c4f7c 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ uiautomator2/ coverage .nyc_output/ test-results.xml +.DS_Store diff --git a/lib/commands/general.js b/lib/commands/general.js index 2b9a75c38..ad323c535 100644 --- a/lib/commands/general.js +++ b/lib/commands/general.js @@ -133,6 +133,7 @@ extensions.executeMobile = async function (mobileCommand, opts = {}) { listSms: 'mobileListSms', type: 'mobileType', + sensorSet: 'sensorSet', }; if (!_.has(mobileCommandsMapping, mobileCommand)) { diff --git a/test/unit/commands/general-specs.js b/test/unit/commands/general-specs.js index 3fc4a2beb..59490f955 100644 --- a/test/unit/commands/general-specs.js +++ b/test/unit/commands/general-specs.js @@ -26,5 +26,15 @@ describe('General', function () { result.x.should.be.equal(0); result.y.should.be.equal(0); }); + it('should raise error on non-existent mobile command', async function () { + await driver.executeMobile('fruta', {}).should.eventually.be.rejectedWith('Unknown mobile command "fruta"'); + }); + it('should accept sensorSet on emulator', async function () { + sandbox.stub(driver, 'isEmulator').returns(true); + let stub = sandbox.stub(driver, 'sensorSet'); + await driver.executeMobile('sensorSet', { sensorType: 'acceleration', value: '0:9.77631:0.812349' }); + stub.calledOnce.should.equal(true); + stub.calledWithExactly({ sensorType: 'acceleration', value: '0:9.77631:0.812349' }); + }); }); });