@tamagui/fake-react-native 2.0.0-1768636514428 → 2.0.0-1768699687560
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +30 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
|
+
const React = require('react')
|
|
2
|
+
|
|
3
|
+
// Create mock RN components that render as simple divs/spans for testing
|
|
4
|
+
// react-test-renderer will serialize these properly
|
|
5
|
+
const createMockComponent = (name) => {
|
|
6
|
+
const Component = React.forwardRef((props, ref) => {
|
|
7
|
+
const { children, style, ...rest } = props
|
|
8
|
+
// Return a "View" element that react-test-renderer understands
|
|
9
|
+
return React.createElement(name, { ...rest, style, ref }, children)
|
|
10
|
+
})
|
|
11
|
+
Component.displayName = name
|
|
12
|
+
return Component
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// For components that don't need to render (like Image)
|
|
1
16
|
const emtpyComponent = () => null
|
|
2
17
|
|
|
18
|
+
// Mock usePressability for testing - returns empty event handlers
|
|
19
|
+
const usePressabilityMock = () => ({})
|
|
20
|
+
|
|
3
21
|
function proxyWorm() {
|
|
4
22
|
return new Proxy(
|
|
5
23
|
{
|
|
@@ -10,10 +28,10 @@ function proxyWorm() {
|
|
|
10
28
|
OS: 'web',
|
|
11
29
|
},
|
|
12
30
|
Image: emtpyComponent,
|
|
13
|
-
View:
|
|
14
|
-
Text:
|
|
15
|
-
TextInput:
|
|
16
|
-
ScrollView:
|
|
31
|
+
View: createMockComponent('View'),
|
|
32
|
+
Text: createMockComponent('Text'),
|
|
33
|
+
TextInput: createMockComponent('TextInput'),
|
|
34
|
+
ScrollView: createMockComponent('ScrollView'),
|
|
17
35
|
Dimensions: {
|
|
18
36
|
addEventListener(cb) {},
|
|
19
37
|
},
|
|
@@ -23,6 +41,14 @@ function proxyWorm() {
|
|
|
23
41
|
removeChangeListener: () => {},
|
|
24
42
|
},
|
|
25
43
|
addPoolingTo() {},
|
|
44
|
+
// Libraries/Pressability/usePressability mock
|
|
45
|
+
Libraries: {
|
|
46
|
+
Pressability: {
|
|
47
|
+
usePressability: {
|
|
48
|
+
default: usePressabilityMock,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
26
52
|
},
|
|
27
53
|
{
|
|
28
54
|
get(target, key) {
|