-
Notifications
You must be signed in to change notification settings - Fork 181
Clean up navigation and setup Jest #549
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
Merged
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
fa1f8bf
remove dupe account screens and prefer the term home
transphorm 598ad7e
organize screen loading better
transphorm 31a4aeb
sort keys
transphorm 55fc7cd
rename screen files wip
transphorm 17a60bf
fix deleted directory issues
transphorm 5a8ac4e
rename folders
transphorm 4af1608
fix paths and naming
transphorm e1fa1ae
save working jest import test
transphorm 630294e
save base working jest navigation test
transphorm c40052e
finalize navigation refactor and jest test
transphorm eff227b
update test name and podfile lock
transphorm ef1a5e9
remove unused packages
transphorm e700bd2
use the correct version of react test renderer
transphorm 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 |
|---|---|---|
| @@ -1,3 +1,13 @@ | ||
| module.exports = { | ||
| preset: 'react-native', | ||
| moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], | ||
| transformIgnorePatterns: [ | ||
| 'node_modules/(?!(react-native|@react-native|@react-navigation|@react-native-community|@segment/analytics-react-native|@openpassport|react-native-keychain|react-native-check-version|react-native-nfc-manager|react-native-passport-reader|uuid|@stablelib|@react-native-google-signin|react-native-cloud-storage|@react-native-clipboard)/)', | ||
| ], | ||
| setupFiles: ['<rootDir>/jest.setup.js'], | ||
| testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.[jt]sx?$', | ||
| moduleNameMapper: { | ||
| '^@env$': '<rootDir>/tests/__setup__/@env.js', | ||
| '^@openpassport/(.*)$': '<rootDir>/../common/node_modules/@openpassport/$1', | ||
| }, | ||
| }; |
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,263 @@ | ||
| /* global jest */ | ||
| /** @jest-environment jsdom */ | ||
| require('react-native-gesture-handler/jestSetup'); | ||
|
|
||
| jest.mock('react-native-reanimated', () => { | ||
| const Reanimated = require('react-native-reanimated/mock'); | ||
| Reanimated.default.call = () => {}; | ||
| return Reanimated; | ||
| }); | ||
|
|
||
| jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper'); | ||
|
|
||
| // Mock react-native-haptic-feedback | ||
| jest.mock('react-native-haptic-feedback', () => ({ | ||
| trigger: jest.fn(), | ||
| })); | ||
|
|
||
| // Mock Segment Analytics | ||
| jest.mock('@segment/analytics-react-native', () => { | ||
| const mockClient = { | ||
| add: jest.fn(), | ||
| track: jest.fn(), | ||
| identify: jest.fn(), | ||
| screen: jest.fn(), | ||
| group: jest.fn(), | ||
| alias: jest.fn(), | ||
| reset: jest.fn(), | ||
| }; | ||
|
|
||
| return { | ||
| createClient: jest.fn(() => mockClient), | ||
| EventPlugin: jest.fn(), | ||
| PluginType: { | ||
| ENRICHMENT: 'enrichment', | ||
| DESTINATION: 'destination', | ||
| BEFORE: 'before', | ||
| }, | ||
| }; | ||
| }); | ||
|
|
||
| // Mock react-native-keychain | ||
| jest.mock('react-native-keychain', () => ({ | ||
| SECURITY_LEVEL_ANY: 'MOCK_SECURITY_LEVEL_ANY', | ||
| SECURITY_LEVEL_SECURE_SOFTWARE: 'MOCK_SECURITY_LEVEL_SECURE_SOFTWARE', | ||
| SECURITY_LEVEL_SECURE_HARDWARE: 'MOCK_SECURITY_LEVEL_SECURE_HARDWARE', | ||
| setGenericPassword: jest.fn(), | ||
| getGenericPassword: jest.fn(), | ||
| resetGenericPassword: jest.fn(), | ||
| ACCESSIBLE: { | ||
| WHEN_UNLOCKED: 'AccessibleWhenUnlocked', | ||
| AFTER_FIRST_UNLOCK: 'AccessibleAfterFirstUnlock', | ||
| ALWAYS: 'AccessibleAlways', | ||
| WHEN_PASSCODE_SET_THIS_DEVICE_ONLY: | ||
| 'AccessibleWhenPasscodeSetThisDeviceOnly', | ||
| WHEN_UNLOCKED_THIS_DEVICE_ONLY: 'AccessibleWhenUnlockedThisDeviceOnly', | ||
| AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY: | ||
| 'AccessibleAfterFirstUnlockThisDeviceOnly', | ||
| ALWAYS_THIS_DEVICE_ONLY: 'AccessibleAlwaysThisDeviceOnly', | ||
| }, | ||
| ACCESS_CONTROL: { | ||
| USER_PRESENCE: 'UserPresence', | ||
| BIOMETRY_ANY: 'BiometryAny', | ||
| BIOMETRY_CURRENT_SET: 'BiometryCurrentSet', | ||
| DEVICE_PASSCODE: 'DevicePasscode', | ||
| APPLICATION_PASSWORD: 'ApplicationPassword', | ||
| BIOMETRY_ANY_OR_DEVICE_PASSCODE: 'BiometryAnyOrDevicePasscode', | ||
| BIOMETRY_CURRENT_SET_OR_DEVICE_PASSCODE: | ||
| 'BiometryCurrentSetOrDevicePasscode', | ||
| }, | ||
| })); | ||
|
|
||
| // Mock AsyncStorage | ||
| jest.mock('@react-native-async-storage/async-storage', () => ({ | ||
| setItem: jest.fn(), | ||
| getItem: jest.fn(), | ||
| removeItem: jest.fn(), | ||
| mergeItem: jest.fn(), | ||
| clear: jest.fn(), | ||
| getAllKeys: jest.fn(), | ||
| flushGetRequests: jest.fn(), | ||
| multiGet: jest.fn(), | ||
| multiSet: jest.fn(), | ||
| multiRemove: jest.fn(), | ||
| multiMerge: jest.fn(), | ||
| })); | ||
|
|
||
| // Mock react-native-check-version | ||
| jest.mock('react-native-check-version', () => ({ | ||
| checkVersion: jest.fn().mockResolvedValue({ | ||
| needsUpdate: false, | ||
| currentVersion: '1.0.0', | ||
| latestVersion: '1.0.0', | ||
| }), | ||
| })); | ||
|
|
||
| // Mock @react-native-community/netinfo | ||
| jest.mock('@react-native-community/netinfo', () => ({ | ||
| addEventListener: jest.fn(), | ||
| useNetInfo: jest.fn().mockReturnValue({ | ||
| type: 'wifi', | ||
| isConnected: true, | ||
| isInternetReachable: true, | ||
| details: { | ||
| isConnectionExpensive: false, | ||
| cellularGeneration: '4g', | ||
| }, | ||
| }), | ||
| fetch: jest.fn(), | ||
| })); | ||
|
|
||
| // Mock react-native-nfc-manager | ||
| jest.mock('react-native-nfc-manager', () => ({ | ||
| start: jest.fn(), | ||
| isSupported: jest.fn().mockResolvedValue(true), | ||
| isEnabled: jest.fn().mockResolvedValue(true), | ||
| registerTagEvent: jest.fn(), | ||
| unregisterTagEvent: jest.fn(), | ||
| requestTechnology: jest.fn(), | ||
| cancelTechnologyRequest: jest.fn(), | ||
| getTag: jest.fn(), | ||
| setAlertMessage: jest.fn(), | ||
| sendMifareCommand: jest.fn(), | ||
| sendCommandAPDU: jest.fn(), | ||
| transceive: jest.fn(), | ||
| getMaxTransceiveLength: jest.fn(), | ||
| setTimeout: jest.fn(), | ||
| connect: jest.fn(), | ||
| close: jest.fn(), | ||
| cleanUpTag: jest.fn(), | ||
| default: { | ||
| start: jest.fn(), | ||
| isSupported: jest.fn().mockResolvedValue(true), | ||
| isEnabled: jest.fn().mockResolvedValue(true), | ||
| registerTagEvent: jest.fn(), | ||
| unregisterTagEvent: jest.fn(), | ||
| requestTechnology: jest.fn(), | ||
| cancelTechnologyRequest: jest.fn(), | ||
| getTag: jest.fn(), | ||
| setAlertMessage: jest.fn(), | ||
| sendMifareCommand: jest.fn(), | ||
| sendCommandAPDU: jest.fn(), | ||
| transceive: jest.fn(), | ||
| getMaxTransceiveLength: jest.fn(), | ||
| setTimeout: jest.fn(), | ||
| connect: jest.fn(), | ||
| close: jest.fn(), | ||
| cleanUpTag: jest.fn(), | ||
| }, | ||
| })); | ||
|
|
||
| // Mock react-native-passport-reader | ||
| jest.mock('react-native-passport-reader', () => ({ | ||
| default: { | ||
| initialize: jest.fn(), | ||
| scanPassport: jest.fn(), | ||
| readPassport: jest.fn(), | ||
| cancelPassportRead: jest.fn(), | ||
| }, | ||
| })); | ||
|
|
||
| // Mock @stablelib packages | ||
| jest.mock('@stablelib/cbor', () => ({ | ||
| encode: jest.fn(), | ||
| decode: jest.fn(), | ||
| })); | ||
|
|
||
| jest.mock('@stablelib/utf8', () => ({ | ||
| encode: jest.fn(), | ||
| decode: jest.fn(), | ||
| })); | ||
|
|
||
| // Mock @react-native-google-signin/google-signin | ||
| jest.mock('@react-native-google-signin/google-signin', () => ({ | ||
| GoogleSignin: { | ||
| configure: jest.fn(), | ||
| hasPlayServices: jest.fn().mockResolvedValue(true), | ||
| signIn: jest.fn().mockResolvedValue({ | ||
| user: { | ||
| id: 'mock-user-id', | ||
| email: '[email protected]', | ||
| name: 'Mock User', | ||
| photo: 'mock-photo-url', | ||
| }, | ||
| }), | ||
| signOut: jest.fn(), | ||
| revokeAccess: jest.fn(), | ||
| isSignedIn: jest.fn().mockResolvedValue(false), | ||
| getCurrentUser: jest.fn().mockResolvedValue(null), | ||
| getTokens: jest.fn().mockResolvedValue({ | ||
| accessToken: 'mock-access-token', | ||
| idToken: 'mock-id-token', | ||
| }), | ||
| }, | ||
| statusCodes: { | ||
| SIGN_IN_REQUIRED: 'SIGN_IN_REQUIRED', | ||
| IN_PROGRESS: 'IN_PROGRESS', | ||
| PLAY_SERVICES_NOT_AVAILABLE: 'PLAY_SERVICES_NOT_AVAILABLE', | ||
| }, | ||
| })); | ||
|
|
||
| // Mock react-native-cloud-storage | ||
| jest.mock('react-native-cloud-storage', () => { | ||
| const mockCloudStorage = { | ||
| setProviderOptions: jest.fn(), | ||
| isCloudAvailable: jest.fn().mockResolvedValue(true), | ||
| createFolder: jest.fn(), | ||
| deleteFolder: jest.fn(), | ||
| listFiles: jest.fn(), | ||
| readFile: jest.fn(), | ||
| writeFile: jest.fn(), | ||
| deleteFile: jest.fn(), | ||
| getFileInfo: jest.fn(), | ||
| getStorageInfo: jest.fn(), | ||
| getProvider: jest.fn(), | ||
| mkdir: jest.fn(), | ||
| exists: jest.fn(), | ||
| rmdir: jest.fn(), | ||
| }; | ||
|
|
||
| return { | ||
| __esModule: true, | ||
| CloudStorage: mockCloudStorage, | ||
| CloudStorageScope: { | ||
| AppData: 'AppData', | ||
| Documents: 'Documents', | ||
| Full: 'Full', | ||
| }, | ||
| CloudStorageProvider: { | ||
| GoogleDrive: 'GoogleDrive', | ||
| ICloud: 'ICloud', | ||
| }, | ||
| }; | ||
| }); | ||
|
|
||
| // Mock @react-native-clipboard/clipboard | ||
| jest.mock('@react-native-clipboard/clipboard', () => ({ | ||
| getString: jest.fn().mockResolvedValue(''), | ||
| setString: jest.fn(), | ||
| hasString: jest.fn().mockResolvedValue(false), | ||
| })); | ||
|
|
||
| // Mock react-native-localize | ||
| jest.mock('react-native-localize', () => ({ | ||
| getLocales: jest.fn().mockReturnValue([ | ||
| { | ||
| countryCode: 'US', | ||
| languageTag: 'en-US', | ||
| languageCode: 'en', | ||
| isRTL: false, | ||
| }, | ||
| ]), | ||
| getCountry: jest.fn().mockReturnValue('US'), | ||
| getTimeZone: jest.fn().mockReturnValue('America/New_York'), | ||
| getCurrencies: jest.fn().mockReturnValue(['USD']), | ||
| getTemperatureUnit: jest.fn().mockReturnValue('celsius'), | ||
| getFirstWeekDay: jest.fn().mockReturnValue(0), | ||
| uses24HourClock: jest.fn().mockReturnValue(false), | ||
| usesMetricSystem: jest.fn().mockReturnValue(false), | ||
| findBestAvailableLanguage: jest.fn().mockReturnValue({ | ||
| languageTag: 'en-US', | ||
| isRTL: 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
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dupe file. similar to navigation/recovery |
This file was deleted.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need all these react native mocks for the navigation test to pass