Skip to content

Commit

Permalink
feat: include sensorSet to mobile commands (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
vrunoa committed Mar 30, 2020
1 parent d0763b0 commit aefb47b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -7,3 +7,4 @@ uiautomator2/
coverage
.nyc_output/
test-results.xml
.DS_Store
1 change: 1 addition & 0 deletions lib/commands/general.js
Expand Up @@ -133,6 +133,7 @@ extensions.executeMobile = async function (mobileCommand, opts = {}) {
listSms: 'mobileListSms',

type: 'mobileType',
sensorSet: 'sensorSet',
};

if (!_.has(mobileCommandsMapping, mobileCommand)) {
Expand Down
10 changes: 10 additions & 0 deletions test/unit/commands/general-specs.js
Expand Up @@ -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' });
});
});
});

0 comments on commit aefb47b

Please sign in to comment.