@@ -3,6 +3,7 @@ import {ADB} from 'appium-adb';
3
3
import { AndroidDriver } from '../../../lib/driver' ;
4
4
import B from 'bluebird' ;
5
5
import { SettingsApp } from 'io.appium.settings' ;
6
+ import { errors } from 'appium/driver' ;
6
7
7
8
/** @type {AndroidDriver } */
8
9
let driver ;
@@ -118,6 +119,47 @@ describe('Network', function () {
118
119
driver . setDataState . calledWithExactly ( true ) . should . be . true ;
119
120
} ) ;
120
121
} ) ;
122
+ describe ( 'mobileGetConnectivity' , function ( ) {
123
+ it ( 'should raise unsupported services in string' , async function ( ) {
124
+ await driver . mobileGetConnectivity ( 'bad' )
125
+ . should . eventually . rejectedWith ( errors . InvalidArgumentError ) ;
126
+ } ) ;
127
+ it ( 'should raise unsupported services in array' , async function ( ) {
128
+ await driver . mobileGetConnectivity ( [ 'bad' , 'array' ] )
129
+ . should . eventually . rejectedWith ( errors . InvalidArgumentError ) ;
130
+ } ) ;
131
+ it ( 'should raise unsupported services with an empty array' , async function ( ) {
132
+ await driver . mobileGetConnectivity ( ) . should . eventually . eql ( { } ) ;
133
+ } ) ;
134
+ it ( 'should return all supported services' , async function ( ) {
135
+ adb . isWifiOn . returns ( true ) ;
136
+ adb . isDataOn . returns ( true ) ;
137
+ adb . isAirplaneModeOn . returns ( true ) ;
138
+ await driver . mobileGetConnectivity ( )
139
+ . should . eventually . eql ( { wifi : true , data : true , airplaneMode : true } ) ;
140
+ } ) ;
141
+ it ( 'should return only wifi' , async function ( ) {
142
+ adb . isWifiOn . returns ( true ) ;
143
+ adb . isDataOn . returns ( true ) ;
144
+ adb . isAirplaneModeOn . returns ( true ) ;
145
+ await driver . mobileGetConnectivity ( 'wifi' )
146
+ . should . eventually . eql ( { wifi : true } ) ;
147
+ } ) ;
148
+ it ( 'should return only data' , async function ( ) {
149
+ adb . isWifiOn . returns ( true ) ;
150
+ adb . isDataOn . returns ( true ) ;
151
+ adb . isAirplaneModeOn . returns ( true ) ;
152
+ await driver . mobileGetConnectivity ( [ 'data' ] )
153
+ . should . eventually . eql ( { data : true } ) ;
154
+ } ) ;
155
+ it ( 'should return only data and airplaneMode' , async function ( ) {
156
+ adb . isWifiOn . returns ( true ) ;
157
+ adb . isDataOn . returns ( true ) ;
158
+ adb . isAirplaneModeOn . returns ( false ) ;
159
+ await driver . mobileGetConnectivity ( [ 'data' , 'airplaneMode' ] )
160
+ . should . eventually . eql ( { data : true , airplaneMode : false } ) ;
161
+ } ) ;
162
+ } ) ;
121
163
describe ( 'toggleData' , function ( ) {
122
164
it ( 'should toggle data' , async function ( ) {
123
165
adb . isDataOn . returns ( false ) ;
0 commit comments