-
-
Notifications
You must be signed in to change notification settings - Fork 212
/
Copy pathnfc.js
36 lines (33 loc) · 980 Bytes
/
nfc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import {errors} from 'appium/driver';
import _ from 'lodash';
const SUPPORTED_ACTIONS = /** @type {const} */ ({
ENABLE: 'enable',
DISABLE: 'disable',
});
/**
* Performs the requested action on the default NFC adapter
*
* @this {AndroidDriver}
* @param { 'enable' | 'disable'} action
* @returns {Promise<void>}
* @throws {Error} if the device under test has no default NFC adapter
* or there was a failure while performing the action.
*/
export async function mobileNfc(action) {
switch (action) {
case SUPPORTED_ACTIONS.ENABLE:
await this.adb.setNfcOn(true);
break;
case SUPPORTED_ACTIONS.DISABLE:
await this.adb.setNfcOn(false);
break;
default:
throw new errors.InvalidArgumentError(
`You must provide a valid 'action' argument. Supported actions are: ${_.values(SUPPORTED_ACTIONS)}`
);
}
}
/**
* @typedef {import('appium-adb').ADB} ADB
* @typedef {import('../driver').AndroidDriver} AndroidDriver
*/