Skip to content

Commit

Permalink
app navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
lcflight committed Dec 1, 2023
1 parent 78e97a2 commit 3cc4bc8
Show file tree
Hide file tree
Showing 13 changed files with 818 additions and 20 deletions.
2 changes: 2 additions & 0 deletions __mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// __mocks__/fileMock.js
module.exports = '';
6 changes: 6 additions & 0 deletions __mocks__/react-native-gesture-handler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// __mocks__/react-native-gesture-handler.js
jest.mock('react-native-gesture-handler', () => {
return {
// Add the properties and methods you want to mock here
};
});
32 changes: 32 additions & 0 deletions __mocks__/react-native-screens.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
jest.mock('react-native-screens', () => {
const RealComponent = jest.requireActual('react-native-screens');
const React = require('react');
const {View} = require('react-native');

class Screen extends React.Component {
render() {
return React.createElement(View, this.props, this.props.children);
}
}

if (RealComponent.Screen) {
Screen.propTypes = RealComponent.Screen.propTypes;
}

class ScreenContainer extends React.Component {
render() {
return React.createElement(View, this.props, this.props.children);
}
}

if (RealComponent.ScreenContainer) {
ScreenContainer.propTypes = RealComponent.ScreenContainer.propTypes;
}

return {
...RealComponent,
enableScreens: jest.fn(),
Screen,
ScreenContainer,
};
});
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
* @format
*/

import {gestureHandlerRootHOC} from 'react-native-gesture-handler';
import {AppRegistry} from 'react-native';
import App from './src/App';
import {name as appName} from './app.json';

AppRegistry.registerComponent(appName, () => App);
AppRegistry.registerComponent(appName, () => gestureHandlerRootHOC(App));
20 changes: 20 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ PODS:
- React-jsinspector (0.72.7)
- React-logger (0.72.7):
- glog
- react-native-safe-area-context (4.7.4):
- React-Core
- React-NativeModulesApple (0.72.7):
- hermes-engine
- React-callinvoker
Expand Down Expand Up @@ -485,6 +487,12 @@ PODS:
- React-jsi (= 0.72.7)
- React-logger (= 0.72.7)
- React-perflogger (= 0.72.7)
- RNGestureHandler (2.14.0):
- RCT-Folly (= 2021.07.22.00)
- React-Core
- RNScreens (3.27.0):
- RCT-Folly (= 2021.07.22.00)
- React-Core
- RNVectorIcons (10.0.2):
- RCT-Folly (= 2021.07.22.00)
- React-Core
Expand Down Expand Up @@ -539,6 +547,7 @@ DEPENDENCIES:
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
- React-NativeModulesApple (from `../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios`)
- React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
- React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`)
Expand All @@ -556,6 +565,8 @@ DEPENDENCIES:
- React-runtimescheduler (from `../node_modules/react-native/ReactCommon/react/renderer/runtimescheduler`)
- React-utils (from `../node_modules/react-native/ReactCommon/react/utils`)
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
- RNScreens (from `../node_modules/react-native-screens`)
- RNVectorIcons (from `../node_modules/react-native-vector-icons`)
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)

Expand Down Expand Up @@ -620,6 +631,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/jsinspector"
React-logger:
:path: "../node_modules/react-native/ReactCommon/logger"
react-native-safe-area-context:
:path: "../node_modules/react-native-safe-area-context"
React-NativeModulesApple:
:path: "../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios"
React-perflogger:
Expand Down Expand Up @@ -654,6 +667,10 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/react/utils"
ReactCommon:
:path: "../node_modules/react-native/ReactCommon"
RNGestureHandler:
:path: "../node_modules/react-native-gesture-handler"
RNScreens:
:path: "../node_modules/react-native-screens"
RNVectorIcons:
:path: "../node_modules/react-native-vector-icons"
Yoga:
Expand Down Expand Up @@ -693,6 +710,7 @@ SPEC CHECKSUMS:
React-jsiexecutor: c49502e5d02112247ee4526bc3ccfc891ae3eb9b
React-jsinspector: 8baadae51f01d867c3921213a25ab78ab4fbcd91
React-logger: 8edc785c47c8686c7962199a307015e2ce9a0e4f
react-native-safe-area-context: 2cd91d532de12acdb0a9cbc8d43ac72a8e4c897c
React-NativeModulesApple: b6868ee904013a7923128892ee4a032498a1024a
React-perflogger: 31ea61077185eb1428baf60c0db6e2886f141a5a
React-RCTActionSheet: 392090a3abc8992eb269ef0eaa561750588fc39d
Expand All @@ -710,6 +728,8 @@ SPEC CHECKSUMS:
React-runtimescheduler: 7649c3b46c8dee1853691ecf60146a16ae59253c
React-utils: 56838edeaaf651220d1e53cd0b8934fb8ce68415
ReactCommon: 5f704096ccf7733b390f59043b6fa9cc180ee4f6
RNGestureHandler: 32a01c29ecc9bb0b5bf7bc0a33547f61b4dc2741
RNScreens: 3c2d122f5e08c192e254c510b212306da97d2581
RNVectorIcons: 23b6e11af4aaf104d169b1b0afa7e5cf96c676ce
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Yoga: 4c3aa327e4a6a23eeacd71f61c81df1bcdf677d5
Expand Down
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
module.exports = {
preset: 'react-native',
moduleNameMapper: {
// Match all files ending in `.png` or other image formats if needed
'\\.(png)$': '<rootDir>/__mocks__/fileMock.js',
},
setupFilesAfterEnv: ['./jest.setup.js'],
};
15 changes: 15 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
jest.mock('react-native-screens', () => ({
enableScreens: jest.fn(),
}));

jest.mock('@react-navigation/native', () => ({
...jest.requireActual('@react-navigation/native'),
NavigationContainer: () => <div />,
}));

jest.mock('@react-navigation/stack', () => ({
createStackNavigator: jest.fn(() => ({
Screen: jest.fn(),
Navigator: jest.fn(),
})),
}));
Loading

0 comments on commit 3cc4bc8

Please sign in to comment.