vitest-native 0.2.1 → 0.3.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.
@@ -13,6 +13,10 @@ function reanimated() {
13
13
  "useDerivedValue",
14
14
  "useAnimatedScrollHandler",
15
15
  "useAnimatedGestureHandler",
16
+ "useAnimatedReaction",
17
+ "useAnimatedKeyboard",
18
+ "useReducedMotion",
19
+ "useFrameCallback",
16
20
  "withTiming",
17
21
  "withSpring",
18
22
  "withDecay",
@@ -25,15 +29,69 @@ function reanimated() {
25
29
  "Easing",
26
30
  "FadeIn",
27
31
  "FadeOut",
32
+ "FadeInDown",
33
+ "FadeInUp",
34
+ "FadeInLeft",
35
+ "FadeInRight",
36
+ "FadeOutDown",
37
+ "FadeOutUp",
38
+ "FadeOutLeft",
39
+ "FadeOutRight",
28
40
  "SlideInRight",
41
+ "SlideInLeft",
42
+ "SlideInUp",
43
+ "SlideInDown",
44
+ "SlideOutRight",
29
45
  "SlideOutLeft",
46
+ "SlideOutUp",
47
+ "SlideOutDown",
48
+ "ZoomIn",
49
+ "ZoomOut",
50
+ "BounceIn",
51
+ "BounceOut",
52
+ "BounceInDown",
53
+ "BounceInUp",
54
+ "BounceInLeft",
55
+ "BounceInRight",
56
+ "FlipInEasyX",
57
+ "FlipInEasyY",
58
+ "FlipOutEasyX",
59
+ "FlipOutEasyY",
60
+ "LightSpeedInLeft",
61
+ "LightSpeedInRight",
62
+ "LightSpeedOutLeft",
63
+ "LightSpeedOutRight",
64
+ "PinwheelIn",
65
+ "PinwheelOut",
66
+ "StretchInX",
67
+ "StretchInY",
68
+ "StretchOutX",
69
+ "StretchOutY",
70
+ "RotateInDownLeft",
71
+ "RotateInDownRight",
72
+ "RotateInUpLeft",
73
+ "RotateInUpRight",
74
+ "RotateOutDownLeft",
75
+ "RotateOutDownRight",
76
+ "RotateOutUpLeft",
77
+ "RotateOutUpRight",
30
78
  "Layout",
79
+ "LinearTransition",
80
+ "SequencedTransition",
81
+ "FadingTransition",
82
+ "JumpingTransition",
83
+ "CurvedTransition",
84
+ "EntryExitTransition",
31
85
  "interpolate",
32
86
  "Extrapolation",
33
87
  "useAnimatedRef",
34
88
  "measure",
35
89
  "scrollTo",
36
- "cancelAnimation"
90
+ "cancelAnimation",
91
+ "makeMutable",
92
+ "SharedTransition",
93
+ "ReduceMotion",
94
+ "KeyboardState"
37
95
  ],
38
96
  factory: () => {
39
97
  function createSharedValue(init) {
@@ -78,6 +136,23 @@ function reanimated() {
78
136
  function useAnimatedGestureHandler(_handler) {
79
137
  return vi.fn();
80
138
  }
139
+ function useAnimatedReaction(_prepare, _react, _deps) {}
140
+ function useAnimatedKeyboard() {
141
+ return {
142
+ state: createSharedValue(0),
143
+ height: createSharedValue(0)
144
+ };
145
+ }
146
+ function useReducedMotion() {
147
+ return false;
148
+ }
149
+ function useFrameCallback(_callback, _autostart) {
150
+ return {
151
+ setActive: vi.fn(),
152
+ isActive: false,
153
+ callbackId: 0
154
+ };
155
+ }
81
156
  function withTiming(toValue, _config, callback) {
82
157
  callback?.({
83
158
  finished: true,
@@ -124,6 +199,24 @@ function reanimated() {
124
199
  Animated.displayName = `Animated(${component.displayName || component.name || "Component"})`;
125
200
  return Animated;
126
201
  }
202
+ function createLayoutAnim() {
203
+ const obj = {};
204
+ obj.duration = vi.fn().mockReturnValue(obj);
205
+ obj.delay = vi.fn().mockReturnValue(obj);
206
+ obj.easing = vi.fn().mockReturnValue(obj);
207
+ obj.damping = vi.fn().mockReturnValue(obj);
208
+ obj.stiffness = vi.fn().mockReturnValue(obj);
209
+ obj.mass = vi.fn().mockReturnValue(obj);
210
+ obj.overshootClamping = vi.fn().mockReturnValue(obj);
211
+ obj.restDisplacementThreshold = vi.fn().mockReturnValue(obj);
212
+ obj.restSpeedThreshold = vi.fn().mockReturnValue(obj);
213
+ obj.springify = vi.fn().mockReturnValue(obj);
214
+ obj.withCallback = vi.fn().mockReturnValue(obj);
215
+ obj.withInitialValues = vi.fn().mockReturnValue(obj);
216
+ obj.randomDelay = vi.fn().mockReturnValue(obj);
217
+ obj.build = vi.fn();
218
+ return obj;
219
+ }
127
220
  return {
128
221
  default: { createAnimatedComponent },
129
222
  useSharedValue,
@@ -132,6 +225,10 @@ function reanimated() {
132
225
  useDerivedValue,
133
226
  useAnimatedScrollHandler,
134
227
  useAnimatedGestureHandler,
228
+ useAnimatedReaction,
229
+ useAnimatedKeyboard,
230
+ useReducedMotion,
231
+ useFrameCallback,
135
232
  withTiming,
136
233
  withSpring,
137
234
  withDecay,
@@ -151,28 +248,61 @@ function reanimated() {
151
248
  out: vi.fn((fn) => fn),
152
249
  inOut: vi.fn((fn) => fn)
153
250
  },
154
- FadeIn: {
155
- duration: vi.fn().mockReturnThis(),
156
- delay: vi.fn().mockReturnThis(),
157
- build: vi.fn()
158
- },
159
- FadeOut: {
160
- duration: vi.fn().mockReturnThis(),
161
- delay: vi.fn().mockReturnThis(),
162
- build: vi.fn()
163
- },
164
- SlideInRight: {
165
- duration: vi.fn().mockReturnThis(),
166
- build: vi.fn()
167
- },
168
- SlideOutLeft: {
169
- duration: vi.fn().mockReturnThis(),
170
- build: vi.fn()
171
- },
172
- Layout: {
173
- duration: vi.fn().mockReturnThis(),
174
- build: vi.fn()
175
- },
251
+ FadeIn: createLayoutAnim(),
252
+ FadeOut: createLayoutAnim(),
253
+ FadeInDown: createLayoutAnim(),
254
+ FadeInUp: createLayoutAnim(),
255
+ FadeInLeft: createLayoutAnim(),
256
+ FadeInRight: createLayoutAnim(),
257
+ FadeOutDown: createLayoutAnim(),
258
+ FadeOutUp: createLayoutAnim(),
259
+ FadeOutLeft: createLayoutAnim(),
260
+ FadeOutRight: createLayoutAnim(),
261
+ SlideInRight: createLayoutAnim(),
262
+ SlideInLeft: createLayoutAnim(),
263
+ SlideInUp: createLayoutAnim(),
264
+ SlideInDown: createLayoutAnim(),
265
+ SlideOutRight: createLayoutAnim(),
266
+ SlideOutLeft: createLayoutAnim(),
267
+ SlideOutUp: createLayoutAnim(),
268
+ SlideOutDown: createLayoutAnim(),
269
+ ZoomIn: createLayoutAnim(),
270
+ ZoomOut: createLayoutAnim(),
271
+ BounceIn: createLayoutAnim(),
272
+ BounceOut: createLayoutAnim(),
273
+ BounceInDown: createLayoutAnim(),
274
+ BounceInUp: createLayoutAnim(),
275
+ BounceInLeft: createLayoutAnim(),
276
+ BounceInRight: createLayoutAnim(),
277
+ FlipInEasyX: createLayoutAnim(),
278
+ FlipInEasyY: createLayoutAnim(),
279
+ FlipOutEasyX: createLayoutAnim(),
280
+ FlipOutEasyY: createLayoutAnim(),
281
+ LightSpeedInLeft: createLayoutAnim(),
282
+ LightSpeedInRight: createLayoutAnim(),
283
+ LightSpeedOutLeft: createLayoutAnim(),
284
+ LightSpeedOutRight: createLayoutAnim(),
285
+ PinwheelIn: createLayoutAnim(),
286
+ PinwheelOut: createLayoutAnim(),
287
+ StretchInX: createLayoutAnim(),
288
+ StretchInY: createLayoutAnim(),
289
+ StretchOutX: createLayoutAnim(),
290
+ StretchOutY: createLayoutAnim(),
291
+ RotateInDownLeft: createLayoutAnim(),
292
+ RotateInDownRight: createLayoutAnim(),
293
+ RotateInUpLeft: createLayoutAnim(),
294
+ RotateInUpRight: createLayoutAnim(),
295
+ RotateOutDownLeft: createLayoutAnim(),
296
+ RotateOutDownRight: createLayoutAnim(),
297
+ RotateOutUpLeft: createLayoutAnim(),
298
+ RotateOutUpRight: createLayoutAnim(),
299
+ Layout: createLayoutAnim(),
300
+ LinearTransition: createLayoutAnim(),
301
+ SequencedTransition: createLayoutAnim(),
302
+ FadingTransition: createLayoutAnim(),
303
+ JumpingTransition: createLayoutAnim(),
304
+ CurvedTransition: createLayoutAnim(),
305
+ EntryExitTransition: createLayoutAnim(),
176
306
  interpolate: vi.fn((_value, input, output) => output[0]),
177
307
  Extrapolation: {
178
308
  CLAMP: "clamp",
@@ -189,7 +319,26 @@ function reanimated() {
189
319
  pageY: 0
190
320
  })),
191
321
  scrollTo: vi.fn(),
192
- cancelAnimation: vi.fn()
322
+ cancelAnimation: vi.fn(),
323
+ makeMutable: vi.fn((init) => createSharedValue(init)),
324
+ SharedTransition: {
325
+ duration: vi.fn().mockReturnThis(),
326
+ custom: vi.fn().mockReturnThis(),
327
+ progressAnimation: vi.fn().mockReturnThis(),
328
+ defaultTransitionType: vi.fn().mockReturnThis()
329
+ },
330
+ ReduceMotion: {
331
+ System: "system",
332
+ Always: "always",
333
+ Never: "never"
334
+ },
335
+ KeyboardState: {
336
+ UNKNOWN: 0,
337
+ OPENING: 1,
338
+ OPEN: 2,
339
+ CLOSING: 3,
340
+ CLOSED: 4
341
+ }
193
342
  };
194
343
  }
195
344
  } }
@@ -368,19 +517,25 @@ function safeAreaContext() {
368
517
  "Metrics"
369
518
  ],
370
519
  factory: () => {
520
+ const defaultInsets = {
521
+ top: 47,
522
+ right: 0,
523
+ bottom: 34,
524
+ left: 0
525
+ };
526
+ const defaultFrame = {
527
+ x: 0,
528
+ y: 0,
529
+ width: 390,
530
+ height: 844
531
+ };
532
+ const state = {
533
+ insets: { ...defaultInsets },
534
+ frame: { ...defaultFrame }
535
+ };
371
536
  const initialMetrics = {
372
- frame: {
373
- x: 0,
374
- y: 0,
375
- width: 390,
376
- height: 844
377
- },
378
- insets: {
379
- top: 47,
380
- right: 0,
381
- bottom: 34,
382
- left: 0
383
- }
537
+ frame: state.frame,
538
+ insets: state.insets
384
539
  };
385
540
  const SafeAreaProvider = React.forwardRef((props, ref) => React.createElement("SafeAreaProvider", {
386
541
  ...props,
@@ -392,19 +547,19 @@ function safeAreaContext() {
392
547
  ref
393
548
  }, props.children));
394
549
  SafeAreaView.displayName = "SafeAreaView";
395
- const SafeAreaInsetsContext = React.createContext(initialMetrics.insets);
396
- const SafeAreaFrameContext = React.createContext(initialMetrics.frame);
550
+ const SafeAreaInsetsContext = React.createContext(state.insets);
551
+ const SafeAreaFrameContext = React.createContext(state.frame);
397
552
  function useSafeAreaInsets() {
398
- return initialMetrics.insets;
553
+ return state.insets;
399
554
  }
400
555
  function useSafeAreaFrame() {
401
- return initialMetrics.frame;
556
+ return state.frame;
402
557
  }
403
558
  function withSafeAreaInsets(WrappedComponent) {
404
559
  const WithSafeAreaInsets = React.forwardRef((props, ref) => React.createElement(WrappedComponent, {
405
560
  ...props,
406
561
  ref,
407
- insets: initialMetrics.insets
562
+ insets: state.insets
408
563
  }));
409
564
  WithSafeAreaInsets.displayName = `withSafeAreaInsets(${WrappedComponent.displayName || WrappedComponent.name || "Component"})`;
410
565
  return WithSafeAreaInsets;
@@ -422,10 +577,17 @@ function safeAreaContext() {
422
577
  useSafeAreaFrame,
423
578
  withSafeAreaInsets,
424
579
  initialWindowMetrics: initialMetrics,
425
- initialWindowSafeAreaInsets: initialMetrics.insets,
580
+ initialWindowSafeAreaInsets: state.insets,
426
581
  EdgeInsets: vi.fn(),
427
582
  Rect: vi.fn(),
428
- Metrics: vi.fn()
583
+ Metrics: vi.fn(),
584
+ _setInsets: (insets) => {
585
+ Object.assign(state.insets, insets);
586
+ },
587
+ _reset: () => {
588
+ Object.assign(state.insets, defaultInsets);
589
+ Object.assign(state.frame, defaultFrame);
590
+ }
429
591
  };
430
592
  }
431
593
  } }
@@ -433,7 +595,76 @@ function safeAreaContext() {
433
595
  }
434
596
  //#endregion
435
597
  //#region src/presets/navigation.ts
598
+ /** Builds a minimal navigation prop matching useNavigation()'s shape. */
599
+ function createMockNavigation() {
600
+ return {
601
+ navigate: vi.fn(),
602
+ goBack: vi.fn(),
603
+ reset: vi.fn(),
604
+ setParams: vi.fn(),
605
+ setOptions: vi.fn(),
606
+ dispatch: vi.fn(),
607
+ canGoBack: vi.fn(() => false),
608
+ getParent: vi.fn(() => void 0),
609
+ getState: vi.fn(() => ({
610
+ index: 0,
611
+ key: "root",
612
+ routeNames: [],
613
+ routes: [],
614
+ type: "stack",
615
+ stale: false
616
+ })),
617
+ isFocused: vi.fn(() => true),
618
+ addListener: vi.fn(() => vi.fn()),
619
+ removeListener: vi.fn(),
620
+ getId: vi.fn(() => void 0)
621
+ };
622
+ }
623
+ /**
624
+ * Creates a Screen component mock that handles all three React Navigation patterns:
625
+ * 1. <Screen component={Comp} /> — renders Comp with route & navigation props
626
+ * 2. <Screen>{(props) => <Comp />}</Screen> — calls render function
627
+ * 3. <Screen><Something /></Screen> — passes children through
628
+ *
629
+ * Accepts NavigationContext and NavigationRouteContext so that hooks like
630
+ * useNavigation() and useRoute() inside the screen component return values
631
+ * consistent with the route/navigation props passed to the component.
632
+ */
633
+ function createMockScreen(NavContext, RouteContext) {
634
+ const Screen = React.forwardRef(({ component: Component, children, ...rest }, ref) => {
635
+ const route = {
636
+ key: rest.name ?? "",
637
+ name: rest.name ?? "",
638
+ params: rest.initialParams
639
+ };
640
+ const nav = createMockNavigation();
641
+ const content = Component ? React.createElement(Component, {
642
+ route,
643
+ navigation: nav
644
+ }) : typeof children === "function" ? children({
645
+ route,
646
+ navigation: nav
647
+ }) : children;
648
+ return React.createElement("Screen", {
649
+ ...rest,
650
+ ref
651
+ }, React.createElement(NavContext.Provider, { value: nav }, React.createElement(RouteContext.Provider, { value: route }, content)));
652
+ });
653
+ Screen.displayName = "Screen";
654
+ return Screen;
655
+ }
436
656
  function navigation() {
657
+ const NavigationContext = React.createContext(null);
658
+ const NavigationRouteContext = React.createContext(null);
659
+ const NavigationContainerRefContext = React.createContext(null);
660
+ const NavigationHelpersContext = React.createContext(null);
661
+ const CurrentRenderContext = React.createContext(void 0);
662
+ const ThemeContext = React.createContext({
663
+ dark: false,
664
+ colors: {}
665
+ });
666
+ const PreventRemoveContext = React.createContext(null);
667
+ const Screen = createMockScreen(NavigationContext, NavigationRouteContext);
437
668
  return {
438
669
  name: "navigation",
439
670
  modules: {
@@ -447,6 +678,7 @@ function navigation() {
447
678
  "useFocusEffect",
448
679
  "useIsFocused",
449
680
  "useNavigationState",
681
+ "useScrollToTop",
450
682
  "useNavigationContainerRef",
451
683
  "createNavigationContainerRef",
452
684
  "createNavigatorFactory",
@@ -503,29 +735,39 @@ function navigation() {
503
735
  type: "stack",
504
736
  stale: false
505
737
  }));
738
+ const defaultNavigation = {
739
+ navigate,
740
+ goBack,
741
+ reset,
742
+ setParams,
743
+ setOptions,
744
+ dispatch,
745
+ canGoBack,
746
+ getParent,
747
+ getState,
748
+ isFocused: vi.fn(() => true),
749
+ addListener: vi.fn(() => vi.fn()),
750
+ removeListener: vi.fn(),
751
+ getId: vi.fn(() => void 0)
752
+ };
753
+ const defaultRoute = {
754
+ key: "test-route-key",
755
+ name: "TestScreen",
756
+ params: {}
757
+ };
506
758
  function useNavigation() {
507
- return {
508
- navigate,
509
- goBack,
510
- reset,
511
- setParams,
512
- setOptions,
513
- dispatch,
514
- canGoBack,
515
- getParent,
516
- getState,
517
- isFocused: vi.fn(() => true),
518
- addListener: vi.fn(() => vi.fn()),
519
- removeListener: vi.fn(),
520
- getId: vi.fn(() => void 0)
521
- };
759
+ try {
760
+ const ctx = React.useContext(NavigationContext);
761
+ if (ctx) return ctx;
762
+ } catch {}
763
+ return defaultNavigation;
522
764
  }
523
765
  function useRoute() {
524
- return {
525
- key: "test-route-key",
526
- name: "TestScreen",
527
- params: {}
528
- };
766
+ try {
767
+ const ctx = React.useContext(NavigationRouteContext);
768
+ if (ctx) return ctx;
769
+ } catch {}
770
+ return defaultRoute;
529
771
  }
530
772
  function useFocusEffect(callback) {
531
773
  React.useEffect(callback, []);
@@ -558,16 +800,6 @@ function navigation() {
558
800
  function useNavigationContainerRef() {
559
801
  return createNavigationContainerRef();
560
802
  }
561
- const NavigationContext = React.createContext(null);
562
- const NavigationRouteContext = React.createContext(null);
563
- const NavigationContainerRefContext = React.createContext(null);
564
- const NavigationHelpersContext = React.createContext(null);
565
- const CurrentRenderContext = React.createContext(void 0);
566
- const ThemeContext = React.createContext({
567
- dark: false,
568
- colors: {}
569
- });
570
- const PreventRemoveContext = React.createContext(null);
571
803
  const defaultTheme = {
572
804
  dark: false,
573
805
  colors: {
@@ -667,6 +899,7 @@ function navigation() {
667
899
  getStateForAction: vi.fn((state) => state),
668
900
  shouldActionChangeFocus: vi.fn(() => false)
669
901
  },
902
+ useScrollToTop: vi.fn(),
670
903
  useLinkTo: vi.fn(() => vi.fn()),
671
904
  Link: React.forwardRef((props, ref) => React.createElement("Link", {
672
905
  ...props,
@@ -684,10 +917,7 @@ function navigation() {
684
917
  ...props,
685
918
  ref
686
919
  }, props.children)),
687
- Screen: React.forwardRef((props, ref) => React.createElement("Screen", {
688
- ...props,
689
- ref
690
- }, props.children)),
920
+ Screen,
691
921
  Group: React.forwardRef((props, ref) => React.createElement("Group", {
692
922
  ...props,
693
923
  ref
@@ -709,10 +939,29 @@ function navigation() {
709
939
  ...props,
710
940
  ref
711
941
  }, props.children)),
712
- Screen: React.forwardRef((props, ref) => React.createElement("Screen", {
942
+ Screen,
943
+ Group: React.forwardRef((props, ref) => React.createElement("Group", {
944
+ ...props,
945
+ ref
946
+ }, props.children))
947
+ };
948
+ }
949
+ return {
950
+ default: { createBottomTabNavigator },
951
+ createBottomTabNavigator
952
+ };
953
+ }
954
+ },
955
+ "@react-navigation/drawer": {
956
+ exports: ["createDrawerNavigator"],
957
+ factory: () => {
958
+ function createDrawerNavigator() {
959
+ return {
960
+ Navigator: React.forwardRef((props, ref) => React.createElement("DrawerNavigator", {
713
961
  ...props,
714
962
  ref
715
963
  }, props.children)),
964
+ Screen,
716
965
  Group: React.forwardRef((props, ref) => React.createElement("Group", {
717
966
  ...props,
718
967
  ref
@@ -720,8 +969,8 @@ function navigation() {
720
969
  };
721
970
  }
722
971
  return {
723
- default: { createBottomTabNavigator },
724
- createBottomTabNavigator
972
+ default: { createDrawerNavigator },
973
+ createDrawerNavigator
725
974
  };
726
975
  }
727
976
  },
@@ -856,7 +1105,8 @@ function asyncStorage() {
856
1105
  else store.set(key, value);
857
1106
  });
858
1107
  }),
859
- flushGetRequests: vi.fn(() => {})
1108
+ flushGetRequests: vi.fn(() => {}),
1109
+ _resetStore: () => store.clear()
860
1110
  };
861
1111
  return {
862
1112
  ...exports,
package/dist/presets.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_presets = require("./presets-9Y4ssfiH.cjs");
2
+ const require_presets = require("./presets-B-spxZz7.cjs");
3
3
  exports.asyncStorage = require_presets.asyncStorage;
4
4
  exports.expo = require_presets.expo;
5
5
  exports.gestureHandler = require_presets.gestureHandler;
package/dist/presets.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as navigation, c as reanimated, i as asyncStorage, n as expo, o as safeAreaContext, r as screens, s as gestureHandler } from "./presets-CWH0gtM0.mjs";
1
+ import { a as navigation, c as reanimated, i as asyncStorage, n as expo, o as safeAreaContext, r as screens, s as gestureHandler } from "./presets-DvrcfEPz.mjs";
2
2
  export { asyncStorage, expo, gestureHandler, navigation, reanimated, safeAreaContext, screens };