|
1 | 1 | /* eslint-disable sort-keys */
|
2 |
| -import { PropsWithChildren, ReactNode, createElement } from "react"; |
3 |
| -import { ScrollView, View, requireNativeComponent } from "react-native"; |
| 2 | +import { ElementRef, PropsWithChildren, ReactNode, createElement } from "react"; |
| 3 | +import { HostComponent, NativeMethods, ScrollView, View, requireNativeComponent } from "react-native"; |
4 | 4 |
|
5 | 5 | import { noop } from "../../helpers/commons";
|
6 | 6 | import { mockComponent } from "../../helpers/mockComponent";
|
7 |
| -import { MockNativeMethods } from "../../helpers/mockNativeMethods"; |
| 7 | +import { nativeMethodsMock } from "../../helpers/nativeMethodsMock"; |
8 | 8 |
|
9 |
| -const RCTScrollView = requireNativeComponent("RCTScrollView"); |
10 |
| -const BaseMock = mockComponent(ScrollView, { |
11 |
| - ...MockNativeMethods, |
12 |
| - getScrollResponder: noop, |
| 9 | +export type ScrollViewMethods = NativeMethods | ScrollView & { |
| 10 | + getInnerViewRef: () => ElementRef<typeof View> | null; |
| 11 | + getNativeScrollRef: () => ElementRef<HostComponent<unknown>> | null; |
| 12 | +}; |
| 13 | + |
| 14 | +export const scrollViewMethodsMock: ScrollViewMethods = { |
| 15 | + ...nativeMethodsMock, |
| 16 | + getScrollResponder: () => ({ |
| 17 | + addListenerOn: noop, |
| 18 | + componentWillMount: noop, |
| 19 | + scrollResponderGetScrollableNode: noop, |
| 20 | + scrollResponderHandleMomentumScrollBegin: noop, |
| 21 | + scrollResponderHandleMomentumScrollEnd: noop, |
| 22 | + scrollResponderHandleResponderGrant: noop, |
| 23 | + scrollResponderHandleResponderReject: noop, |
| 24 | + scrollResponderHandleResponderRelease: noop, |
| 25 | + scrollResponderHandleScroll: noop, |
| 26 | + scrollResponderHandleScrollBeginDrag: noop, |
| 27 | + scrollResponderHandleScrollEndDrag: noop, |
| 28 | + scrollResponderHandleScrollShouldSetResponder: () => false, |
| 29 | + scrollResponderHandleStartShouldSetResponder: () => false, |
| 30 | + scrollResponderHandleStartShouldSetResponderCapture: () => false, |
| 31 | + scrollResponderHandleTerminationRequest: () => false, |
| 32 | + scrollResponderHandleTouchEnd: noop, |
| 33 | + scrollResponderHandleTouchMove: noop, |
| 34 | + scrollResponderHandleTouchStart: noop, |
| 35 | + scrollResponderInputMeasureAndScrollToKeyboard: noop, |
| 36 | + scrollResponderIsAnimating: () => false, |
| 37 | + scrollResponderKeyboardDidHide: noop, |
| 38 | + scrollResponderKeyboardDidShow: noop, |
| 39 | + scrollResponderKeyboardWillHide: noop, |
| 40 | + scrollResponderKeyboardWillShow: noop, |
| 41 | + scrollResponderScrollNativeHandleToKeyboard: noop, |
| 42 | + scrollResponderScrollTo: noop, |
| 43 | + scrollResponderTextInputFocusError: noop, |
| 44 | + scrollResponderZoomTo: noop, |
| 45 | + }), |
13 | 46 | getScrollableNode: noop,
|
14 | 47 | getInnerViewNode: noop,
|
15 |
| - getInnerViewRef: noop, |
16 |
| - getNativeScrollRef: noop, |
| 48 | + getInnerViewRef: () => null, |
| 49 | + getNativeScrollRef: () => null, |
17 | 50 | scrollTo: noop,
|
18 | 51 | scrollToEnd: noop,
|
19 | 52 | flashScrollIndicators: noop,
|
20 | 53 | scrollResponderZoomTo: noop,
|
21 | 54 | scrollResponderScrollNativeHandleToKeyboard: noop,
|
22 |
| -}); |
| 55 | + |
| 56 | +}; |
| 57 | + |
| 58 | +const RCTScrollView = requireNativeComponent("RCTScrollView"); |
| 59 | +const BaseMock = mockComponent(ScrollView, scrollViewMethodsMock); |
23 | 60 |
|
24 | 61 | export class ScrollViewMock<P> extends BaseMock {
|
25 | 62 |
|
|
0 commit comments