@@ -16,6 +16,9 @@ const mockGetCurrentPrefersCrossFadeTransitionsState = jest.fn(
1616const mockGetCurrentDarkerSystemColorsState = jest . fn ( ( onSuccess , onError ) =>
1717 onSuccess ( true ) ,
1818) ;
19+ const mockGetCurrentDifferentiateWithoutColorState = jest . fn (
20+ ( onSuccess , onError ) => onSuccess ( true ) ,
21+ ) ;
1922const mockGetCurrentBoldTextState = jest . fn ( ( onSuccess , onError ) =>
2023 onSuccess ( true ) ,
2124) ;
@@ -35,6 +38,13 @@ const mockGetCurrentVoiceOverState = jest.fn((onSuccess, onError) =>
3538 onSuccess ( true ) ,
3639) ;
3740let mockNativeAccessibilityManagerIOS : {
41+ getCurrentDifferentiateWithoutColorState: JestMockFn <
42+ [
43+ onSuccess : ( isDifferentiateWithoutColorEnabled : boolean ) = > void ,
44+ onError : ( error : Error ) = > void ,
45+ ] ,
46+ void ,
47+ > | null ,
3848 getCurrentPrefersCrossFadeTransitionsState : JestMockFn <
3949 [
4050 onSuccess : ( prefersCrossFadeTransitions : boolean ) = > void ,
@@ -92,6 +102,8 @@ let mockNativeAccessibilityManagerIOS: {
92102 void ,
93103 > | null ,
94104} = {
105+ getCurrentDifferentiateWithoutColorState :
106+ mockGetCurrentDifferentiateWithoutColorState ,
95107 getCurrentPrefersCrossFadeTransitionsState :
96108 mockGetCurrentPrefersCrossFadeTransitionsState ,
97109 getCurrentDarkerSystemColorsState : mockGetCurrentDarkerSystemColorsState ,
@@ -660,6 +672,54 @@ describe('AccessibilityInfo', () => {
660672 } ) ;
661673 } ) ;
662674
675+ describe ( 'isDifferentiateWithoutColorEnabled' , ( ) => {
676+ describe ( 'Android' , ( ) => {
677+ it ( 'should return immediately' , async ( ) => {
678+ /* $FlowFixMe[incompatible-type] */
679+ Platform . OS = 'android' ;
680+
681+ const result =
682+ await AccessibilityInfo . isDifferentiateWithoutColorEnabled ( ) ;
683+
684+ expect ( result ) . toBe ( false ) ;
685+ } ) ;
686+ } ) ;
687+
688+ describe ( 'iOS' , ( ) => {
689+ it ( 'should call getCurrentDifferentiateWithoutColorState if available' , async ( ) => {
690+ /* $FlowFixMe[incompatible-type] */
691+ Platform . OS = 'ios' ;
692+
693+ const result =
694+ await AccessibilityInfo . isDifferentiateWithoutColorEnabled ( ) ;
695+
696+ expect ( mockGetCurrentDifferentiateWithoutColorState ) . toHaveBeenCalled ( ) ;
697+ expect ( result ) . toBe ( true ) ;
698+ } ) ;
699+
700+ it ( 'should throw error if getCurrentDifferentiateWithoutColorState is not available' , async ( ) => {
701+ /* $FlowFixMe[incompatible-type] */
702+ Platform . OS = 'ios' ;
703+
704+ mockNativeAccessibilityManagerIOS . getCurrentDifferentiateWithoutColorState =
705+ null ;
706+
707+ const result : unknown =
708+ await AccessibilityInfo . isDifferentiateWithoutColorEnabled ( ) . catch (
709+ e => e ,
710+ ) ;
711+
712+ invariant (
713+ result instanceof Error ,
714+ 'Expected isDifferentiateWithoutColorEnabled to reject' ,
715+ ) ;
716+ expect ( result . message ) . toEqual (
717+ 'NativeAccessibilityManagerIOS.getCurrentDifferentiateWithoutColorState is not available' ,
718+ ) ;
719+ } ) ;
720+ } ) ;
721+ } ) ;
722+
663723 describe ( 'isDarkerSystemColorsEnabled' , ( ) => {
664724 describe ( 'Android' , ( ) => {
665725 it ( 'should return immediately' , async ( ) => {
@@ -791,6 +851,8 @@ describe('AccessibilityInfo', () => {
791851
792852 afterEach ( ( ) => {
793853 mockNativeAccessibilityManagerIOS = {
854+ getCurrentDifferentiateWithoutColorState :
855+ mockGetCurrentDifferentiateWithoutColorState ,
794856 getCurrentPrefersCrossFadeTransitionsState :
795857 mockGetCurrentPrefersCrossFadeTransitionsState ,
796858 getCurrentDarkerSystemColorsState : mockGetCurrentDarkerSystemColorsState ,
0 commit comments