@applicaster/zapp-react-native-utils 15.1.0-rc.8 → 16.0.0-alpha.1833861900

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 (147) hide show
  1. package/README.md +0 -6
  2. package/actionUtils/index.ts +7 -0
  3. package/actionsExecutor/ActionExecutorContext.tsx +43 -12
  4. package/actionsExecutor/feedDecorator.ts +6 -6
  5. package/adsUtils/__tests__/createVMAP.test.ts +419 -0
  6. package/adsUtils/index.ts +2 -2
  7. package/analyticsUtils/PlayerAnalyticsManager.ts +11 -1
  8. package/analyticsUtils/README.md +1 -1
  9. package/analyticsUtils/playerAnalyticsTracker.ts +26 -3
  10. package/appDataUtils/__tests__/urlScheme.test.ts +678 -0
  11. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +0 -188
  12. package/appUtils/HooksManager/__tests__/hooksManager.test.js +16 -2
  13. package/appUtils/HooksManager/index.ts +15 -26
  14. package/appUtils/RiverFocusManager/{index.js → index.ts} +25 -18
  15. package/appUtils/accessibilityManager/const.ts +4 -0
  16. package/appUtils/accessibilityManager/utils.ts +0 -1
  17. package/appUtils/contextKeysManager/__tests__/getKeys/failure.test.ts +7 -2
  18. package/appUtils/contextKeysManager/__tests__/getKeys/success.test.ts +48 -0
  19. package/appUtils/contextKeysManager/contextResolver.ts +51 -22
  20. package/appUtils/contextKeysManager/index.ts +65 -10
  21. package/appUtils/contextKeysManager/utils/index.ts +38 -25
  22. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +3 -0
  23. package/appUtils/focusManager/index.ios.ts +43 -4
  24. package/appUtils/focusManager/treeDataStructure/Tree/__tests__/Tree.test.js +46 -0
  25. package/appUtils/focusManager/treeDataStructure/Tree/index.js +18 -18
  26. package/appUtils/focusManagerAux/utils/index.ios.ts +122 -0
  27. package/appUtils/focusManagerAux/utils/index.ts +11 -3
  28. package/appUtils/focusManagerAux/utils/utils.ios.ts +202 -3
  29. package/appUtils/keyCodes/keys/keys.web.ts +1 -4
  30. package/appUtils/orientationHelper.ts +2 -4
  31. package/appUtils/platform/platformUtils.ts +12 -1
  32. package/appUtils/playerManager/player.ts +4 -0
  33. package/appUtils/playerManager/playerNative.ts +30 -21
  34. package/appUtils/playerManager/usePlayerState.tsx +14 -2
  35. package/cloudEventsUtils/__tests__/index.test.ts +529 -0
  36. package/cloudEventsUtils/index.ts +65 -1
  37. package/componentsUtils/index.ts +8 -0
  38. package/configurationUtils/__tests__/manifestKeyParser.test.ts +26 -26
  39. package/enumUtils/__tests__/getEnumKeyByEnumValue.test.ts +207 -0
  40. package/errorUtils/__tests__/GeneralError.test.ts +97 -0
  41. package/errorUtils/__tests__/HttpStatusCode.test.ts +344 -0
  42. package/errorUtils/__tests__/MissingPluginError.test.ts +113 -0
  43. package/errorUtils/__tests__/NetworkError.test.ts +202 -0
  44. package/errorUtils/__tests__/getParsedResponse.test.ts +188 -0
  45. package/errorUtils/__tests__/invariant.test.ts +112 -0
  46. package/focusManager/aux/index.ts +1 -1
  47. package/headersUtils/__tests__/headersUtils.test.js +11 -1
  48. package/headersUtils/index.ts +2 -1
  49. package/manifestUtils/_internals/__tests__/index.test.js +41 -0
  50. package/manifestUtils/_internals/index.js +33 -0
  51. package/manifestUtils/defaultManifestConfigurations/player.js +59 -1
  52. package/manifestUtils/fieldUtils/__tests__/fieldUtils.test.js +49 -0
  53. package/manifestUtils/fieldUtils/index.js +54 -0
  54. package/manifestUtils/index.js +3 -1
  55. package/manifestUtils/keys.js +228 -0
  56. package/manifestUtils/mobileAction/button/__tests__/mobileActionButton.test.js +168 -0
  57. package/manifestUtils/mobileAction/button/index.js +140 -0
  58. package/manifestUtils/mobileAction/container/__tests__/mobileActionButtonsContainer.test.js +102 -0
  59. package/manifestUtils/mobileAction/container/index.js +73 -0
  60. package/manifestUtils/mobileAction/groups/__tests__/buildMobileActionButtonGroups.test.js +127 -0
  61. package/manifestUtils/mobileAction/groups/defaults.js +76 -0
  62. package/manifestUtils/mobileAction/groups/index.js +80 -0
  63. package/manifestUtils/tvAction/container/index.js +1 -1
  64. package/numberUtils/__tests__/toNumber.test.ts +27 -0
  65. package/numberUtils/__tests__/toPositiveNumber.test.ts +193 -0
  66. package/numberUtils/index.ts +23 -1
  67. package/package.json +4 -4
  68. package/playerUtils/index.ts +4 -2
  69. package/pluginUtils/index.ts +4 -0
  70. package/reactHooks/advertising/index.ts +2 -2
  71. package/reactHooks/analytics/__tests__/useSendAnalyticsOnPress.test.ts +537 -0
  72. package/reactHooks/app/__tests__/useAppState.test.ts +1 -1
  73. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
  74. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +1 -2
  75. package/reactHooks/cell-click/__tests__/index.test.js +1 -3
  76. package/reactHooks/cell-click/index.ts +2 -1
  77. package/reactHooks/configuration/__tests__/index.test.tsx +1 -1
  78. package/reactHooks/connection/__tests__/index.test.js +1 -1
  79. package/reactHooks/debugging/__tests__/index.test.js +4 -4
  80. package/reactHooks/dev/__tests__/useReRenderLog.test.ts +188 -0
  81. package/reactHooks/device/useIsTablet.tsx +14 -19
  82. package/reactHooks/device/useMemoizedIsTablet.ts +3 -3
  83. package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +32 -23
  84. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +19 -19
  85. package/reactHooks/feed/__tests__/useEntryScreenId.test.tsx +4 -1
  86. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +42 -30
  87. package/reactHooks/feed/__tests__/useInflatedUrl.test.tsx +1 -1
  88. package/reactHooks/feed/index.ts +0 -2
  89. package/reactHooks/feed/useBatchLoading.ts +7 -1
  90. package/reactHooks/feed/useEntryScreenId.ts +2 -2
  91. package/reactHooks/feed/usePipesCacheReset.ts +3 -1
  92. package/reactHooks/flatList/useLoadNextPageIfNeeded.ts +13 -16
  93. package/reactHooks/layout/__tests__/index.test.tsx +1 -1
  94. package/reactHooks/layout/__tests__/useLayoutVersion.test.tsx +1 -1
  95. package/reactHooks/layout/useDimensions/__tests__/{useDimensions.test.ts → useDimensions.test.tsx} +105 -25
  96. package/reactHooks/layout/useDimensions/useDimensions.ts +2 -2
  97. package/reactHooks/navigation/__tests__/index.test.tsx +2 -4
  98. package/reactHooks/navigation/index.ts +7 -6
  99. package/reactHooks/navigation/useRoute.ts +8 -6
  100. package/reactHooks/player/TVSeekControlller/TVSeekController.ts +27 -10
  101. package/reactHooks/player/__tests__/useAutoSeek._test.tsx +1 -1
  102. package/reactHooks/player/__tests__/useTapSeek._test.ts +1 -1
  103. package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +1 -1
  104. package/reactHooks/resolvers/__tests__/useComponentResolver.test.tsx +1 -1
  105. package/reactHooks/resolvers/useCellResolver.ts +6 -2
  106. package/reactHooks/resolvers/useComponentResolver.ts +8 -2
  107. package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +2 -2
  108. package/reactHooks/screen/__tests__/useIsStandaloneFullscreen.test.ts +114 -0
  109. package/reactHooks/screen/__tests__/useScreenBackgroundColor.test.tsx +1 -1
  110. package/reactHooks/screen/__tests__/useScreenData.test.tsx +1 -1
  111. package/reactHooks/screen/__tests__/useTargetScreenData.test.tsx +12 -4
  112. package/reactHooks/screen/useTargetScreenData.ts +4 -2
  113. package/reactHooks/state/useRivers.ts +1 -1
  114. package/reactHooks/ui/__tests__/useFadeOutWhenBlurred.test.ts +580 -0
  115. package/reactHooks/usePluginConfiguration.ts +2 -2
  116. package/reactHooks/utils/__tests__/index.test.js +1 -1
  117. package/rectUtils/__tests__/index.test.ts +549 -0
  118. package/rectUtils/index.ts +2 -2
  119. package/refreshUtils/RefreshCoordinator/__tests__/refreshCoordinator.test.ts +206 -0
  120. package/refreshUtils/RefreshCoordinator/index.ts +245 -0
  121. package/refreshUtils/RefreshCoordinator/utils/__tests__/getDataRefreshConfig.test.ts +104 -0
  122. package/refreshUtils/RefreshCoordinator/utils/index.ts +29 -0
  123. package/screenPickerUtils/__tests__/index.test.ts +333 -0
  124. package/screenState/__tests__/index.test.ts +1 -1
  125. package/screenUtils/index.ts +3 -0
  126. package/searchUtils/const.ts +7 -0
  127. package/searchUtils/index.ts +3 -0
  128. package/stringUtils/index.ts +1 -1
  129. package/testUtils/index.tsx +30 -21
  130. package/time/__tests__/BackgroundTimer.test.ts +156 -0
  131. package/time/__tests__/Timer.test.ts +236 -0
  132. package/typeGuards/__tests__/isString.test.ts +21 -0
  133. package/typeGuards/index.ts +4 -0
  134. package/utils/__tests__/mergeRight.test.ts +48 -0
  135. package/utils/__tests__/path.test.ts +7 -0
  136. package/utils/__tests__/selectors.test.ts +124 -0
  137. package/utils/index.ts +13 -0
  138. package/utils/mergeRight.ts +5 -0
  139. package/utils/path.ts +6 -3
  140. package/utils/pathOr.ts +5 -1
  141. package/utils/selectors.ts +46 -0
  142. package/zappFrameworkUtils/HookCallback/callbackNavigationAction.ts +1 -1
  143. package/zappFrameworkUtils/HookCallback/hookCallbackManifestExtensions.config.js +1 -1
  144. package/zappFrameworkUtils/loginPluginUtils.ts +1 -1
  145. package/reactHooks/componentsMap/index.ts +0 -55
  146. package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +0 -75
  147. package/reactHooks/feed/useFeedRefresh.tsx +0 -65
@@ -54,7 +54,7 @@ export const useCellClick = ({
54
54
  component?.rules?.component_cells_selectable
55
55
  );
56
56
 
57
- const [__, setEntryContext] =
57
+ const [entryContext, setEntryContext] =
58
58
  ZappPipesEntryContext.useZappPipesContext(pathname);
59
59
 
60
60
  const logTimestamp = useProfilerLogging();
@@ -89,6 +89,7 @@ export const useCellClick = ({
89
89
  screenState,
90
90
  screenRoute: pathname,
91
91
  screenStateStore,
92
+ entryContext,
92
93
  });
93
94
  }
94
95
 
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  import React from "react";
3
- import { renderHook, cleanup } from "@testing-library/react-hooks";
3
+ import { renderHook, cleanup } from "@testing-library/react-native";
4
4
  import { ConfigurationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ConfigutaionContext";
5
5
  import { useConfiguration } from "@applicaster/zapp-react-native-utils/reactHooks/configuration";
6
6
 
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { renderHook, cleanup } from "@testing-library/react-hooks";
2
+ import { renderHook, cleanup } from "@testing-library/react-native";
3
3
  import { NetworkStatusContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NetworkStatusContext";
4
4
 
5
5
  const MockNetInfo = {
@@ -27,20 +27,20 @@ describe("Debug utils", () => {
27
27
  it("should create new timer if timer with a label does not exist", () => {
28
28
  performanceNowMock.mockReturnValue(1000);
29
29
  time("timer1");
30
- expect(timers["timer1"]).toBeDefined();
31
- expect(timers["timer1"].startTime).toBe(1000);
30
+ expect(timers.timer1).toBeDefined();
31
+ expect(timers.timer1.startTime).toBe(1000);
32
32
  });
33
33
 
34
34
  it("should update start time of timer if timer with a label exists", () => {
35
35
  // First call to time()
36
36
  performanceNowMock.mockReturnValue(1000);
37
37
  time("timer1");
38
- const previousStartTime = timers["timer1"].startTime;
38
+ const previousStartTime = timers.timer1.startTime;
39
39
 
40
40
  // Second call to time()
41
41
  performanceNowMock.mockReturnValue(2000);
42
42
  time("timer1");
43
- const currentStartTime = timers["timer1"].startTime;
43
+ const currentStartTime = timers.timer1.startTime;
44
44
 
45
45
  expect(previousStartTime).toBe(1000);
46
46
  expect(currentStartTime).toBe(2000);
@@ -0,0 +1,188 @@
1
+ import { renderHook } from "@testing-library/react-native";
2
+ import { useReRenderLog } from "../index";
3
+
4
+ describe("useReRenderLog", () => {
5
+ let consoleLogSpy: jest.SpyInstance;
6
+
7
+ beforeEach(() => {
8
+ consoleLogSpy = jest.spyOn(console, "log").mockImplementation();
9
+ });
10
+
11
+ afterEach(() => {
12
+ consoleLogSpy.mockRestore();
13
+ });
14
+
15
+ it("should log on initial render", () => {
16
+ const message = "Test Component";
17
+
18
+ renderHook(() => useReRenderLog(message));
19
+
20
+ expect(consoleLogSpy).toHaveBeenCalledWith(
21
+ expect.stringContaining("<<RE-RENDERED>>")
22
+ );
23
+
24
+ expect(consoleLogSpy).toHaveBeenCalledWith(
25
+ expect.stringContaining("<<COUNT: 1>>")
26
+ );
27
+
28
+ expect(consoleLogSpy).toHaveBeenCalledWith(
29
+ expect.stringContaining(message)
30
+ );
31
+ });
32
+
33
+ it("should increment count on each re-render", () => {
34
+ const message = "Counter Test";
35
+
36
+ const { rerender } = renderHook(() => useReRenderLog(message));
37
+
38
+ expect(consoleLogSpy).toHaveBeenCalledWith(
39
+ expect.stringContaining("<<COUNT: 1>>")
40
+ );
41
+
42
+ rerender();
43
+
44
+ expect(consoleLogSpy).toHaveBeenCalledWith(
45
+ expect.stringContaining("<<COUNT: 2>>")
46
+ );
47
+
48
+ rerender();
49
+
50
+ expect(consoleLogSpy).toHaveBeenCalledWith(
51
+ expect.stringContaining("<<COUNT: 3>>")
52
+ );
53
+ });
54
+
55
+ it("should log correct message format", () => {
56
+ const message = "MyComponent";
57
+
58
+ renderHook(() => useReRenderLog(message));
59
+
60
+ expect(consoleLogSpy).toHaveBeenCalledWith(
61
+ "<<RE-RENDERED>><<COUNT: 1>>: MyComponent"
62
+ );
63
+ });
64
+
65
+ it("should track renders independently for different hook instances", () => {
66
+ const message1 = "Component1";
67
+ const message2 = "Component2";
68
+
69
+ const { rerender: rerender1 } = renderHook(() => useReRenderLog(message1));
70
+
71
+ const { rerender: rerender2 } = renderHook(() => useReRenderLog(message2));
72
+
73
+ consoleLogSpy.mockClear();
74
+
75
+ rerender1();
76
+
77
+ expect(consoleLogSpy).toHaveBeenLastCalledWith(
78
+ expect.stringContaining("Component1")
79
+ );
80
+
81
+ rerender2();
82
+
83
+ expect(consoleLogSpy).toHaveBeenLastCalledWith(
84
+ expect.stringContaining("Component2")
85
+ );
86
+ });
87
+
88
+ it("should handle empty string message", () => {
89
+ renderHook(() => useReRenderLog(""));
90
+
91
+ expect(consoleLogSpy).toHaveBeenCalledWith("<<RE-RENDERED>><<COUNT: 1>>: ");
92
+ });
93
+
94
+ it("should handle message with special characters", () => {
95
+ const message = "Test!@#$%^&*()";
96
+
97
+ renderHook(() => useReRenderLog(message));
98
+
99
+ expect(consoleLogSpy).toHaveBeenCalledWith(
100
+ expect.stringContaining(message)
101
+ );
102
+ });
103
+
104
+ it("should handle long messages", () => {
105
+ const message = "A".repeat(1000);
106
+
107
+ renderHook(() => useReRenderLog(message));
108
+
109
+ expect(consoleLogSpy).toHaveBeenCalledWith(
110
+ expect.stringContaining(message)
111
+ );
112
+ });
113
+
114
+ it("should persist count across multiple re-renders", () => {
115
+ const message = "Persistence Test";
116
+
117
+ const { rerender } = renderHook(() => useReRenderLog(message));
118
+
119
+ for (let i = 2; i <= 10; i++) {
120
+ rerender();
121
+
122
+ expect(consoleLogSpy).toHaveBeenLastCalledWith(
123
+ expect.stringContaining(`<<COUNT: ${i}>>`)
124
+ );
125
+ }
126
+ });
127
+
128
+ it("should log on every render without dependencies", () => {
129
+ const message = "Every Render";
130
+
131
+ const { rerender } = renderHook(() => useReRenderLog(message));
132
+
133
+ const initialCallCount = consoleLogSpy.mock.calls.length;
134
+
135
+ rerender();
136
+ rerender();
137
+ rerender();
138
+
139
+ // Should have 4 total calls (initial + 3 rerenders)
140
+ expect(consoleLogSpy).toHaveBeenCalledTimes(initialCallCount + 3);
141
+ });
142
+
143
+ it("should handle numeric messages", () => {
144
+ renderHook(() => useReRenderLog(123 as any));
145
+
146
+ expect(consoleLogSpy).toHaveBeenCalledWith(expect.stringContaining("123"));
147
+ });
148
+
149
+ it("should handle object messages", () => {
150
+ const obj = { key: "value" };
151
+
152
+ renderHook(() => useReRenderLog(obj as any));
153
+
154
+ expect(consoleLogSpy).toHaveBeenCalled();
155
+ });
156
+
157
+ it("should maintain separate refs for each instance", () => {
158
+ const { rerender: rerender1 } = renderHook(() =>
159
+ useReRenderLog("Instance1")
160
+ );
161
+
162
+ const { rerender: rerender2 } = renderHook(() =>
163
+ useReRenderLog("Instance2")
164
+ );
165
+
166
+ consoleLogSpy.mockClear();
167
+
168
+ // Render instance 1 twice more
169
+ rerender1();
170
+ rerender1();
171
+
172
+ // Render instance 2 once more
173
+ rerender2();
174
+
175
+ const calls = consoleLogSpy.mock.calls;
176
+
177
+ // Instance 1 should be at count 2 and 3
178
+ expect(calls[0][0]).toContain("Instance1");
179
+ expect(calls[0][0]).toContain("<<COUNT: 2>>");
180
+
181
+ expect(calls[1][0]).toContain("Instance1");
182
+ expect(calls[1][0]).toContain("<<COUNT: 3>>");
183
+
184
+ // Instance 2 should be at count 2
185
+ expect(calls[2][0]).toContain("Instance2");
186
+ expect(calls[2][0]).toContain("<<COUNT: 2>>");
187
+ });
188
+ });
@@ -1,28 +1,23 @@
1
1
  /* eslint react-native/split-platform-components: off */
2
2
 
3
3
  import { Platform, PlatformIOSStatic, NativeModules } from "react-native";
4
- import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
5
- import { F as alwaysFalse } from "ramda";
6
4
  import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
7
5
 
8
- const useIsTabletIos = (): boolean => {
9
- const { isPad } = Platform as PlatformIOSStatic;
6
+ export const useIsTablet = (): boolean => {
7
+ const platform = Platform.OS;
10
8
 
11
- return isPad;
12
- };
9
+ if (platform === "ios") {
10
+ const { isPad } = Platform as PlatformIOSStatic;
13
11
 
14
- const useIsTabletAndroid = (): boolean => {
15
- const { initialProps } = NativeModules.QuickBrickCommunicationModule;
12
+ return Boolean(isPad);
13
+ }
16
14
 
17
- return toBooleanWithDefaultFalse(initialProps?.is_tablet);
18
- };
15
+ if (platform === "android") {
16
+ const initialProps =
17
+ NativeModules.QuickBrickCommunicationModule?.initialProps;
19
18
 
20
- export const useIsTablet = platformSelect({
21
- ios: useIsTabletIos,
22
- android: useIsTabletAndroid,
23
- lg_tv: alwaysFalse,
24
- samsung_tv: alwaysFalse,
25
- android_tv: alwaysFalse,
26
- tvos: alwaysFalse,
27
- default: alwaysFalse,
28
- });
19
+ return toBooleanWithDefaultFalse(initialProps?.is_tablet);
20
+ }
21
+
22
+ return false;
23
+ };
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
3
2
  import { useIsTablet } from "./useIsTablet";
3
+ import { useAppData } from "@applicaster/zapp-react-native-redux";
4
4
 
5
5
  export const useMemoizedIsTablet = () => {
6
6
  const isTablet = useIsTablet();
@@ -14,9 +14,9 @@ export const useMemoizedIsTablet = () => {
14
14
  };
15
15
 
16
16
  export const useIsTabletLandscape = (): boolean => {
17
- const { appData } = usePickFromState(["appData"]);
17
+ const { isTabletPortrait } = useAppData();
18
18
 
19
19
  const isTablet = useIsTablet();
20
20
 
21
- return isTablet && !appData.isTabletPortrait;
21
+ return isTablet && !isTabletPortrait;
22
22
  };
@@ -1,8 +1,7 @@
1
- import { renderHook } from "@testing-library/react-hooks";
1
+ import { renderHook, waitFor } from "@testing-library/react-native";
2
2
  import { allFeedsIsReady, useBatchLoading } from "../useBatchLoading";
3
3
  import { WrappedWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
4
4
  import { appStore } from "@applicaster/zapp-react-native-redux/AppStore";
5
- import { waitFor } from "@testing-library/react-native";
6
5
 
7
6
  jest.mock("../../navigation");
8
7
 
@@ -16,7 +15,11 @@ jest.mock(
16
15
  })
17
16
  );
18
17
 
19
- const wrapper = WrappedWithProviders;
18
+ const getWrapper =
19
+ (store) =>
20
+ ({ children }) => (
21
+ <WrappedWithProviders store={store}>{children}</WrappedWithProviders>
22
+ );
20
23
 
21
24
  describe("useBatchLoading", () => {
22
25
  const data = [
@@ -63,8 +66,7 @@ describe("useBatchLoading", () => {
63
66
  const riverId = "123";
64
67
 
65
68
  renderHook(() => useBatchLoading(data, { initialBatchSize, riverId }), {
66
- wrapper,
67
- initialProps: { store },
69
+ wrapper: getWrapper(store),
68
70
  });
69
71
 
70
72
  const actions = (appStore.getStore() as any).getActions();
@@ -84,7 +86,7 @@ describe("useBatchLoading", () => {
84
86
  });
85
87
  });
86
88
 
87
- it("loadPipesData start loading new feed when 1 feed is done loading and 1 is in loading state", () => {
89
+ it("loadPipesData start loading new feed when 1 feed is done loading and 1 is in loading state", async () => {
88
90
  const store = {
89
91
  zappPipes: {
90
92
  url1: {
@@ -110,13 +112,14 @@ describe("useBatchLoading", () => {
110
112
  const riverId = "123";
111
113
 
112
114
  renderHook(() => useBatchLoading(data, { initialBatchSize, riverId }), {
113
- wrapper,
114
- initialProps: { store },
115
+ wrapper: getWrapper(store),
115
116
  });
116
117
 
117
118
  const actions = (appStore.getStore() as any).getActions();
118
119
 
119
- expect(actions).toHaveLength(1);
120
+ await waitFor(() => {
121
+ expect(actions).toHaveLength(1);
122
+ });
120
123
 
121
124
  expect(actions[0]).toMatchObject({
122
125
  type: "ZAPP_PIPES_REQUEST_START",
@@ -124,7 +127,7 @@ describe("useBatchLoading", () => {
124
127
  });
125
128
  });
126
129
 
127
- it("loadPipesData has been called when no data cached", () => {
130
+ it("loadPipesData has been called when no data cached", async () => {
128
131
  const store = {
129
132
  zappPipes: {},
130
133
  test: "true",
@@ -134,16 +137,17 @@ describe("useBatchLoading", () => {
134
137
  const riverId = "123";
135
138
 
136
139
  renderHook(() => useBatchLoading(data, { initialBatchSize, riverId }), {
137
- wrapper,
138
- initialProps: { store },
140
+ wrapper: getWrapper(store),
139
141
  });
140
142
 
141
143
  const actions = (appStore.getStore() as any).getActions();
142
144
 
143
- expect(actions).toHaveLength(3);
145
+ await waitFor(() => {
146
+ expect(actions).toHaveLength(3);
147
+ });
144
148
  });
145
149
 
146
- it("initial batch ready when all initial items loaded", () => {
150
+ it("initial batch ready when all initial items loaded", async () => {
147
151
  const store = {
148
152
  zappPipes: {
149
153
  url1: {
@@ -169,13 +173,15 @@ describe("useBatchLoading", () => {
169
173
 
170
174
  const { result } = renderHook(
171
175
  () => useBatchLoading(data, { initialBatchSize, riverId }),
172
- { wrapper, initialProps: { store } }
176
+ { wrapper: getWrapper(store) }
173
177
  );
174
178
 
175
- expect(result.current).toBe(true);
179
+ await waitFor(() => {
180
+ expect(result.current).toBe(true);
181
+ });
176
182
  });
177
183
 
178
- it("gallery-qb: loadPipesData should be called only once for first component in the gallery", () => {
184
+ it("gallery-qb: loadPipesData should be called only once for first component in the gallery", async () => {
179
185
  const store = {
180
186
  zappPipes: {},
181
187
  test: "true",
@@ -198,16 +204,17 @@ describe("useBatchLoading", () => {
198
204
  ];
199
205
 
200
206
  renderHook(() => useBatchLoading(data, { initialBatchSize, riverId }), {
201
- wrapper,
202
- initialProps: { store },
207
+ wrapper: getWrapper(store),
203
208
  });
204
209
 
205
210
  const actions = (appStore.getStore() as any).getActions();
206
211
 
207
- expect(actions).toHaveLength(1);
212
+ await waitFor(() => {
213
+ expect(actions).toHaveLength(1);
214
+ });
208
215
  });
209
216
 
210
- it("gallery-qb: initial batch ready when all initial items loaded", () => {
217
+ it("gallery-qb: initial batch ready when all initial items loaded", async () => {
211
218
  const store = {
212
219
  zappPipes: {
213
220
  url1: {
@@ -233,10 +240,12 @@ describe("useBatchLoading", () => {
233
240
 
234
241
  const { result } = renderHook(
235
242
  () => useBatchLoading(data, { initialBatchSize, riverId }),
236
- { wrapper, initialProps: { store } }
243
+ { wrapper: getWrapper(store) }
237
244
  );
238
245
 
239
- expect(result.current).toBe(true);
246
+ await waitFor(() => {
247
+ expect(result.current).toBe(true);
248
+ });
240
249
  });
241
250
  });
242
251
 
@@ -1,4 +1,4 @@
1
- import { renderHook } from "@testing-library/react-hooks";
1
+ import { renderHook, waitFor } from "@testing-library/react-native";
2
2
  import { encodeParams } from "@applicaster/zapp-pipes-v2-client/src/utils";
3
3
 
4
4
  const appData = {
@@ -42,26 +42,26 @@ describe("useBuildPipesUrl", () => {
42
42
  build: jest.fn(() => Promise.resolve(buildResult)),
43
43
  };
44
44
 
45
- const { result, waitForNextUpdate } = renderHook(() =>
45
+ const { result } = renderHook(() =>
46
46
  useBuildPipesUrl({ url, mapping, requestBuilder: mockedRequestBuilder })
47
47
  );
48
48
 
49
49
  expect(result.current.url).toBe("http://foo.com/show/show-1");
50
50
  expect(result.current.requestParams).toBeNull();
51
51
 
52
- await waitForNextUpdate();
53
-
54
- expect(result.current.requestParams).toEqual(
55
- expect.objectContaining({
56
- params: {
57
- version: appData.version_name,
58
- ctx: encodeParams({ platform: appData.platform }),
59
- },
60
- headers: {
61
- SDK: appData.sdk_version,
62
- },
63
- })
64
- );
52
+ await waitFor(() => {
53
+ expect(result.current.requestParams).toEqual(
54
+ expect.objectContaining({
55
+ params: {
56
+ version: appData.version_name,
57
+ ctx: encodeParams({ platform: appData.platform }),
58
+ },
59
+ headers: {
60
+ SDK: appData.sdk_version,
61
+ },
62
+ })
63
+ );
64
+ });
65
65
  });
66
66
 
67
67
  it("returns empty object if url is not in endpoints", async () => {
@@ -81,15 +81,15 @@ describe("useBuildPipesUrl", () => {
81
81
  build: jest.fn(() => Promise.resolve(buildResult)),
82
82
  };
83
83
 
84
- const { result, waitForNextUpdate } = renderHook(() =>
84
+ const { result } = renderHook(() =>
85
85
  useBuildPipesUrl({ url, mapping, requestBuilder: mockedRequestBuilder })
86
86
  );
87
87
 
88
88
  expect(result.current.url).toBe("http://foobar.com/show-1");
89
89
  expect(result.current.requestParams).toBeNull();
90
90
 
91
- await waitForNextUpdate();
92
-
93
- expect(result.current.requestParams).toEqual({});
91
+ await waitFor(() => {
92
+ expect(result.current.requestParams).toEqual({});
93
+ });
94
94
  });
95
95
  });
@@ -1,6 +1,6 @@
1
1
  import * as R from "ramda";
2
2
  import React from "react";
3
- import { renderHook } from "@testing-library/react-hooks";
3
+ import { renderHook } from "@testing-library/react-native";
4
4
  import { Provider } from "react-redux";
5
5
  import { createStore } from "redux";
6
6
 
@@ -10,6 +10,9 @@ describe("useEntryScreenId", () => {
10
10
  const mappedScreenId = "mapped-id";
11
11
 
12
12
  const initialState = {
13
+ rivers: {
14
+ [mappedScreenId]: { id: mappedScreenId, type: "any" },
15
+ },
13
16
  contentTypes: { mappedEntry: { screen_id: mappedScreenId } },
14
17
  };
15
18