@@ -89,22 +89,30 @@ describe("runDeviceAction", () => {
8989 } ) ,
9090 ) ;
9191
92- it . effect ( "keeps a permission change that one compatibility permission applied" , ( ) =>
93- Effect . gen ( function * ( ) {
94- // Images before Android 13 only allow the older storage permission.
95- const { ready } = makeReady ( ( call ) => {
96- if ( call . args . at ( - 1 ) !== "android.permission.READ_EXTERNAL_STORAGE" ) return { code : 1 } ;
97- return { } ;
98- } ) ;
99- const result = yield * runDeviceAction ( ready , "android" , {
100- type : "setPermission" ,
101- deviceId : "emulator-5554" ,
102- appId : "com.example.app" ,
103- permission : "photos" ,
104- decision : "grant" ,
105- } ) ;
106- expect ( result ) . toBeUndefined ( ) ;
107- } ) ,
92+ it . effect . each ( [
93+ [
94+ "photos" ,
95+ [ "android.permission.READ_MEDIA_IMAGES" , "android.permission.READ_EXTERNAL_STORAGE" ] ,
96+ 1 ,
97+ ] ,
98+ [ "contacts" , [ "android.permission.READ_CONTACTS" , "android.permission.WRITE_CONTACTS" ] , 0 ] ,
99+ ] as const ) (
100+ "keeps a partially applied %s permission change" ,
101+ ( [ permission , permissions , success ] ) =>
102+ Effect . gen ( function * ( ) {
103+ const { ready, calls } = makeReady ( ( call ) => ( {
104+ code : call . args . at ( - 1 ) === permissions [ success ] ? 0 : 1 ,
105+ } ) ) ;
106+ const result = yield * runDeviceAction ( ready , "android" , {
107+ type : "setPermission" ,
108+ deviceId : "emulator-5554" ,
109+ appId : "com.example.app" ,
110+ permission,
111+ decision : "grant" ,
112+ } ) ;
113+ expect ( result ) . toBeUndefined ( ) ;
114+ expect ( calls . map ( ( call ) => call . args . at ( - 1 ) ) ) . toEqual ( permissions ) ;
115+ } ) ,
108116 ) ;
109117} ) ;
110118
0 commit comments