@terreno/ui 0.30.0 → 0.31.0

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.
@@ -0,0 +1,339 @@
1
+ import {afterAll, beforeEach, describe, expect, it, mock} from "bun:test";
2
+ import {fireEvent} from "@testing-library/react-native";
3
+ import React, {type ReactNode} from "react";
4
+ import {View} from "react-native";
5
+
6
+ import type {SidebarNavigationItem} from "./Common";
7
+ import {renderWithTheme} from "./test-utils";
8
+
9
+ interface MockChildrenProps {
10
+ children?: ReactNode;
11
+ }
12
+
13
+ interface NavigatorContext {
14
+ state: {index: number; routes: {key: string; name: string}[]};
15
+ navigation: {navigate: (route: string) => void};
16
+ descriptors: Record<string, {options: Record<string, unknown>}>;
17
+ }
18
+
19
+ const navigate = mock((_route: string) => {});
20
+
21
+ let navigatorContext: NavigatorContext = {
22
+ descriptors: {},
23
+ navigation: {navigate},
24
+ state: {index: 0, routes: [{key: "home-key", name: "index"}]},
25
+ };
26
+
27
+ // bunSetup.ts mocks expo-router without Navigator.useContext, which
28
+ // SidebarNavigatorContent depends on. Restored in afterAll to avoid leaking
29
+ // into other test files.
30
+ mock.module("expo-router", () => ({
31
+ Link: ({children, ...props}: MockChildrenProps) => React.createElement("Link", props, children),
32
+ Navigator: Object.assign(
33
+ ({children, ...props}: MockChildrenProps) => React.createElement("Navigator", props, children),
34
+ {useContext: () => navigatorContext}
35
+ ),
36
+ router: {
37
+ back: mock(() => {}),
38
+ canGoBack: mock(() => true),
39
+ navigate: mock(() => {}),
40
+ push: mock(() => {}),
41
+ replace: mock(() => {}),
42
+ },
43
+ Slot: ({children, ...props}: MockChildrenProps) => React.createElement("Slot", props, children),
44
+ Stack: ({children, ...props}: MockChildrenProps) => React.createElement("Stack", props, children),
45
+ Tabs: ({children, ...props}: MockChildrenProps) => React.createElement("Tabs", props, children),
46
+ useLocalSearchParams: mock(() => ({})),
47
+ useRouter: mock(() => ({
48
+ back: mock(() => {}),
49
+ canGoBack: mock(() => true),
50
+ navigate: mock(() => {}),
51
+ push: mock(() => {}),
52
+ replace: mock(() => {}),
53
+ })),
54
+ useSegments: mock(() => []),
55
+ }));
56
+
57
+ import {SidebarNavigation, SidebarNavigationPanel} from "./SidebarNavigation";
58
+
59
+ afterAll(() => {
60
+ mock.module("expo-router", () => ({
61
+ Link: ({children, ...props}: MockChildrenProps) => React.createElement("Link", props, children),
62
+ Navigator: ({children, ...props}: MockChildrenProps) =>
63
+ React.createElement("Navigator", props, children),
64
+ router: {
65
+ back: mock(() => {}),
66
+ canGoBack: mock(() => true),
67
+ navigate: mock(() => {}),
68
+ push: mock(() => {}),
69
+ replace: mock(() => {}),
70
+ },
71
+ Slot: ({children, ...props}: MockChildrenProps) => React.createElement("Slot", props, children),
72
+ Stack: ({children, ...props}: MockChildrenProps) =>
73
+ React.createElement("Stack", props, children),
74
+ Tabs: ({children, ...props}: MockChildrenProps) => React.createElement("Tabs", props, children),
75
+ useLocalSearchParams: mock(() => ({})),
76
+ useRouter: mock(() => ({
77
+ back: mock(() => {}),
78
+ canGoBack: mock(() => true),
79
+ navigate: mock(() => {}),
80
+ push: mock(() => {}),
81
+ replace: mock(() => {}),
82
+ })),
83
+ useSegments: mock(() => []),
84
+ }));
85
+ });
86
+
87
+ const topItems: SidebarNavigationItem[] = [
88
+ {iconName: "house", label: "Home", route: "index"},
89
+ {badge: 5, iconName: "bell", label: "Alerts", route: "alerts"},
90
+ {badge: true, badgeStatus: "info", iconName: "envelope", label: "Inbox", route: "inbox"},
91
+ ];
92
+
93
+ const bottomItems: SidebarNavigationItem[] = [
94
+ {iconName: "gear", label: "Settings", route: "settings"},
95
+ ];
96
+
97
+ describe("SidebarNavigationPanel", () => {
98
+ it("renders every top and bottom item", () => {
99
+ const onNavigate = mock((_route: string) => {});
100
+ const {getByLabelText} = renderWithTheme(
101
+ <SidebarNavigationPanel
102
+ activeRoute="index"
103
+ bottomItems={bottomItems}
104
+ onNavigate={onNavigate}
105
+ topItems={topItems}
106
+ />
107
+ );
108
+
109
+ for (const item of [...topItems, ...bottomItems]) {
110
+ expect(getByLabelText(item.label)).toBeTruthy();
111
+ }
112
+ });
113
+
114
+ it("renders children next to the rail", () => {
115
+ const {getByTestId} = renderWithTheme(
116
+ <SidebarNavigationPanel
117
+ activeRoute="index"
118
+ bottomItems={bottomItems}
119
+ onNavigate={mock((_route: string) => {})}
120
+ topItems={topItems}
121
+ >
122
+ <View testID="panel-child" />
123
+ </SidebarNavigationPanel>
124
+ );
125
+
126
+ expect(getByTestId("panel-child")).toBeTruthy();
127
+ });
128
+
129
+ it("calls onNavigate with the pressed item route", () => {
130
+ const onNavigate = mock((_route: string) => {});
131
+ const {getByLabelText} = renderWithTheme(
132
+ <SidebarNavigationPanel
133
+ activeRoute="index"
134
+ bottomItems={bottomItems}
135
+ onNavigate={onNavigate}
136
+ topItems={topItems}
137
+ />
138
+ );
139
+
140
+ fireEvent.press(getByLabelText("Settings"));
141
+ expect(onNavigate).toHaveBeenCalledWith("settings");
142
+ });
143
+
144
+ it("hides labels while collapsed and shows them once hovered", () => {
145
+ const {UNSAFE_getAllByType, queryByText, getByText} = renderWithTheme(
146
+ <SidebarNavigationPanel
147
+ activeRoute="index"
148
+ bottomItems={bottomItems}
149
+ onNavigate={mock((_route: string) => {})}
150
+ topItems={topItems}
151
+ />
152
+ );
153
+
154
+ expect(queryByText("Home")).toBeNull();
155
+
156
+ const rail = UNSAFE_getAllByType(View).find(
157
+ (node) => node.props.onMouseEnter !== undefined && node.props.onMouseLeave !== undefined
158
+ );
159
+ if (!rail) {
160
+ throw new Error("expected the sidebar rail to expose hover handlers");
161
+ }
162
+
163
+ fireEvent(rail, "mouseEnter");
164
+ expect(getByText("Home")).toBeTruthy();
165
+ expect(getByText("Settings")).toBeTruthy();
166
+
167
+ fireEvent(rail, "mouseLeave");
168
+ expect(queryByText("Home")).toBeNull();
169
+ });
170
+
171
+ it("bolds the active label and leaves inactive labels unbolded", () => {
172
+ const {UNSAFE_getAllByType, getByText} = renderWithTheme(
173
+ <SidebarNavigationPanel
174
+ activeRoute="alerts"
175
+ bottomItems={bottomItems}
176
+ onNavigate={mock((_route: string) => {})}
177
+ topItems={topItems}
178
+ />
179
+ );
180
+
181
+ const rail = UNSAFE_getAllByType(View).find((node) => node.props.onMouseEnter !== undefined);
182
+ if (!rail) {
183
+ throw new Error("expected the sidebar rail to expose hover handlers");
184
+ }
185
+ fireEvent(rail, "mouseEnter");
186
+
187
+ const fontFamilyOf = (label: string): unknown =>
188
+ Object.assign(
189
+ {},
190
+ ...(Array.isArray(getByText(label).props.style)
191
+ ? getByText(label).props.style.flat(Number.POSITIVE_INFINITY)
192
+ : [getByText(label).props.style])
193
+ ).fontFamily;
194
+
195
+ expect(fontFamilyOf("Alerts")).not.toBe(fontFamilyOf("Home"));
196
+ expect(String(fontFamilyOf("Alerts"))).toContain("bold");
197
+ });
198
+
199
+ it("applies hover styling to individual items", () => {
200
+ const {getByLabelText} = renderWithTheme(
201
+ <SidebarNavigationPanel
202
+ activeRoute="index"
203
+ bottomItems={bottomItems}
204
+ onNavigate={mock((_route: string) => {})}
205
+ topItems={topItems}
206
+ />
207
+ );
208
+
209
+ const item = getByLabelText("Alerts");
210
+ const flatten = (style: unknown): Record<string, unknown> =>
211
+ Object.assign({}, ...(Array.isArray(style) ? style : [style]));
212
+
213
+ const initialBackground = flatten(item.props.style).backgroundColor;
214
+ fireEvent(item, "hoverIn");
215
+ expect(flatten(getByLabelText("Alerts").props.style).backgroundColor).not.toBe(
216
+ initialBackground
217
+ );
218
+
219
+ fireEvent(item, "hoverOut");
220
+ expect(flatten(getByLabelText("Alerts").props.style).backgroundColor).toBe(initialBackground);
221
+ });
222
+
223
+ it("applies custom panel and item styles", () => {
224
+ const {getByLabelText, UNSAFE_getAllByType} = renderWithTheme(
225
+ <SidebarNavigationPanel
226
+ activeRoute="index"
227
+ bottomItems={bottomItems}
228
+ itemStyle={{opacity: 0.5}}
229
+ onNavigate={mock((_route: string) => {})}
230
+ panelStyle={{borderRightWidth: 4}}
231
+ topItems={topItems}
232
+ />
233
+ );
234
+
235
+ const rail = UNSAFE_getAllByType(View).find((node) => node.props.onMouseEnter !== undefined);
236
+ expect(rail?.props.style).toContainEqual({borderRightWidth: 4});
237
+ expect(getByLabelText("Home").props.style).toContainEqual({opacity: 0.5});
238
+ });
239
+ });
240
+
241
+ describe("SidebarNavigation", () => {
242
+ beforeEach(() => {
243
+ navigate.mockClear();
244
+ navigatorContext = {
245
+ descriptors: {},
246
+ navigation: {navigate},
247
+ state: {index: 0, routes: [{key: "home-key", name: "index"}]},
248
+ };
249
+ });
250
+
251
+ it("exposes Screen for per-screen options", () => {
252
+ expect(SidebarNavigation.Screen).toBeDefined();
253
+ });
254
+
255
+ it("renders the sidebar for the active navigator route", () => {
256
+ const {getByLabelText} = renderWithTheme(
257
+ <SidebarNavigation bottomItems={bottomItems} topItems={topItems} />
258
+ );
259
+
260
+ expect(getByLabelText("Home")).toBeTruthy();
261
+ expect(getByLabelText("Settings")).toBeTruthy();
262
+ });
263
+
264
+ it("navigates through the navigator and forwards the route to onNavigate", () => {
265
+ const onNavigate = mock((_route: string) => {});
266
+ const {getByLabelText} = renderWithTheme(
267
+ <SidebarNavigation bottomItems={bottomItems} onNavigate={onNavigate} topItems={topItems} />
268
+ );
269
+
270
+ fireEvent.press(getByLabelText("Alerts"));
271
+ expect(navigate).toHaveBeenCalledWith("alerts");
272
+ expect(onNavigate).toHaveBeenCalledWith("alerts");
273
+ });
274
+
275
+ it("navigates without an onNavigate callback", () => {
276
+ const {getByLabelText} = renderWithTheme(
277
+ <SidebarNavigation bottomItems={bottomItems} topItems={topItems} />
278
+ );
279
+
280
+ fireEvent.press(getByLabelText("Inbox"));
281
+ expect(navigate).toHaveBeenCalledWith("inbox");
282
+ });
283
+
284
+ it("renders the header with the screen title and header slots", () => {
285
+ navigatorContext = {
286
+ descriptors: {
287
+ "home-key": {
288
+ options: {
289
+ headerLeft: () => <View testID="header-left" />,
290
+ headerRight: () => <View testID="header-right" />,
291
+ title: "Dashboard",
292
+ },
293
+ },
294
+ },
295
+ navigation: {navigate},
296
+ state: {index: 0, routes: [{key: "home-key", name: "index"}]},
297
+ };
298
+
299
+ const {getByTestId, getByText} = renderWithTheme(
300
+ <SidebarNavigation bottomItems={bottomItems} topItems={topItems} />
301
+ );
302
+
303
+ expect(getByText("Dashboard")).toBeTruthy();
304
+ expect(getByTestId("header-left")).toBeTruthy();
305
+ expect(getByTestId("header-right")).toBeTruthy();
306
+ });
307
+
308
+ it("omits the header when the active screen has no title or header slots", () => {
309
+ const {queryByText} = renderWithTheme(
310
+ <SidebarNavigation bottomItems={bottomItems} topItems={topItems} />
311
+ );
312
+
313
+ expect(queryByText("Dashboard")).toBeNull();
314
+ });
315
+
316
+ it("renders Screen children passed to the navigator", () => {
317
+ const {getByTestId} = renderWithTheme(
318
+ <SidebarNavigation bottomItems={bottomItems} topItems={topItems}>
319
+ <View testID="screen-child" />
320
+ </SidebarNavigation>
321
+ );
322
+
323
+ expect(getByTestId("screen-child")).toBeTruthy();
324
+ });
325
+
326
+ it("handles an empty navigator route list", () => {
327
+ navigatorContext = {
328
+ descriptors: {},
329
+ navigation: {navigate},
330
+ state: {index: 0, routes: []},
331
+ };
332
+
333
+ const {getByLabelText} = renderWithTheme(
334
+ <SidebarNavigation bottomItems={bottomItems} topItems={topItems} />
335
+ );
336
+
337
+ expect(getByLabelText("Home")).toBeTruthy();
338
+ });
339
+ });
@@ -1,6 +1,4 @@
1
- // noExplicitAny: test mock typing
2
- // biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
3
- import {describe, expect, it, mock} from "bun:test";
1
+ import {describe, expect, it, mock, spyOn} from "bun:test";
4
2
  import {act, fireEvent} from "@testing-library/react-native";
5
3
  import {Linking} from "react-native";
6
4
 
@@ -141,9 +139,7 @@ describe("TapToEdit", () => {
141
139
  });
142
140
 
143
141
  it("invokes Linking.openURL for url type when clicked", async () => {
144
- const originalOpen = Linking.openURL;
145
- const openMock = mock(() => Promise.resolve(true));
146
- (Linking as any).openURL = openMock;
142
+ const openURLSpy = spyOn(Linking, "openURL").mockImplementation(() => Promise.resolve(true));
147
143
 
148
144
  const {getByLabelText} = renderWithTheme(
149
145
  <TapToEdit editable={false} title="Site" type="url" value="https://example.com" />
@@ -152,15 +148,13 @@ describe("TapToEdit", () => {
152
148
  await act(async () => {
153
149
  fireEvent.press(getByLabelText("Link"));
154
150
  });
155
- expect(openMock).toHaveBeenCalled();
151
+ expect(openURLSpy).toHaveBeenCalled();
156
152
 
157
- (Linking as any).openURL = originalOpen;
153
+ openURLSpy.mockRestore();
158
154
  });
159
155
 
160
156
  it("invokes Linking.openURL with google maps for address type when clicked", async () => {
161
- const originalOpen = Linking.openURL;
162
- const openMock = mock(() => Promise.resolve(true));
163
- (Linking as any).openURL = openMock;
157
+ const openURLSpy = spyOn(Linking, "openURL").mockImplementation(() => Promise.resolve(true));
164
158
 
165
159
  const {getByLabelText} = renderWithTheme(
166
160
  <TapToEdit
@@ -174,11 +168,11 @@ describe("TapToEdit", () => {
174
168
  await act(async () => {
175
169
  fireEvent.press(getByLabelText("Link"));
176
170
  });
177
- expect(openMock).toHaveBeenCalled();
178
- const arg = openMock.mock.calls[0][0];
171
+ expect(openURLSpy).toHaveBeenCalled();
172
+ const arg = openURLSpy.mock.calls[0][0];
179
173
  expect(arg).toContain("google.com/maps");
180
174
 
181
- (Linking as any).openURL = originalOpen;
175
+ openURLSpy.mockRestore();
182
176
  });
183
177
 
184
178
  it("throws when editable is true and setValue is not provided", () => {
package/src/Theme.tsx CHANGED
@@ -137,6 +137,7 @@ const defaultTheme: TerrenoThemeConfig = {
137
137
  primary: "primary400",
138
138
  secondaryDark: "secondary500",
139
139
  secondaryExtraDark: "secondary800",
140
+ secondaryExtraLight: "secondary000",
140
141
  secondaryLight: "secondary100",
141
142
  success: "success200",
142
143
  successLight: "success000",
@@ -775,6 +775,7 @@ describe("Tooltip", () => {
775
775
  const wrapper = (treeAfter.children as TestNode[]).find(
776
776
  (c: TestNode) => c.props && (c.props as {hitSlop?: object}).hitSlop !== undefined
777
777
  ) as TestNode | undefined;
778
+ expect(wrapper).toBeTruthy();
778
779
  await act(async () => {
779
780
  (wrapper?.props as {onPress?: () => void} | undefined)?.onPress?.();
780
781
  });
@@ -444,3 +444,4 @@ exports[`Card display variant renders image when imageUri is provided 1`] = `
444
444
  "type": "View",
445
445
  }
446
446
  `;
447
+
@@ -0,0 +1,242 @@
1
+ // Bun Snapshot v1, https://bun.sh/docs/test/snapshots
2
+
3
+ exports[`EditableCard renders correctly with all props 1`] = `
4
+ {
5
+ "$$typeof": Symbol(react.test.json),
6
+ "children": [
7
+ {
8
+ "$$typeof": Symbol(react.test.json),
9
+ "children": null,
10
+ "props": {
11
+ "onPointerEnter": [Function: AsyncFunction],
12
+ "onPointerLeave": [Function: AsyncFunction],
13
+ "style": {
14
+ "paddingBottom": 4,
15
+ "paddingTop": 4,
16
+ },
17
+ "testID": undefined,
18
+ },
19
+ "type": "View",
20
+ },
21
+ {
22
+ "$$typeof": Symbol(react.test.json),
23
+ "children": [
24
+ {
25
+ "$$typeof": Symbol(react.test.json),
26
+ "children": [
27
+ {
28
+ "$$typeof": Symbol(react.test.json),
29
+ "children": [
30
+ {
31
+ "$$typeof": Symbol(react.test.json),
32
+ "children": [
33
+ {
34
+ "$$typeof": Symbol(react.test.json),
35
+ "children": [
36
+ "Home Address",
37
+ ],
38
+ "props": {
39
+ "numberOfLines": 1,
40
+ "selectable": undefined,
41
+ "style": {
42
+ "color": "#1C1C1C",
43
+ "fontFamily": "text-bold",
44
+ "fontSize": 14,
45
+ "textAlign": "left",
46
+ },
47
+ "testID": undefined,
48
+ },
49
+ "type": "Text",
50
+ },
51
+ ],
52
+ "props": {},
53
+ "type": "View",
54
+ },
55
+ ],
56
+ "props": {
57
+ "onPointerEnter": [Function: AsyncFunction],
58
+ "onPointerLeave": [Function: AsyncFunction],
59
+ "style": {
60
+ "display": "flex",
61
+ "flexShrink": 1,
62
+ "minWidth": 0,
63
+ },
64
+ "testID": undefined,
65
+ },
66
+ "type": "View",
67
+ },
68
+ {
69
+ "$$typeof": Symbol(react.test.json),
70
+ "children": [
71
+ {
72
+ "$$typeof": Symbol(react.test.json),
73
+ "children": [
74
+ {
75
+ "$$typeof": Symbol(react.test.json),
76
+ "children": null,
77
+ "props": {
78
+ "style": {
79
+ "marginRight": 8,
80
+ },
81
+ "testID": "icon",
82
+ },
83
+ "type": "View",
84
+ },
85
+ {
86
+ "$$typeof": Symbol(react.test.json),
87
+ "children": [
88
+ "Verified",
89
+ ],
90
+ "props": {
91
+ "style": {
92
+ "color": "#1A7F36",
93
+ "fontFamily": "text",
94
+ "fontSize": 10,
95
+ "fontWeight": "700",
96
+ },
97
+ },
98
+ "type": "Text",
99
+ },
100
+ ],
101
+ "props": {
102
+ "style": [
103
+ {
104
+ "alignItems": "center",
105
+ "backgroundColor": "#DCF2E2",
106
+ "borderRadius": 4,
107
+ "flexDirection": "row",
108
+ "height": 20,
109
+ "justifyContent": "center",
110
+ "paddingHorizontal": 8,
111
+ "paddingVertical": 0,
112
+ "width": "auto",
113
+ },
114
+ false,
115
+ {
116
+ "borderColor": "#7FD898",
117
+ "borderWidth": 1,
118
+ },
119
+ ],
120
+ "testID": undefined,
121
+ },
122
+ "type": "View",
123
+ },
124
+ ],
125
+ "props": {
126
+ "style": {
127
+ "alignItems": "flex-start",
128
+ },
129
+ "testID": undefined,
130
+ },
131
+ "type": "View",
132
+ },
133
+ ],
134
+ "props": {
135
+ "onPointerEnter": [Function: AsyncFunction],
136
+ "onPointerLeave": [Function: AsyncFunction],
137
+ "style": {
138
+ "alignItems": "center",
139
+ "display": "flex",
140
+ "flexDirection": "row",
141
+ "gap": 8,
142
+ },
143
+ "testID": undefined,
144
+ },
145
+ "type": "View",
146
+ },
147
+ {
148
+ "$$typeof": Symbol(react.test.json),
149
+ "children": [
150
+ {
151
+ "$$typeof": Symbol(react.test.json),
152
+ "children": [
153
+ "123 Main Street",
154
+ ],
155
+ "props": {
156
+ "numberOfLines": 0,
157
+ "selectable": undefined,
158
+ "style": {
159
+ "color": "#1C1C1C",
160
+ "fontFamily": "text-regular",
161
+ "fontSize": 14,
162
+ "textAlign": "left",
163
+ },
164
+ "testID": undefined,
165
+ },
166
+ "type": "Text",
167
+ },
168
+ ],
169
+ "props": {},
170
+ "type": "View",
171
+ },
172
+ {
173
+ "$$typeof": Symbol(react.test.json),
174
+ "children": [
175
+ {
176
+ "$$typeof": Symbol(react.test.json),
177
+ "children": [
178
+ "Last updated 2 days ago",
179
+ ],
180
+ "props": {
181
+ "numberOfLines": 0,
182
+ "selectable": undefined,
183
+ "style": {
184
+ "color": "#686868",
185
+ "fontFamily": "text-regular",
186
+ "fontSize": 10,
187
+ "textAlign": "left",
188
+ },
189
+ "testID": undefined,
190
+ },
191
+ "type": "Text",
192
+ },
193
+ ],
194
+ "props": {},
195
+ "type": "View",
196
+ },
197
+ ],
198
+ "props": {
199
+ "onPointerEnter": [Function: AsyncFunction],
200
+ "onPointerLeave": [Function: AsyncFunction],
201
+ "style": {
202
+ "display": "flex",
203
+ "flexDirection": "column",
204
+ "flexGrow": 1,
205
+ "flexShrink": 1,
206
+ "gap": 4,
207
+ "minWidth": 0,
208
+ },
209
+ "testID": undefined,
210
+ },
211
+ "type": "View",
212
+ },
213
+ ],
214
+ "props": {
215
+ "onPointerEnter": [Function: AsyncFunction],
216
+ "onPointerLeave": [Function: AsyncFunction],
217
+ "style": {
218
+ "backgroundColor": "#FFFFFF",
219
+ "borderBottomColor": "#CDCDCD",
220
+ "borderBottomWidth": 1,
221
+ "borderLeftColor": "#CDCDCD",
222
+ "borderLeftWidth": 1,
223
+ "borderRadius": 4,
224
+ "borderRightColor": "#CDCDCD",
225
+ "borderRightWidth": 1,
226
+ "borderTopColor": "#CDCDCD",
227
+ "borderTopWidth": 1,
228
+ "display": "flex",
229
+ "flex": undefined,
230
+ "flexDirection": "row",
231
+ "gap": 8,
232
+ "maxWidth": "100%",
233
+ "minWidth": 0,
234
+ "overflow": "hidden",
235
+ "padding": 12,
236
+ "width": "100%",
237
+ },
238
+ "testID": undefined,
239
+ },
240
+ "type": "View",
241
+ }
242
+ `;
package/src/bunSetup.ts CHANGED
@@ -303,9 +303,12 @@ mock.module("react-native", () => {
303
303
  };
304
304
  const UIManager = {
305
305
  getViewManagerConfig: mock(() => ({})),
306
+ measure: mock(() => {}),
306
307
  setLayoutAnimationEnabledExperimental: mock(() => {}),
307
308
  };
308
- const findNodeHandle = mock(() => null);
309
+ // Node handles are opaque numbers in React Native; pass them through so code that
310
+ // measures the currently focused field can be exercised in tests.
311
+ const findNodeHandle = mock((node: unknown) => (typeof node === "number" ? node : null));
309
312
  const requireNativeComponent = mock((name: string) => name);
310
313
  const TurboModuleRegistry = {
311
314
  get: mock(() => null),
@@ -1117,12 +1120,13 @@ mock.module("react-native/Libraries/LayoutAnimation/LayoutAnimation", () => ({
1117
1120
  mock.module("react-native/Libraries/ReactNative/UIManager", () => ({
1118
1121
  default: {
1119
1122
  getViewManagerConfig: mock(() => ({})),
1123
+ measure: mock(() => {}),
1120
1124
  setLayoutAnimationEnabledExperimental: mock(() => {}),
1121
1125
  },
1122
1126
  }));
1123
1127
 
1124
1128
  mock.module("react-native/Libraries/Renderer/shims/ReactNative", () => ({
1125
- findNodeHandle: mock(() => null),
1129
+ findNodeHandle: mock((node: unknown) => (typeof node === "number" ? node : null)),
1126
1130
  }));
1127
1131
 
1128
1132
  mock.module("react-native/Libraries/Components/StatusBar/StatusBar", () => ({