Skip to content

Commit

Permalink
Fix AccessibilityInfo mock to always return a promise in isScreenRead…
Browse files Browse the repository at this point in the history
…erEnabled

Summary:
`AccessibilityInfo.isScreenReaderEnabled().then()` fails by default in tests because that function is mocked and it doesn't return a promise (the default return value is `undefined`). Returning `Promise.resolve(false)` is a good default in this case so it doesn't break any code relying on it.

Changelog: [General] [Fixed] - Fix `AccessibilityInfo.isScreenReaderEnabled` mock in Jest setup

Reviewed By: lunaleaps, motiz88

Differential Revision: D19972921

fbshipit-source-id: 3c8498d5aeeac54d1f5cf333ae39658e22c180a1
  • Loading branch information
rubennorte authored and facebook-github-bot committed Feb 20, 2020
1 parent dbe0d7d commit ec3327b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion jest/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jest
isInvertColorsEnabled: jest.fn(),
isReduceMotionEnabled: jest.fn(),
isReduceTransparencyEnabled: jest.fn(),
isScreenReaderEnabled: jest.fn(),
isScreenReaderEnabled: jest.fn(() => Promise.resolve(false)),
removeEventListener: jest.fn(),
setAccessibilityFocus: jest.fn(),
}))
Expand Down

0 comments on commit ec3327b

Please sign in to comment.