Skip to content

Commit

Permalink
Fix mock of AccessibilityInfo
Browse files Browse the repository at this point in the history
This aligns with the mock found within the React Native source itself.
Prior to this change, `AccessibilityInfo` was `undefined` within tests.
https://git.io/JXKgx
  • Loading branch information
dcalhoun committed Nov 10, 2021
1 parent 36b6acd commit d1d9040
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions test/native/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,21 @@ jest.mock( 'react-native/Libraries/LayoutAnimation/LayoutAnimation' );
jest.mock(
'react-native/Libraries/Components/AccessibilityInfo/AccessibilityInfo',
() => ( {
addEventListener: jest.fn(),
announceForAccessibility: jest.fn(),
removeEventListener: jest.fn(),
isScreenReaderEnabled: jest.fn( () => Promise.resolve( false ) ),
fetch: jest.fn( () => ( {
done: jest.fn(),
} ) ),
__esModule: true,
default: {
addEventListener: jest.fn( () => ( { remove: jest.fn() } ) ),
announceForAccessibility: jest.fn(),
isBoldTextEnabled: jest.fn(),
isGrayscaleEnabled: jest.fn(),
isInvertColorsEnabled: jest.fn(),
isReduceMotionEnabled: jest.fn(),
isReduceTransparencyEnabled: jest.fn(),
isScreenReaderEnabled: jest.fn( () => Promise.resolve( false ) ),
removeEventListener: jest.fn(),
setAccessibilityFocus: jest.fn(),
sendAccessibilityEvent_unstable: jest.fn(),
getRecommendedTimeoutMillis: jest.fn(),
},
} )
);

Expand Down

1 comment on commit d1d9040

@hypest
Copy link
Contributor

@hypest hypest commented on d1d9040 Dec 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

Please sign in to comment.