-
Notifications
You must be signed in to change notification settings - Fork 6
CU-868ffcgaz Fixing unit tests broken by Expo 53 update #169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // Mock for expo-av | ||
| export const Audio = { | ||
| setAudioModeAsync: jest.fn().mockResolvedValue(undefined), | ||
| Sound: class MockSound { | ||
| static createAsync = jest.fn().mockResolvedValue({ | ||
| sound: new this(), | ||
| status: { isLoaded: true }, | ||
| }); | ||
|
|
||
| playAsync = jest.fn().mockResolvedValue({ status: { isPlaying: true } }); | ||
| stopAsync = jest.fn().mockResolvedValue({ status: { isPlaying: false } }); | ||
| unloadAsync = jest.fn().mockResolvedValue(undefined); | ||
| setVolumeAsync = jest.fn().mockResolvedValue(undefined); | ||
| }, | ||
| setIsEnabledAsync: jest.fn().mockResolvedValue(undefined), | ||
| getPermissionsAsync: jest.fn().mockResolvedValue({ | ||
| granted: true, | ||
| canAskAgain: true, | ||
| expires: 'never', | ||
| status: 'granted', | ||
| }), | ||
| requestPermissionsAsync: jest.fn().mockResolvedValue({ | ||
| granted: true, | ||
| canAskAgain: true, | ||
| expires: 'never', | ||
| status: 'granted', | ||
| }), | ||
| }; | ||
|
|
||
| export const InterruptionModeIOS = { | ||
| MixWithOthers: 0, | ||
| DoNotMix: 1, | ||
| DuckOthers: 2, | ||
| }; | ||
|
|
||
| export const AVPlaybackSource = {}; |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| export const isDevice = true; | ||
| export const deviceName = 'Test Device'; | ||
| export const deviceYearClass = 2023; | ||
| export const totalMemory = 8192; | ||
| export const supportedCpuArchitectures = ['arm64']; | ||
| export const osName = 'iOS'; | ||
| export const osVersion = '15.0'; | ||
| export const platformApiLevel = null; | ||
| export const modelName = 'iPhone 13'; | ||
| export const modelId = 'iPhone14,5'; | ||
| export const designName = 'iPhone'; | ||
| export const productName = 'iPhone'; | ||
| export const deviceType = 1; | ||
| export const manufacturer = 'Apple'; | ||
|
|
||
| export default { | ||
| isDevice, | ||
| deviceName, | ||
| deviceYearClass, | ||
| totalMemory, | ||
| supportedCpuArchitectures, | ||
| osName, | ||
| osVersion, | ||
| platformApiLevel, | ||
| modelName, | ||
| modelId, | ||
| designName, | ||
| productName, | ||
| deviceType, | ||
| manufacturer, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| export const LocationAccuracy = { | ||
| Lowest: 1, | ||
| Low: 2, | ||
| Balanced: 3, | ||
| High: 4, | ||
| Highest: 5, | ||
| BestForNavigation: 6, | ||
| }; | ||
|
|
||
| export const LocationActivityType = { | ||
| Other: 1, | ||
| AutomotiveNavigation: 2, | ||
| Fitness: 3, | ||
| OtherNavigation: 4, | ||
| Airborne: 5, | ||
| }; | ||
|
|
||
| export const requestForegroundPermissionsAsync = jest.fn().mockResolvedValue({ | ||
| status: 'granted', | ||
| granted: true, | ||
| canAskAgain: true, | ||
| expires: 'never', | ||
| }); | ||
|
|
||
| export const requestBackgroundPermissionsAsync = jest.fn().mockResolvedValue({ | ||
| status: 'granted', | ||
| granted: true, | ||
| canAskAgain: true, | ||
| expires: 'never', | ||
| }); | ||
|
|
||
| export const getCurrentPositionAsync = jest.fn().mockResolvedValue({ | ||
| coords: { | ||
| latitude: 40.7128, | ||
| longitude: -74.006, | ||
| altitude: null, | ||
| accuracy: 5, | ||
| altitudeAccuracy: null, | ||
| heading: null, | ||
| speed: null, | ||
| }, | ||
| timestamp: Date.now(), | ||
| }); | ||
|
|
||
| export const watchPositionAsync = jest.fn().mockImplementation((options, callback) => { | ||
| let timeoutId: ReturnType<typeof setTimeout> | null = null; | ||
| let hasTimedOut = false; | ||
|
|
||
| // Use setTimeout for a one-shot callback to avoid timer leaks | ||
| timeoutId = setTimeout(() => { | ||
| hasTimedOut = true; | ||
| timeoutId = null; | ||
| callback({ | ||
| coords: { | ||
| latitude: 40.7128, | ||
| longitude: -74.006, | ||
| altitude: null, | ||
| accuracy: 5, | ||
| altitudeAccuracy: null, | ||
| heading: 0, | ||
| speed: null, | ||
| }, | ||
| timestamp: Date.now(), | ||
| }); | ||
| }, 100); // Shorter delay for faster tests | ||
|
|
||
| return Promise.resolve({ | ||
| remove: () => { | ||
| if (timeoutId && !hasTimedOut) { | ||
| clearTimeout(timeoutId); | ||
| timeoutId = null; | ||
| } | ||
| // Safe no-op if timeout already fired | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| export const startLocationUpdatesAsync = jest.fn().mockResolvedValue(undefined); | ||
| export const stopLocationUpdatesAsync = jest.fn().mockResolvedValue(undefined); | ||
| export const hasStartedLocationUpdatesAsync = jest.fn().mockResolvedValue(false); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| export const setVisibilityAsync = jest.fn().mockResolvedValue(undefined); | ||
| export const getVisibilityAsync = jest.fn().mockResolvedValue('visible'); | ||
| export const setBackgroundColorAsync = jest.fn().mockResolvedValue(undefined); | ||
| export const getBackgroundColorAsync = jest.fn().mockResolvedValue('#000000'); | ||
| export const setBehaviorAsync = jest.fn().mockResolvedValue(undefined); | ||
| export const getBehaviorAsync = jest.fn().mockResolvedValue('overlay-swipe'); | ||
| export const setButtonStyleAsync = jest.fn().mockResolvedValue(undefined); | ||
| export const getButtonStyleAsync = jest.fn().mockResolvedValue('light'); | ||
| export const setPositionAsync = jest.fn().mockResolvedValue(undefined); | ||
| export const getPositionAsync = jest.fn().mockResolvedValue('bottom'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| export const defineTask = jest.fn(); | ||
| export const startLocationTrackingAsync = jest.fn().mockResolvedValue(undefined); | ||
| export const stopLocationTrackingAsync = jest.fn().mockResolvedValue(undefined); | ||
| export const hasStartedLocationTrackingAsync = jest.fn().mockResolvedValue(false); | ||
| export const getRegisteredTasksAsync = jest.fn().mockResolvedValue([]); | ||
| export const isTaskRegisteredAsync = jest.fn().mockResolvedValue(false); | ||
| export const unregisterTaskAsync = jest.fn().mockResolvedValue(undefined); | ||
| export const unregisterAllTasksAsync = jest.fn().mockResolvedValue(undefined); | ||
|
|
||
| const TaskManager = { | ||
| defineTask, | ||
| startLocationTrackingAsync, | ||
| stopLocationTrackingAsync, | ||
| hasStartedLocationTrackingAsync, | ||
| getRegisteredTasksAsync, | ||
| isTaskRegisteredAsync, | ||
| unregisterTaskAsync, | ||
| unregisterAllTasksAsync, | ||
| }; | ||
|
|
||
| export default TaskManager; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| export const SystemBars = ({ style, hidden }: any) => null; | ||
|
|
||
| export const setStatusBarStyle = jest.fn(); | ||
| export const setNavigationBarStyle = jest.fn(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // Platform setup for Jest - must run before other modules | ||
| const mockPlatform = { | ||
| OS: 'ios' as const, | ||
| select: jest.fn().mockImplementation((obj: any) => obj.ios || obj.default), | ||
| Version: 17, | ||
| constants: {}, | ||
| isTesting: true, | ||
| }; | ||
|
|
||
| // Set global Platform for testing library - must be set before other imports | ||
| Object.defineProperty(global, 'Platform', { | ||
| value: mockPlatform, | ||
| writable: true, | ||
| enumerable: true, | ||
| configurable: true, | ||
| }); | ||
|
|
||
| // Also mock the react-native Platform module directly | ||
| jest.doMock('react-native/Libraries/Utilities/Platform', () => mockPlatform); | ||
|
|
||
| // Ensure Platform is available in the global scope for React Navigation and other libs | ||
| (global as any).Platform = mockPlatform; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.