Conversation
📝 WalkthroughWalkthroughThis PR establishes Jest mock infrastructure for Expo libraries and extends existing React Native mocks with Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@__mocks__/react-native.ts`:
- Around line 37-41: The I18nManager mock is missing the swapLeftAndRightInRTL
property used in jest-setup.ts and src/app/login/__tests__/login-form.test.tsx;
update the I18nManager export in __mocks__/react-native.ts to include
swapLeftAndRightInRTL (as a jest.fn() or boolean as appropriate for the mock) so
the mock API matches the real I18nManager and the tests that call
swapLeftAndRightInRTL do not get undefined.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d4de7e79-5102-44a5-b1ee-7ad25c60a24a
📒 Files selected for processing (10)
__mocks__/expo-keep-awake.ts__mocks__/expo-localization.ts__mocks__/react-native.tsjest-setup.tssrc/app/login/__tests__/login-form.test.tsxsrc/app/login/login-form.tsxsrc/translations/ar.jsonsrc/translations/en.jsonsrc/translations/es.jsonsrc/translations/pl.json
| export const I18nManager = { | ||
| allowRTL: jest.fn(), | ||
| forceRTL: jest.fn(), | ||
| isRTL: false, | ||
| }; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== I18nManager usage and API members =="
rg -n -C2 '\bI18nManager\b|\bswapLeftAndRightInRTL\b' --type ts --type tsx
echo
echo "== __mocks__/react-native.ts excerpt =="
sed -n '30,80p' __mocks__/react-native.ts
echo
echo "== jest-setup.ts excerpt =="
sed -n '318,336p' jest-setup.tsRepository: Resgrid/Responder
Length of output: 145
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== __mocks__/react-native.ts (lines 30-80) =="
cat -n __mocks__/react-native.ts | sed -n '30,80p'
echo
echo "== jest-setup.ts (searching for I18nManager) =="
grep -n -A5 'I18nManager' jest-setup.ts || echo "Not found in jest-setup.ts"
echo
echo "== Search for swapLeftAndRightInRTL usage =="
rg -n 'swapLeftAndRightInRTL' || echo "No matches found"
echo
echo "== Search for I18nManager usage across codebase =="
rg -n 'I18nManager' -t ts || echo "No matches in .ts files"Repository: Resgrid/Responder
Length of output: 2370
Add swapLeftAndRightInRTL to keep I18nManager mock API consistent.
The I18nManager mock at lines 37-41 is missing swapLeftAndRightInRTL, which is defined in jest-setup.ts and actively used in src/app/login/__tests__/login-form.test.tsx. This API surface mismatch can cause undefined behavior if tests import from __mocks__/react-native.ts instead of relying on the jest-setup definition.
🔧 Proposed fix
export const I18nManager = {
allowRTL: jest.fn(),
forceRTL: jest.fn(),
+ swapLeftAndRightInRTL: jest.fn(),
isRTL: false,
};📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| export const I18nManager = { | |
| allowRTL: jest.fn(), | |
| forceRTL: jest.fn(), | |
| isRTL: false, | |
| }; | |
| export const I18nManager = { | |
| allowRTL: jest.fn(), | |
| forceRTL: jest.fn(), | |
| swapLeftAndRightInRTL: jest.fn(), | |
| isRTL: false, | |
| }; |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@__mocks__/react-native.ts` around lines 37 - 41, The I18nManager mock is
missing the swapLeftAndRightInRTL property used in jest-setup.ts and
src/app/login/__tests__/login-form.test.tsx; update the I18nManager export in
__mocks__/react-native.ts to include swapLeftAndRightInRTL (as a jest.fn() or
boolean as appropriate for the mock) so the mock API matches the real
I18nManager and the tests that call swapLeftAndRightInRTL do not get undefined.
|
Approve |
Summary by CodeRabbit
Tests
Localization
Style