@applicaster/zapp-react-native-utils 13.0.0-alpha.6714678893 → 13.0.0-alpha.7100577251

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.
Files changed (93) hide show
  1. package/actionsExecutor/ActionExecutor.ts +16 -9
  2. package/actionsExecutor/ActionExecutorContext.tsx +59 -8
  3. package/alertUtils/alert.ts +148 -0
  4. package/alertUtils/index.ts +1 -148
  5. package/analyticsUtils/AnalyticPlayerListener.ts +18 -1
  6. package/analyticsUtils/__tests__/__snapshots__/analyticsManagerNoModule.test.js.snap +9 -9
  7. package/analyticsUtils/helpers/hooks.ts +1 -1
  8. package/appUtils/HooksManager/Hook.ts +2 -2
  9. package/appUtils/HooksManager/__tests__/__snapshots__/hook.test.js.snap +7 -7
  10. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +186 -186
  11. package/appUtils/HooksManager/types.ts +5 -2
  12. package/appUtils/accessibilityManager/index.ts +42 -1
  13. package/appUtils/contextKeysManager/contextResolver.ts +77 -0
  14. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +6 -6
  15. package/appUtils/focusManager/index.ts +91 -65
  16. package/appUtils/focusManager/treeDataStructure/Tree/index.js +23 -0
  17. package/appUtils/focusManager/utils/enums.ts +4 -0
  18. package/appUtils/focusManagerAux/utils/index.ts +4 -3
  19. package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +2 -2
  20. package/appUtils/keyCodes/__tests__/keyCodes.test.js +1 -1
  21. package/appUtils/keyCodes/keys/keysByPlatform.ts +4 -0
  22. package/appUtils/keyInputHandler/KeyInputHandler.ts +68 -0
  23. package/appUtils/orientationHelper.ts +1 -1
  24. package/appUtils/platform/const.ts +14 -0
  25. package/appUtils/platform/platformUtils.ts +41 -4
  26. package/appUtils/playerManager/player.ts +19 -7
  27. package/appUtils/playerManager/playerNative.ts +3 -2
  28. package/appUtils/playerManager/usePlayerControllerSetup.tsx +3 -3
  29. package/arrayUtils/__tests__/__snapshots__/arrayUtils.test.ts.snap +4 -4
  30. package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +4 -4
  31. package/idleUtils/__tests__/withTimeout$.test.ts +37 -0
  32. package/idleUtils/index.ts +1 -1
  33. package/idleUtils/withTimeout.ts +15 -2
  34. package/logger/const.ts +9 -67
  35. package/manifestUtils/__tests__/createConfig.test.js +16 -16
  36. package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +6 -6
  37. package/navigationUtils/__tests__/itemTypes.test.js +2 -2
  38. package/navigationUtils/__tests__/navigationUtils.test.js +2 -2
  39. package/navigationUtils/index.ts +3 -3
  40. package/package.json +3 -2
  41. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
  42. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +1 -1
  43. package/reactHooks/cell-click/__tests__/index.test.js +10 -2
  44. package/reactHooks/cell-click/index.ts +7 -1
  45. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +4 -4
  46. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +10 -11
  47. package/reactHooks/feed/useFeedLoader.tsx +1 -1
  48. package/reactHooks/feed/usePipesCacheReset.ts +5 -5
  49. package/reactHooks/flatList/__tests__/index.test.tsx +30 -21
  50. package/reactHooks/layout/__tests__/index.test.tsx +10 -10
  51. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +14 -28
  52. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +1 -1
  53. package/reactHooks/layout/useDimensions/useDimensions.ts +8 -0
  54. package/reactHooks/navigation/__tests__/index.test.tsx +0 -4
  55. package/reactHooks/navigation/index.ts +22 -214
  56. package/reactHooks/navigation/useGetBottomTabBarHeight.ts +12 -0
  57. package/reactHooks/navigation/useGetNavBarTopBorderWidth.ts +14 -0
  58. package/reactHooks/navigation/useGetTabBarHeight.ts +12 -0
  59. package/reactHooks/navigation/useIsScreenActive.ts +17 -0
  60. package/reactHooks/navigation/useNavigationPluginData.ts +15 -0
  61. package/reactHooks/navigation/useNavigationType.ts +15 -0
  62. package/reactHooks/navigation/usePathname.ts +4 -0
  63. package/reactHooks/navigation/useRoute.ts +100 -0
  64. package/reactHooks/navigation/useUniqueRouteSuffix.ts +41 -0
  65. package/reactHooks/player/TVSeekControlller/ISeekController.ts +32 -0
  66. package/reactHooks/player/TVSeekControlller/LongPressSeekController.ts +71 -0
  67. package/reactHooks/player/TVSeekControlller/TVSeekController.ts +258 -0
  68. package/reactHooks/player/TVSeekControlller/TapSeekController.ts +53 -0
  69. package/reactHooks/player/__tests__/{useAutoSeek.test.tsx → useAutoSeek._test.tsx} +2 -3
  70. package/reactHooks/player/const.ts +0 -4
  71. package/reactHooks/player/index.ts +0 -6
  72. package/reactHooks/state/useRefWithInitialValue.ts +14 -0
  73. package/reactHooks/state/useStateFromSubscribe.ts +23 -0
  74. package/reactHooks/usePluginConfiguration.ts +1 -1
  75. package/reactHooks/useSubscriberFor.ts +4 -3
  76. package/reactUtils/__tests__/reactUtils.test.js +10 -28
  77. package/reactUtils/createContext/__tests__/__snapshots__/helpers.test.js.snap +19 -19
  78. package/reactUtils/createContext/__tests__/__snapshots__/index.test.js.snap +2 -2
  79. package/reactUtils/createContext/__tests__/__snapshots__/provider.test.js.snap +3 -3
  80. package/reactUtils/createContext/__tests__/helpers.test.js +8 -8
  81. package/screenState/index.ts +24 -10
  82. package/theme/__mocks__/index.ts +4 -0
  83. package/theme/index.ts +1 -1
  84. package/time/Timer.ts +5 -2
  85. package/types.ts +1 -0
  86. package/zappFrameworkUtils/presentPluginOneTime.ts +2 -3
  87. package/manifestUtils/sharedConfiguration/screenPicker/__tests__/utils.test.js +0 -304
  88. package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +0 -875
  89. package/manifestUtils/sharedConfiguration/screenPicker/utils.js +0 -130
  90. package/reactHooks/player/useAutoSeek.tsx +0 -87
  91. package/reactHooks/player/useSeek.tsx +0 -66
  92. package/reactHooks/player/useTapSeek.tsx +0 -58
  93. /package/reactHooks/player/__tests__/{useTapSeek.test.ts → useTapSeek._test.ts} +0 -0
@@ -0,0 +1,258 @@
1
+ import { BehaviorSubject } from "rxjs";
2
+ import { TapSeekController } from "./TapSeekController";
3
+ import { LongPressSeekController } from "./LongPressSeekController";
4
+ import { SEEK_TYPE } from "../const";
5
+ import { createLogger } from "../../../logger";
6
+ import { Player } from "../../../appUtils/playerManager/player";
7
+ import { SeekKeyHandlerListener } from "../../../appUtils/keyInputHandler/KeyInputHandler";
8
+ import {
9
+ ISeekController,
10
+ ISeekControllerDelegate,
11
+ SeekIncrementalBaseStrategy,
12
+ } from "./ISeekController";
13
+
14
+ export const { log_warning, log_debug, log_info, log_error, log_verbose } =
15
+ createLogger({
16
+ category: "General",
17
+ subsystem: "TVSeekController",
18
+ });
19
+
20
+ export enum SEEK_STRATEGY {
21
+ TAP_SEEK = "TAP_SEEK",
22
+ AUTO_SEEK = "AUTO_SEEK",
23
+ }
24
+
25
+ const CONFIG_TAP_SEEK = {
26
+ CLICKS_BEFORE_PAUSE: 0,
27
+ };
28
+
29
+ const CONFIG_LONG_PRESS = {
30
+ TIMER_INTERVAL_MS: 200,
31
+ };
32
+
33
+ const LONG_PRESS_THRESHOLD = 500;
34
+ const SEEK_END_TIMEOUT_DURATION = 700;
35
+ // prettier-ignore
36
+
37
+ export class TVSeekController
38
+ implements SeekKeyHandlerListener, ISeekControllerDelegate {
39
+ public delayedSeekPosition: number | null = null;
40
+ private readonly playerController: Player;
41
+ private delayedSeekProgressSubject = new BehaviorSubject<number | null>(null);
42
+ isPlayerInitiallyPaused: null | boolean = null;
43
+ currentSeekType: SEEK_TYPE | null = null;
44
+
45
+ private currentSeekController: ISeekController;
46
+ private readonly tapSeekController: TapSeekController;
47
+ private readonly longPressSeekController: LongPressSeekController;
48
+ private longPressThresholdTimeout: any | null = null;
49
+ private seekEndTimeout: any | null = null;
50
+
51
+ constructor(playerController: Player) {
52
+ this.playerController = playerController;
53
+
54
+ this.tapSeekController = new TapSeekController(
55
+ this,
56
+ new SeekIncrementalBaseStrategy(),
57
+ CONFIG_TAP_SEEK
58
+ );
59
+
60
+ this.longPressSeekController = new LongPressSeekController(
61
+ this,
62
+ new SeekIncrementalBaseStrategy(),
63
+ CONFIG_LONG_PRESS
64
+ );
65
+
66
+ this.currentSeekController = this.tapSeekController;
67
+ }
68
+
69
+ getDelayedSeekProgressObservable = () => {
70
+ return this.delayedSeekProgressSubject;
71
+ };
72
+
73
+ setStrategy = (seekStrategy: SEEK_STRATEGY) => {
74
+ switch (seekStrategy) {
75
+ case SEEK_STRATEGY.TAP_SEEK:
76
+ this.currentSeekController = this.tapSeekController;
77
+ log_debug("TVSeekController: setStrategy - TAP_SEEK");
78
+
79
+ break;
80
+ case SEEK_STRATEGY.AUTO_SEEK:
81
+ this.currentSeekController = this.longPressSeekController;
82
+ log_debug("TVSeekController: setStrategy - AUTO_SEEK");
83
+
84
+ break;
85
+ default:
86
+ }
87
+ };
88
+
89
+ handleStartSeek = (seekType: SEEK_TYPE) => {
90
+ this.currentSeekType = seekType;
91
+
92
+ if (this.isPlayerInitiallyPaused === null) {
93
+ this.isPlayerInitiallyPaused = this.playerController.isPaused();
94
+ }
95
+
96
+ this.clearLongPressThresholdTimeout();
97
+ this.clearSeekCompleteTimeout();
98
+ this.setStrategy(SEEK_STRATEGY.TAP_SEEK);
99
+ this.currentSeekController.onStartSeek(seekType);
100
+
101
+ this.longPressThresholdTimeout = setTimeout(() => {
102
+ this.setStrategy(SEEK_STRATEGY.AUTO_SEEK);
103
+ this.currentSeekController.onStartSeek(seekType);
104
+ }, LONG_PRESS_THRESHOLD);
105
+ };
106
+
107
+ onForwardPress = (): boolean => {
108
+ this.handleStartSeek(SEEK_TYPE.FORWARD);
109
+
110
+ return true;
111
+ };
112
+
113
+ onRewindPress = (): boolean => {
114
+ this.handleStartSeek(SEEK_TYPE.REWIND);
115
+
116
+ return true;
117
+ };
118
+
119
+ onSeekEnd = () => {
120
+ this.clearLongPressThresholdTimeout();
121
+ this.currentSeekController.onSeekEnd();
122
+ };
123
+
124
+ onRewindPressOut = () => {
125
+ this.onSeekEnd();
126
+ };
127
+
128
+ onForwardPressOut = () => {
129
+ this.onSeekEnd();
130
+ };
131
+
132
+ onVideoProgress = (position: number) => {
133
+ if (this.delayedSeekPosition !== null) {
134
+ return;
135
+ }
136
+
137
+ this.delayedSeekProgressSubject.next(position);
138
+ };
139
+
140
+ handleDelayedSeek = (offset: number = 0) => {
141
+ this.handlePlayerPause();
142
+
143
+ const currentPos =
144
+ this.delayedSeekPosition === null
145
+ ? this.playerController.getPosition()
146
+ : this.delayedSeekPosition;
147
+
148
+ let targetPos = currentPos;
149
+
150
+ if (this.currentSeekType === SEEK_TYPE.FORWARD) {
151
+ targetPos = Math.min(
152
+ currentPos + offset,
153
+ this.playerController.getSeekableDuration()
154
+ );
155
+ } else if (this.currentSeekType === SEEK_TYPE.REWIND) {
156
+ targetPos = Math.max(0, currentPos - offset);
157
+ } else {
158
+ log_warning(
159
+ `TVSeekController: handleDelayedSeek - invalid seek type: ${this.currentSeekType}`
160
+ );
161
+ }
162
+
163
+ log_debug(
164
+ `TVSeekController: handleDelayedSeek - targetPos: ${targetPos}, skipTime: ${offset}`
165
+ );
166
+
167
+ const prevValue = this.delayedSeekProgressSubject.getValue();
168
+
169
+ if (prevValue !== null) {
170
+ const delta = Math.abs(prevValue - targetPos);
171
+
172
+ if (delta < 1) {
173
+ return;
174
+ }
175
+ }
176
+
177
+ this.delayedSeekPosition = targetPos;
178
+ this.delayedSeekProgressSubject.next(targetPos);
179
+ };
180
+
181
+ handleSeekTo = (newPosition: number) => {
182
+ this.playerController.seekTo(newPosition);
183
+
184
+ if (!this.isPlayerInitiallyPaused) {
185
+ this.playerController.play();
186
+ }
187
+ };
188
+
189
+ handleSeek = (offset: number) => {
190
+ this.playerController[this.currentSeekType](offset);
191
+
192
+ if (!this.isPlayerInitiallyPaused) {
193
+ this.playerController.play();
194
+ }
195
+ };
196
+
197
+ handleSeekComplete = () => {
198
+ this.clearSeekCompleteTimeout();
199
+
200
+ this.seekEndTimeout = setTimeout(() => {
201
+ if (this.delayedSeekPosition !== null) {
202
+ this.handleSeekTo(this.delayedSeekPosition);
203
+ }
204
+
205
+ log_debug(
206
+ `handleSeekComplete: Seek finished, type: ${this.currentSeekController.title}, seekPosition: ${this.delayedSeekPosition}. Reset all states and seek position.`
207
+ );
208
+
209
+ this.resetAll();
210
+ }, SEEK_END_TIMEOUT_DURATION);
211
+ };
212
+
213
+ isSeeking = (): boolean => {
214
+ return this.delayedSeekPosition !== null;
215
+ };
216
+
217
+ handlePlayerPause = () => {
218
+ if (this.playerController.isPaused()) {
219
+ return;
220
+ }
221
+
222
+ this.playerController.pause();
223
+ };
224
+
225
+ clearSeekCompleteTimeout = () => {
226
+ if (this.seekEndTimeout === null) {
227
+ return;
228
+ }
229
+
230
+ clearTimeout(this.seekEndTimeout);
231
+ this.seekEndTimeout = null;
232
+ };
233
+
234
+ clearLongPressThresholdTimeout = () => {
235
+ if (this.longPressThresholdTimeout === null) {
236
+ return;
237
+ }
238
+
239
+ clearTimeout(this.longPressThresholdTimeout);
240
+ this.longPressThresholdTimeout = null;
241
+ };
242
+
243
+ resetAll() {
244
+ log_debug("TVSeekController: Reset all states");
245
+ this.currentSeekType = null;
246
+
247
+ this.delayedSeekPosition = null;
248
+ this.isPlayerInitiallyPaused = null;
249
+
250
+ this.clearSeekCompleteTimeout();
251
+ this.clearLongPressThresholdTimeout();
252
+
253
+ this.tapSeekController.reset();
254
+ this.longPressSeekController.reset();
255
+
256
+ this.setStrategy(SEEK_STRATEGY.TAP_SEEK);
257
+ }
258
+ }
@@ -0,0 +1,53 @@
1
+ import {
2
+ ISeekController,
3
+ ISeekControllerDelegate,
4
+ SeekIncrementalBaseStrategy,
5
+ } from "./ISeekController";
6
+ import { SEEK_TYPE } from "../const";
7
+ import { log_debug } from "./TVSeekController";
8
+
9
+ interface TapPressConfig {
10
+ CLICKS_BEFORE_PAUSE: number;
11
+ }
12
+
13
+ export class TapSeekController implements ISeekController {
14
+ readonly title = "TapSeek";
15
+ constructor(
16
+ private seekControllerDelegate: ISeekControllerDelegate,
17
+ private seekIncrementalStrategy: SeekIncrementalBaseStrategy,
18
+ private config: TapPressConfig
19
+ ) {}
20
+
21
+ onStartSeek = (seekType: SEEK_TYPE) => {
22
+ log_debug(`${this.title}: start tap seek type: ${seekType}.`);
23
+
24
+ const skipTime = this.seekIncrementalStrategy.getSkipTime();
25
+ const seekMultiplier = this.seekIncrementalStrategy.getSkipMultiplier();
26
+
27
+ if (seekMultiplier > this.config.CLICKS_BEFORE_PAUSE) {
28
+ log_debug(
29
+ `${this.title}: handle delayed seek type:${seekType} - skipTime: ${skipTime}, seekMultiplier: ${seekMultiplier}.`
30
+ );
31
+
32
+ this.seekControllerDelegate.handleDelayedSeek(skipTime);
33
+ } else {
34
+ log_debug(
35
+ `${this.title}: handle seek type:${seekType} - skipTime: ${skipTime}.`
36
+ );
37
+
38
+ this.seekControllerDelegate.handleSeek(skipTime);
39
+ }
40
+
41
+ this.seekIncrementalStrategy.increment();
42
+ };
43
+
44
+ onSeekEnd = () => {
45
+ this.seekControllerDelegate.handleSeekComplete();
46
+ };
47
+
48
+ reset = () => {
49
+ log_debug("{this.title}: Reset states");
50
+
51
+ this.seekIncrementalStrategy.reset();
52
+ };
53
+ }
@@ -5,15 +5,14 @@ import { ON_HOLD_INTERVAL, SEEK_TYPE, SKIP_TIME_BASE } from "../const";
5
5
 
6
6
  import { useAutoSeek } from "../useAutoSeek";
7
7
 
8
- jest.useFakeTimers();
8
+ jest.useFakeTimers({ legacyFakeTimers: true });
9
9
 
10
10
  const rewind = jest.fn();
11
11
  const forward = jest.fn();
12
12
 
13
13
  jest
14
14
  .spyOn(playerManager, "getInstanceController")
15
- // @ts-ignore
16
- .mockImplementation(() => ({ rewind, forward }));
15
+ .mockReturnValue({ rewind, forward });
17
16
 
18
17
  describe("useAutoSeek", () => {
19
18
  beforeEach(() => {
@@ -1,9 +1,5 @@
1
1
  export const SKIP_TIME_BASE = 10;
2
2
 
3
- export const ON_PRESS_RESET_DURATION = 2000;
4
-
5
- export const ON_HOLD_INTERVAL = 500;
6
-
7
3
  export const MAX_SEEK_TIME = 600;
8
4
 
9
5
  export enum SEEK_TYPE {
@@ -1,7 +1 @@
1
1
  export { useLanguageData } from "./useLanguageData";
2
-
3
- export { useAutoSeek } from "./useAutoSeek";
4
-
5
- export { useTapSeek } from "./useTapSeek";
6
-
7
- export { useSeek, withUseSeek } from "./useSeek";
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+
3
+ /**
4
+ * returns a ref with an initial value that is lazily evaluated once
5
+ * */
6
+ export const useRefWithInitialValue = <T>(initialValueGetter: () => T) => {
7
+ const ref = React.useRef<T>(null);
8
+
9
+ if (ref.current === null) {
10
+ ref.current = initialValueGetter();
11
+ }
12
+
13
+ return ref;
14
+ };
@@ -0,0 +1,23 @@
1
+ import { useEffect, useState } from "react";
2
+ import type { Subject } from "rxjs";
3
+
4
+ export const useStateFromSubscribe = <T, U>(
5
+ subject: Subject<T>,
6
+ onUpdate: (
7
+ observerValue: T,
8
+ next: React.Dispatch<React.SetStateAction<U>>
9
+ ) => void,
10
+ initialValue: U
11
+ ) => {
12
+ const [state, setState] = useState<U>(initialValue);
13
+
14
+ useEffect(() => {
15
+ const subscription = subject.subscribe((observer) =>
16
+ onUpdate(observer, setState)
17
+ );
18
+
19
+ return () => subscription.unsubscribe();
20
+ }, [subject]);
21
+
22
+ return state;
23
+ };
@@ -91,7 +91,7 @@ export function useLayoutConfiguration<
91
91
  S extends unknown,
92
92
  G extends unknown,
93
93
  R extends unknown,
94
- L extends unknown
94
+ L extends unknown,
95
95
  >(layoutData, manifest, options: Options = {}) {
96
96
  const keys = options.keys || [
97
97
  "assets",
@@ -4,9 +4,10 @@ import { subscriber } from "@applicaster/zapp-react-native-utils/functionUtils";
4
4
  const subscriberObjects = Object.create({});
5
5
 
6
6
  interface UseSubscriberFor {
7
- (eventName: string, handler?: (...args: unknown[]) => void): (
8
- ...args: unknown[]
9
- ) => ReturnType<typeof subscriber>;
7
+ (
8
+ eventName: string,
9
+ handler?: (...args: unknown[]) => void
10
+ ): (...args: unknown[]) => ReturnType<typeof subscriber>;
10
11
  }
11
12
 
12
13
  /**
@@ -1,4 +1,3 @@
1
- jest.mock("create-react-ref/lib/createRef", () => jest.fn());
2
1
  import * as React from "react";
3
2
  import * as helpers from "../helpers";
4
3
 
@@ -8,13 +7,7 @@ import {
8
7
  componentDidMount,
9
8
  } from "./fixtures";
10
9
 
11
- const {
12
- attachLifeCycleMethods,
13
- createReactRef,
14
- mergeChildrenProps,
15
- } = require("../index");
16
-
17
- const createRef = require("create-react-ref/lib/createRef");
10
+ import { attachLifeCycleMethods, createReactRef, mergeChildrenProps } from "..";
18
11
 
19
12
  describe("attachLifeCycleMethods", () => {
20
13
  let addLifeCycleMethodsSpy;
@@ -50,30 +43,19 @@ describe("attachLifeCycleMethods", () => {
50
43
 
51
44
  describe("createReactRef", () => {
52
45
  it("calls the React.createRef function if it exists", () => {
53
- jest.resetModules();
54
-
55
- jest.doMock("react", () => ({
56
- ...jest.requireActual("react"),
57
- createRef: jest.fn(),
58
- }));
59
-
60
- const React = require("react");
46
+ jest.clearAllMocks();
61
47
 
62
- createReactRef();
63
- expect(React.createRef).toHaveBeenCalled();
64
- expect(createRef).not.toHaveBeenCalled();
48
+ const ref = createReactRef();
49
+ expect(ref).toHaveProperty("current");
65
50
  });
66
51
 
67
52
  it("calls the polyfill if React.createRef doesn't exist", () => {
68
- jest.resetModules();
69
-
70
- jest.doMock("react", () => ({
71
- ...jest.requireActual("react"),
72
- createRef: undefined,
73
- }));
74
-
75
- createReactRef();
76
- expect(createRef).toHaveBeenCalled();
53
+ jest.clearAllMocks();
54
+ const originalCreateRef = React.createRef;
55
+ React.createRef = undefined;
56
+ const ref = createReactRef();
57
+ expect(ref).toHaveProperty("current");
58
+ React.createRef = originalCreateRef;
77
59
  });
78
60
  });
79
61
 
@@ -1,104 +1,104 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`createContextSetters when no state validator is provided calls setState when the setters are called, no matter what the value is 1`] = `
4
- Object {
4
+ {
5
5
  "bar": "bar",
6
6
  "foo": "foo",
7
7
  }
8
8
  `;
9
9
 
10
10
  exports[`createContextSetters when no state validator is provided calls setState when the setters are called, no matter what the value is 2`] = `
11
- Object {
11
+ {
12
12
  "bar": "bar",
13
13
  "foo": "invalid foo",
14
14
  }
15
15
  `;
16
16
 
17
17
  exports[`createContextSetters when no state validator is provided calls setState when the setters are called, no matter what the value is 3`] = `
18
- Object {
18
+ {
19
19
  "bar": "invalid bar",
20
20
  "foo": "invalid foo",
21
21
  }
22
22
  `;
23
23
 
24
24
  exports[`createContextSetters when no state validator is provided calls setState when the setters are called, no matter what the value is 4`] = `
25
- Array [
26
- Array [
25
+ [
26
+ [
27
27
  [Function],
28
28
  ],
29
- Array [
29
+ [
30
30
  [Function],
31
31
  ],
32
32
  ]
33
33
  `;
34
34
 
35
35
  exports[`createContextSetters when state validator is provided calls setState when the setters are called & the validator passes 1`] = `
36
- Object {
36
+ {
37
37
  "bar": "bar",
38
38
  "foo": "foo",
39
39
  }
40
40
  `;
41
41
 
42
42
  exports[`createContextSetters when state validator is provided calls setState when the setters are called & the validator passes 2`] = `
43
- Object {
43
+ {
44
44
  "bar": "bar",
45
45
  "foo": "new foo",
46
46
  }
47
47
  `;
48
48
 
49
49
  exports[`createContextSetters when state validator is provided calls setState when the setters are called & the validator passes 3`] = `
50
- Object {
50
+ {
51
51
  "bar": "new bar",
52
52
  "foo": "new foo",
53
53
  }
54
54
  `;
55
55
 
56
56
  exports[`createContextSetters when state validator is provided calls setState when the setters are called & the validator passes 4`] = `
57
- Array [
58
- Array [
57
+ [
58
+ [
59
59
  [Function],
60
60
  ],
61
- Array [
61
+ [
62
62
  [Function],
63
63
  ],
64
64
  ]
65
65
  `;
66
66
 
67
67
  exports[`createContextSetters when state validator is provided skips the update if the new value is the same as the previous one 1`] = `
68
- Object {
68
+ {
69
69
  "bar": "bar",
70
70
  "foo": "new foo",
71
71
  }
72
72
  `;
73
73
 
74
74
  exports[`createContextSetters when state validator is provided skips the update if the state validator doesn't pass 1`] = `
75
- Object {
75
+ {
76
76
  "bar": "bar",
77
77
  "foo": "foo",
78
78
  }
79
79
  `;
80
80
 
81
81
  exports[`createContextSetters when state validator is provided skips the update if the state validator doesn't pass 2`] = `
82
- Object {
82
+ {
83
83
  "bar": "bar",
84
84
  "foo": "foo",
85
85
  }
86
86
  `;
87
87
 
88
88
  exports[`createContextSetters when state validator is provided skips the update if the state validator doesn't pass 3`] = `
89
- Object {
89
+ {
90
90
  "bar": "bar",
91
91
  "foo": "foo",
92
92
  }
93
93
  `;
94
94
 
95
95
  exports[`createContextSetters when state validator is provided skips the update if the state validator doesn't pass 4`] = `
96
- Array [
97
- Array [
96
+ [
97
+ [
98
98
  "trying to invoke setFoo with invalid foo - but it was rejected by the state validator
99
99
  skipping context update",
100
100
  ],
101
- Array [
101
+ [
102
102
  "trying to invoke setBar with invalid bar - but it was rejected by the state validator
103
103
  skipping context update",
104
104
  ],
@@ -1,10 +1,10 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`createContext - when React has the new context API returns the components and the decorators 1`] = `
4
- Object {
4
+ {
5
5
  "Consumer": [MockFunction],
6
6
  "Provider": [MockFunction],
7
- "ReactContext": Object {
7
+ "ReactContext": {
8
8
  "Consumer": [MockFunction],
9
9
  "Provider": [MockFunction],
10
10
  },
@@ -3,7 +3,7 @@
3
3
  exports[`createProvider creates a context Provider component 1`] = `
4
4
  <mockConstructor
5
5
  value={
6
- Object {
6
+ {
7
7
  "context": "initialValue",
8
8
  "otherContext": "otherValue",
9
9
  "setContext": [Function],
@@ -18,11 +18,11 @@ exports[`createProvider creates a context Provider component 1`] = `
18
18
  `;
19
19
 
20
20
  exports[`createProvider creates a context Provider component 2`] = `
21
- Object {
21
+ {
22
22
  "children": <MockChild
23
23
  context="context"
24
24
  />,
25
- "value": Object {
25
+ "value": {
26
26
  "context": "initialValue",
27
27
  "otherContext": "otherValue",
28
28
  "setContext": [Function],
@@ -9,13 +9,13 @@ function stateValidator({ property, value }) {
9
9
  );
10
10
  }
11
11
 
12
- const logger = {
12
+ const mockLogger = {
13
13
  warning: jest.fn(),
14
14
  };
15
15
 
16
16
  jest.mock("../../logger", () => ({
17
17
  reactUtilsLogger: {
18
- addSubsystem: jest.fn(() => logger),
18
+ addSubsystem: jest.fn(() => mockLogger),
19
19
  },
20
20
  }));
21
21
 
@@ -62,7 +62,7 @@ describe("createContextSetters", () => {
62
62
  beforeEach(() => {
63
63
  instance.resetInitialState();
64
64
  setStateSpy.mockClear();
65
- logger.warning.mockClear();
65
+ mockLogger.warning.mockClear();
66
66
  });
67
67
 
68
68
  it("adds all properties and setters to the component", () => {
@@ -83,7 +83,7 @@ describe("createContextSetters", () => {
83
83
 
84
84
  expect(setStateSpy).toHaveBeenCalledTimes(2);
85
85
  expect(setStateSpy.mock.calls).toMatchSnapshot();
86
- expect(logger.warning).not.toHaveBeenCalled();
86
+ expect(mockLogger.warning).not.toHaveBeenCalled();
87
87
  });
88
88
 
89
89
  it("skips the update if the state validator doesn't pass", () => {
@@ -96,8 +96,8 @@ describe("createContextSetters", () => {
96
96
  expect(instance.state).toMatchSnapshot();
97
97
 
98
98
  expect(setStateSpy).not.toHaveBeenCalled();
99
- expect(logger.warning).toHaveBeenCalledTimes(2);
100
- expect(logger.warning.mock.calls).toMatchSnapshot();
99
+ expect(mockLogger.warning).toHaveBeenCalledTimes(2);
100
+ expect(mockLogger.warning.mock.calls).toMatchSnapshot();
101
101
  });
102
102
 
103
103
  it("skips the update if the new value is the same as the previous one", () => {
@@ -131,7 +131,7 @@ describe("createContextSetters", () => {
131
131
 
132
132
  afterEach(() => {
133
133
  setStateSpy.mockClear();
134
- logger.warning.mockClear();
134
+ mockLogger.warning.mockClear();
135
135
  });
136
136
 
137
137
  it("adds all properties and setters to the component", () => {
@@ -152,7 +152,7 @@ describe("createContextSetters", () => {
152
152
 
153
153
  expect(setStateSpy).toHaveBeenCalledTimes(2);
154
154
  expect(setStateSpy.mock.calls).toMatchSnapshot();
155
- expect(logger.warning).not.toHaveBeenCalled();
155
+ expect(mockLogger.warning).not.toHaveBeenCalled();
156
156
  });
157
157
  });
158
158
  });