@@ -8,6 +8,12 @@ import {
88 getLocatorSdkSession ,
99 getLocatorSdkMode ,
1010 getLocatorSdkConfig ,
11+ requestPermissionLocation ,
12+ requestPermissionBackgroundLocation ,
13+ requestPermissionMicrophone ,
14+ requestPermissionNotifications ,
15+ requestPermissionCriticalAlerts ,
16+ requestPermissionBatteryOptimization ,
1117} from '../family-locator' ;
1218import {
1319 createFakeAndroidPostMessage ,
@@ -225,3 +231,99 @@ test('getLocatorSdkConfig', async () => {
225231 const res = await getLocatorSdkConfig ( ) ;
226232 expect ( res ) . toEqual ( { config} ) ;
227233} ) ;
234+
235+ test ( 'requestPermissionLocation' , async ( ) => {
236+ createFakeAndroidPostMessage ( {
237+ checkMessage : ( msg ) => {
238+ expect ( msg . type ) . toBe ( 'REQUEST_PERMISSION_LOCATION' ) ;
239+ } ,
240+ getResponse : ( msg ) => ( {
241+ type : 'REQUEST_PERMISSION_LOCATION' ,
242+ id : msg . id ,
243+ payload : { status : 'granted' } ,
244+ } ) ,
245+ } ) ;
246+
247+ const res = await requestPermissionLocation ( ) ;
248+ expect ( res ) . toEqual ( { status : 'granted' } ) ;
249+ } ) ;
250+
251+ test ( 'requestPermissionBackgroundLocation' , async ( ) => {
252+ createFakeAndroidPostMessage ( {
253+ checkMessage : ( msg ) => {
254+ expect ( msg . type ) . toBe ( 'REQUEST_PERMISSION_BACKGROUND_LOCATION' ) ;
255+ } ,
256+ getResponse : ( msg ) => ( {
257+ type : 'REQUEST_PERMISSION_BACKGROUND_LOCATION' ,
258+ id : msg . id ,
259+ payload : { status : 'settings_change_required' } ,
260+ } ) ,
261+ } ) ;
262+
263+ const res = await requestPermissionBackgroundLocation ( ) ;
264+ expect ( res ) . toEqual ( { status : 'settings_change_required' } ) ;
265+ } ) ;
266+
267+ test ( 'requestPermissionMicrophone' , async ( ) => {
268+ createFakeAndroidPostMessage ( {
269+ checkMessage : ( msg ) => {
270+ expect ( msg . type ) . toBe ( 'REQUEST_PERMISSION_MICROPHONE' ) ;
271+ } ,
272+ getResponse : ( msg ) => ( {
273+ type : 'REQUEST_PERMISSION_MICROPHONE' ,
274+ id : msg . id ,
275+ payload : { status : 'denied' } ,
276+ } ) ,
277+ } ) ;
278+
279+ const res = await requestPermissionMicrophone ( ) ;
280+ expect ( res ) . toEqual ( { status : 'denied' } ) ;
281+ } ) ;
282+
283+ test ( 'requestPermissionNotifications' , async ( ) => {
284+ createFakeAndroidPostMessage ( {
285+ checkMessage : ( msg ) => {
286+ expect ( msg . type ) . toBe ( 'REQUEST_PERMISSION_NOTIFICATIONS' ) ;
287+ } ,
288+ getResponse : ( msg ) => ( {
289+ type : 'REQUEST_PERMISSION_NOTIFICATIONS' ,
290+ id : msg . id ,
291+ payload : { status : 'granted' } ,
292+ } ) ,
293+ } ) ;
294+
295+ const res = await requestPermissionNotifications ( ) ;
296+ expect ( res ) . toEqual ( { status : 'granted' } ) ;
297+ } ) ;
298+
299+ test ( 'requestPermissionCriticalAlerts' , async ( ) => {
300+ createFakeAndroidPostMessage ( {
301+ checkMessage : ( msg ) => {
302+ expect ( msg . type ) . toBe ( 'REQUEST_PERMISSION_CRITICAL_ALERTS' ) ;
303+ } ,
304+ getResponse : ( msg ) => ( {
305+ type : 'REQUEST_PERMISSION_CRITICAL_ALERTS' ,
306+ id : msg . id ,
307+ payload : { status : 'denied' } ,
308+ } ) ,
309+ } ) ;
310+
311+ const res = await requestPermissionCriticalAlerts ( ) ;
312+ expect ( res ) . toEqual ( { status : 'denied' } ) ;
313+ } ) ;
314+
315+ test ( 'requestPermissionBatteryOptimization' , async ( ) => {
316+ createFakeAndroidPostMessage ( {
317+ checkMessage : ( msg ) => {
318+ expect ( msg . type ) . toBe ( 'REQUEST_PERMISSION_BATTERY_OPTIMIZATION' ) ;
319+ } ,
320+ getResponse : ( msg ) => ( {
321+ type : 'REQUEST_PERMISSION_BATTERY_OPTIMIZATION' ,
322+ id : msg . id ,
323+ payload : { status : 'settings_change_required' } ,
324+ } ) ,
325+ } ) ;
326+
327+ const res = await requestPermissionBatteryOptimization ( ) ;
328+ expect ( res ) . toEqual ( { status : 'settings_change_required' } ) ;
329+ } ) ;
0 commit comments