Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Commit

Permalink
add mock, fixup: useAnimatedValue() and remove proc
Browse files Browse the repository at this point in the history
  • Loading branch information
andy committed Nov 12, 2019
1 parent e33c998 commit 4733271
Show file tree
Hide file tree
Showing 4 changed files with 251 additions and 69 deletions.
2 changes: 1 addition & 1 deletion example/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const App = () => {
<View
style={{flex: 1, backgroundColor: 'white', justifyContent: 'center'}}>
<PagerProvider activeIndex={activeIndex} onChange={onChange}>
<KilterCards />
<VerticalPager />
</PagerProvider>
</View>
</SafeAreaView>
Expand Down
65 changes: 65 additions & 0 deletions mock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
jest.mock('react-native-reanimated', () => {
const React = require('react');

const View = require('react-native/Libraries/Components/View/View');
const mock = require('react-native-reanimated/mock');

mock.default.Value = function() {
return {
setValue: function() {},
};
};

function MockView(props) {
React.useEffect(() => {
props.onLayout &&
props.onLayout({
nativeEvent: { layout: { width: 100, height: 100 } },
});
}, []);

return React.createElement(View, props, props.children);
}

mock.default.View = MockView;

mock.default.useCode = function() {};

return mock;
});

jest.mock('react-native-gesture-handler', () => {
const View = require('react-native/Libraries/Components/View/View');
const TouchableOpacity = require('react-native/Libraries/Components/Touchable/TouchableOpacity');
return {
Swipeable: View,
DrawerLayout: View,
State: {},
ScrollView: View,
Slider: View,
Switch: View,
TextInput: View,
ToolbarAndroid: View,
ViewPagerAndroid: View,
DrawerLayoutAndroid: View,
WebView: View,
NativeViewGestureHandler: View,
TapGestureHandler: View,
FlingGestureHandler: View,
ForceTouchGestureHandler: View,
LongPressGestureHandler: View,
PanGestureHandler: View,
PinchGestureHandler: View,
RotationGestureHandler: View,
/* Buttons */
RawButton: View,
BaseButton: View,
RectButton: View,
BorderlessButton: View,
TouchableOpacity: TouchableOpacity,
/* Other */
FlatList: View,
gestureHandlerRootHOC: jest.fn(),
Directions: {},
};
});
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"typings": "dist/index.d.ts",
"author": "andrew smith",
"files": [
"dist"
"dist",
"mock.js"
],
"repository": {
"type": "git",
Expand Down
Loading

0 comments on commit 4733271

Please sign in to comment.