@applicaster/zapp-react-native-utils 14.0.0-alpha.2175196485 → 14.0.0-alpha.2292190333

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 (58) hide show
  1. package/actionsExecutor/ActionExecutorContext.tsx +60 -84
  2. package/actionsExecutor/ScreenActions.ts +164 -0
  3. package/actionsExecutor/StorageActions.ts +110 -0
  4. package/actionsExecutor/feedDecorator.ts +171 -0
  5. package/actionsExecutor/screenResolver.ts +11 -0
  6. package/analyticsUtils/AnalyticsEvents/helper.ts +1 -1
  7. package/analyticsUtils/__tests__/analyticsUtils.test.js +0 -11
  8. package/appUtils/contextKeysManager/contextResolver.ts +42 -1
  9. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +5 -0
  10. package/appUtils/focusManager/__tests__/focusManager.test.js +1 -1
  11. package/appUtils/focusManager/index.ios.ts +10 -0
  12. package/appUtils/focusManager/index.ts +82 -11
  13. package/appUtils/focusManager/treeDataStructure/Tree/index.js +1 -1
  14. package/appUtils/focusManagerAux/utils/index.ts +106 -3
  15. package/configurationUtils/__tests__/manifestKeyParser.test.ts +0 -1
  16. package/focusManager/FocusManager.ts +69 -4
  17. package/focusManager/aux/index.ts +170 -0
  18. package/navigationUtils/__tests__/mapContentTypesToRivers.test.ts +130 -0
  19. package/navigationUtils/index.ts +6 -4
  20. package/package.json +2 -3
  21. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +3 -1
  22. package/reactHooks/cell-click/__tests__/index.test.js +3 -0
  23. package/reactHooks/cell-click/index.ts +8 -1
  24. package/reactHooks/debugging/__tests__/index.test.js +0 -1
  25. package/reactHooks/feed/__tests__/useBatchLoading.test.tsx +8 -2
  26. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +71 -31
  27. package/reactHooks/feed/index.ts +2 -0
  28. package/reactHooks/feed/useBatchLoading.ts +15 -8
  29. package/reactHooks/feed/useFeedLoader.tsx +36 -34
  30. package/reactHooks/feed/useLoadPipesDataDispatch.ts +57 -0
  31. package/reactHooks/feed/usePipesCacheReset.ts +2 -2
  32. package/reactHooks/flatList/useSequentialRenderItem.tsx +3 -3
  33. package/reactHooks/layout/__tests__/index.test.tsx +3 -1
  34. package/reactHooks/layout/useDimensions/__tests__/useDimensions.test.ts +34 -36
  35. package/reactHooks/layout/useDimensions/useDimensions.ts +2 -3
  36. package/reactHooks/layout/useLayoutVersion.ts +5 -5
  37. package/reactHooks/navigation/useRoute.ts +7 -2
  38. package/reactHooks/navigation/useScreenStateStore.ts +8 -0
  39. package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +4 -0
  40. package/reactHooks/state/index.ts +1 -1
  41. package/reactHooks/state/useHomeRiver.ts +4 -2
  42. package/reactHooks/state/useRivers.ts +7 -8
  43. package/screenPickerUtils/index.ts +13 -0
  44. package/storage/ScreenSingleValueProvider.ts +204 -0
  45. package/storage/ScreenStateMultiSelectProvider.ts +293 -0
  46. package/storage/StorageMultiSelectProvider.ts +192 -0
  47. package/storage/StorageSingleSelectProvider.ts +108 -0
  48. package/time/BackgroundTimer.ts +1 -1
  49. package/utils/__tests__/find.test.ts +36 -0
  50. package/utils/__tests__/omit.test.ts +19 -0
  51. package/utils/__tests__/pathOr.test.ts +37 -0
  52. package/utils/__tests__/startsWith.test.ts +30 -0
  53. package/utils/endsWith.ts +9 -0
  54. package/utils/find.ts +3 -0
  55. package/utils/index.ts +12 -0
  56. package/utils/omit.ts +5 -0
  57. package/utils/pathOr.ts +5 -0
  58. package/utils/startsWith.ts +9 -0
@@ -0,0 +1,170 @@
1
+ import {
2
+ isNil,
3
+ startsWith,
4
+ find,
5
+ pathOr,
6
+ } from "@applicaster/zapp-react-native-utils/utils";
7
+
8
+ import {
9
+ QUICK_BRICK_CONTENT,
10
+ QUICK_BRICK_NAVBAR,
11
+ } from "@applicaster/quick-brick-core/const";
12
+
13
+ const isNavBar = (node) => startsWith(QUICK_BRICK_NAVBAR, node?.id);
14
+ const isContent = (node) => startsWith(QUICK_BRICK_CONTENT, node?.id);
15
+
16
+ // FIXME
17
+ const sectionIds = {
18
+ right: "nav-bar-right",
19
+ menu: "navbar-items",
20
+ left: "nav-bar-left",
21
+ };
22
+
23
+ // SCREEN_PICKER_SELECTOR_CONTAINER
24
+ let screenPickerSelectorContainerId;
25
+
26
+ export const onRegisterScreenPickerSelectorContainer = (id) => {
27
+ screenPickerSelectorContainerId = id;
28
+ };
29
+
30
+ export const onUnRegisterScreenPickerSelectorContainer = (id) => {
31
+ // reset screenSelectorId on unregistration
32
+ if (screenPickerSelectorContainerId === id) {
33
+ screenPickerSelectorContainerId = undefined;
34
+ }
35
+ };
36
+ // SCREEN_PICKER_SELECTOR_CONTAINER
37
+
38
+ // SCREEN_PICKER_CONTENT_CONTAINER
39
+ let screenPickerContentContainerId;
40
+
41
+ export const onRegisterScreenPickerContentContainer = (id) => {
42
+ screenPickerContentContainerId = id;
43
+ };
44
+
45
+ export const onUnRegisterScreenPickerContentContainer = (id) => {
46
+ // reset screenSelectorId on unregistration
47
+ if (screenPickerContentContainerId === id) {
48
+ screenPickerContentContainerId = undefined;
49
+ }
50
+ };
51
+
52
+ const isScreenPickerContentContainer = (node) =>
53
+ screenPickerContentContainerId === node?.id;
54
+
55
+ // SCREEN_PICKER_CONTENT_CONTAINER
56
+
57
+ const findSelectedMenuIdInSection = (focusableTree, section) => {
58
+ const children = pathOr([], ["children"], focusableTree.find(section));
59
+
60
+ return find((child) => child.component.current.props.isSelected(), children)
61
+ ?.id;
62
+ };
63
+
64
+ export const findSelectedMenuId = (focusableTree) => {
65
+ const selectedMenuItemIdInLeftSection = findSelectedMenuIdInSection(
66
+ focusableTree,
67
+ sectionIds.left
68
+ );
69
+
70
+ if (selectedMenuItemIdInLeftSection) {
71
+ return selectedMenuItemIdInLeftSection;
72
+ }
73
+
74
+ const selectedMenuItemIdInMenuSection = findSelectedMenuIdInSection(
75
+ focusableTree,
76
+ sectionIds.menu
77
+ );
78
+
79
+ if (selectedMenuItemIdInMenuSection) {
80
+ return selectedMenuItemIdInMenuSection;
81
+ }
82
+
83
+ const selectedMenuItemIdInRightSection = findSelectedMenuIdInSection(
84
+ focusableTree,
85
+ sectionIds.right
86
+ );
87
+
88
+ if (selectedMenuItemIdInRightSection) {
89
+ return selectedMenuItemIdInRightSection;
90
+ }
91
+
92
+ return undefined;
93
+ };
94
+
95
+ export const findSelectedTabId = (focusableTree, item: ZappEntry): string => {
96
+ const screenSelectorContainerNode = focusableTree.find(
97
+ screenPickerSelectorContainerId
98
+ );
99
+
100
+ // console.log("debug_2", "findSelectedTabId", {
101
+ // focusableTree,
102
+ // item,
103
+ // screenSelectorContainerNode,
104
+ // });
105
+
106
+ const selectedTabId = find(
107
+ (child) => child.component.current.props.isSelected(item.id),
108
+ screenSelectorContainerNode.children
109
+ )?.id;
110
+
111
+ return selectedTabId;
112
+ };
113
+
114
+ export const isTabsScreenContentFocused = (focusableTree, id) => {
115
+ const node = focusableTree.find(id);
116
+
117
+ if (isNil(node)) {
118
+ return false;
119
+ }
120
+
121
+ if (isNavBar(node)) {
122
+ return false;
123
+ }
124
+
125
+ if (isContent(node)) {
126
+ return false;
127
+ }
128
+
129
+ if (isScreenPickerContentContainer(node)) {
130
+ return true;
131
+ }
132
+
133
+ return isTabsScreenContentFocused(focusableTree, node.parentId);
134
+ };
135
+
136
+ export const isCurrentFocusOnMenu = (focusableTree, id): boolean => {
137
+ const node = focusableTree.find(id);
138
+
139
+ if (isNil(node)) {
140
+ return false;
141
+ }
142
+
143
+ if (isNavBar(node)) {
144
+ return true;
145
+ }
146
+
147
+ if (isContent(node)) {
148
+ return false;
149
+ }
150
+
151
+ return isCurrentFocusOnMenu(focusableTree, node.parentId);
152
+ };
153
+
154
+ export const isCurrentFocusOnContent = (focusableTree, id) => {
155
+ const node = focusableTree.find(id);
156
+
157
+ if (isNil(node)) {
158
+ return false;
159
+ }
160
+
161
+ if (isNavBar(node)) {
162
+ return false;
163
+ }
164
+
165
+ if (isContent(node)) {
166
+ return true;
167
+ }
168
+
169
+ return isCurrentFocusOnContent(focusableTree, node.parentId);
170
+ };
@@ -0,0 +1,130 @@
1
+ import { mapContentTypesToRivers } from "../index";
2
+
3
+ describe("mapContentTypesToRivers", () => {
4
+ it("should return the correct content types mapped to rivers", () => {
5
+ const state = {
6
+ rivers: {
7
+ "river-1": {
8
+ plugin_type: "river",
9
+ },
10
+ },
11
+ contentTypes: {
12
+ "content-type-1": {
13
+ screen_id: "river-1",
14
+ },
15
+ },
16
+ };
17
+
18
+ const result = mapContentTypesToRivers(state);
19
+
20
+ expect(result).toEqual({
21
+ "content-type-1": {
22
+ screenType: "river",
23
+ screen_id: "river-1",
24
+ },
25
+ });
26
+ });
27
+
28
+ it("should return null if contentTypes is undefined", () => {
29
+ const state = {
30
+ rivers: {
31
+ "river-1": {
32
+ plugin_type: "river",
33
+ },
34
+ },
35
+ // contentTypes is missing
36
+ };
37
+
38
+ const result = mapContentTypesToRivers(state);
39
+
40
+ expect(result).toBeNull();
41
+ });
42
+
43
+ it("should skip content types whose screen does not exist in rivers", () => {
44
+ const state = {
45
+ rivers: {
46
+ "river-1": {
47
+ plugin_type: "river",
48
+ },
49
+ },
50
+ contentTypes: {
51
+ "content-type-1": {
52
+ screen_id: "river-1",
53
+ },
54
+ "content-type-2": {
55
+ screen_id: "river-2", // river-2 does not exist
56
+ },
57
+ },
58
+ };
59
+
60
+ const result = mapContentTypesToRivers(state);
61
+
62
+ expect(result).toEqual({
63
+ "content-type-1": {
64
+ screenType: "river",
65
+ screen_id: "river-1",
66
+ },
67
+ });
68
+
69
+ // result is not null, but may be undefined for missing keys
70
+ expect(result && result["content-type-2"]).toBeUndefined();
71
+ });
72
+
73
+ it("should use 'type' if 'plugin_type' is not present in river", () => {
74
+ const state = {
75
+ rivers: {
76
+ "river-1": {
77
+ type: "custom-type",
78
+ },
79
+ },
80
+ contentTypes: {
81
+ "content-type-1": {
82
+ screen_id: "river-1",
83
+ },
84
+ },
85
+ };
86
+
87
+ const result = mapContentTypesToRivers(state);
88
+
89
+ expect(result).toEqual({
90
+ "content-type-1": {
91
+ screenType: "custom-type",
92
+ screen_id: "river-1",
93
+ },
94
+ });
95
+ });
96
+
97
+ it("should skip content types if neither plugin_type nor type is present in river", () => {
98
+ const state = {
99
+ rivers: {
100
+ "river-1": {
101
+ // no plugin_type or type
102
+ },
103
+ },
104
+ contentTypes: {
105
+ "content-type-1": {
106
+ screen_id: "river-1",
107
+ },
108
+ },
109
+ };
110
+
111
+ const result = mapContentTypesToRivers(state);
112
+
113
+ expect(result).toEqual({});
114
+ });
115
+
116
+ it("should handle empty contentTypes object", () => {
117
+ const state = {
118
+ rivers: {
119
+ "river-1": {
120
+ plugin_type: "river",
121
+ },
122
+ },
123
+ contentTypes: {},
124
+ };
125
+
126
+ const result = mapContentTypesToRivers(state);
127
+
128
+ expect(result).toEqual({});
129
+ });
130
+ });
@@ -13,6 +13,7 @@ import {
13
13
  isPlayable,
14
14
  isV2River,
15
15
  } from "./itemTypeMatchers";
16
+ import { RootState } from "@applicaster/zapp-react-native-redux/store";
16
17
 
17
18
  type PathAttribute = {
18
19
  screenType: string;
@@ -377,10 +378,11 @@ export const usesVideoModal = (
377
378
  return targetScreenConfiguration?.styles?.use_video_modal;
378
379
  };
379
380
 
380
- export const mapContentTypesToRivers = ({
381
- rivers,
382
- contentTypes,
383
- }): ZappContentTypesMapped | null => {
381
+ export const mapContentTypesToRivers = (
382
+ state: Partial<RootState>
383
+ ): ZappContentTypesMapped | null => {
384
+ const { rivers, contentTypes } = state;
385
+
384
386
  if (!contentTypes) {
385
387
  return null;
386
388
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "14.0.0-alpha.2175196485",
3
+ "version": "14.0.0-alpha.2292190333",
4
4
  "description": "Applicaster Zapp React Native utilities package",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "homepage": "https://github.com/applicaster/quickbrick#readme",
29
29
  "dependencies": {
30
- "@applicaster/applicaster-types": "14.0.0-alpha.2175196485",
30
+ "@applicaster/applicaster-types": "14.0.0-alpha.2292190333",
31
31
  "buffer": "^5.2.1",
32
32
  "camelize": "^1.0.0",
33
33
  "dayjs": "^1.11.10",
@@ -38,7 +38,6 @@
38
38
  "peerDependencies": {
39
39
  "@applicaster/zapp-pipes-v2-client": "*",
40
40
  "@react-native-community/netinfo": "*",
41
- "immer": "*",
42
41
  "react": "*",
43
42
  "react-native": "*",
44
43
  "uglify-js": "*",
@@ -23,7 +23,9 @@ jest.mock(
23
23
 
24
24
  jest.useFakeTimers();
25
25
 
26
- jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation");
26
+ jest.mock(
27
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation"
28
+ );
27
29
 
28
30
  const mockStore = configureStore();
29
31
 
@@ -26,6 +26,9 @@ jest.mock("@applicaster/zapp-react-native-utils/analyticsUtils/", () => ({
26
26
  }));
27
27
 
28
28
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
29
+ ...jest.requireActual(
30
+ "@applicaster/zapp-react-native-utils/reactHooks/screen"
31
+ ),
29
32
  useTargetScreenData: jest.fn(() => ({})),
30
33
  useCurrentScreenData: jest.fn(() => ({})),
31
34
  }));
@@ -16,7 +16,8 @@ import { ActionExecutorContext } from "@applicaster/zapp-react-native-utils/acti
16
16
  import { isFunction, noop } from "../../functionUtils";
17
17
  import { useSendAnalyticsOnPress } from "../analytics";
18
18
  import { logOnPress, warnEmptyContentType } from "./helpers";
19
- import { useCurrentScreenData } from "../screen";
19
+ import { useCurrentScreenData, useScreenContext } from "../screen";
20
+ import { useScreenStateStore } from "../navigation/useScreenStateStore";
20
21
 
21
22
  /**
22
23
  * If onCellTap is defined execute the function and
@@ -42,10 +43,12 @@ export const useCellClick = ({
42
43
  }: Props): onPressReturnFn => {
43
44
  const { push, currentRoute } = useNavigation();
44
45
  const { pathname } = useRoute();
46
+ const screenStateStore = useScreenStateStore();
45
47
 
46
48
  const onCellTap: Option<Function> = React.useContext(CellTapContext);
47
49
  const actionExecutor = React.useContext(ActionExecutorContext);
48
50
  const screenData = useCurrentScreenData();
51
+ const screenState = useScreenContext()?.options;
49
52
 
50
53
  const cellSelectable = toBooleanWithDefaultTrue(
51
54
  component?.rules?.component_cells_selectable
@@ -83,6 +86,9 @@ export const useCellClick = ({
83
86
  await actionExecutor?.handleEntryActions(selectedItem, {
84
87
  component,
85
88
  screenData,
89
+ screenState,
90
+ screenRoute: pathname,
91
+ screenStateStore,
86
92
  });
87
93
  }
88
94
 
@@ -117,6 +123,7 @@ export const useCellClick = ({
117
123
  push,
118
124
  sendAnalyticsOnPress,
119
125
  screenData,
126
+ screenState,
120
127
  ]
121
128
  );
122
129
 
@@ -12,7 +12,6 @@ describe("Debug utils", () => {
12
12
  // Clear the timers object
13
13
  Object.keys(timers).forEach((key) => delete timers[key]);
14
14
 
15
- // Mock performance.now()
16
15
  // eslint-disable-next-line no-undef
17
16
  performanceNowMock = jest.spyOn(performance, "now");
18
17
  performanceNowMock.mockReturnValue(0); // Initial value
@@ -2,12 +2,16 @@ import { renderHook } from "@testing-library/react-hooks";
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";
5
6
 
6
7
  jest.mock("../../navigation");
7
8
 
8
9
  jest.mock(
9
10
  "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext",
10
11
  () => ({
12
+ ...jest.requireActual(
13
+ "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext"
14
+ ),
11
15
  useScreenContext: jest.fn().mockReturnValue({ screen: {}, entry: {} }),
12
16
  })
13
17
  );
@@ -33,7 +37,7 @@ describe("useBatchLoading", () => {
33
37
  jest.clearAllMocks();
34
38
  });
35
39
 
36
- it("loadPipesData start loading not started requests", () => {
40
+ it("loadPipesData start loading not started requests", async () => {
37
41
  const store = {
38
42
  zappPipes: {
39
43
  url1: {
@@ -65,7 +69,9 @@ describe("useBatchLoading", () => {
65
69
 
66
70
  const actions = (appStore.getStore() as any).getActions();
67
71
 
68
- expect(actions).toHaveLength(2);
72
+ await waitFor(() => {
73
+ expect(actions).toHaveLength(2);
74
+ });
69
75
 
70
76
  expect(actions[0]).toMatchObject({
71
77
  type: "ZAPP_PIPES_REQUEST_START",
@@ -2,15 +2,12 @@ import { renderHook } from "@testing-library/react-hooks";
2
2
  import * as R from "ramda";
3
3
  import * as zappPipesModule from "@applicaster/zapp-react-native-redux/ZappPipes";
4
4
  import * as reactReduxModules from "react-redux";
5
- import { Provider } from "react-redux";
6
5
  import * as React from "react";
7
- import configureStore from "redux-mock-store";
8
- import thunk from "redux-thunk";
9
6
  import * as useRouteHook from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute";
10
7
  import * as useNavigationHooks from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
11
8
  import { useFeedLoader } from "../useFeedLoader";
12
-
13
- const mockStore = configureStore([thunk]);
9
+ import { WrappedWithProviders } from "../../../testUtils";
10
+ import { ScreenStateResolver } from "../../../appUtils/contextKeysManager/contextResolver";
14
11
 
15
12
  jest.useFakeTimers({ legacyFakeTimers: true });
16
13
 
@@ -55,13 +52,15 @@ const mockZappPipesData = {
55
52
 
56
53
  describe("useFeedLoader", () => {
57
54
  describe("with cached feed url", () => {
58
- const store = mockStore({
55
+ const store = {
59
56
  plugins: [],
60
57
  zappPipes: { "test://testfakeurl": mockZappPipesData },
61
- });
58
+ };
62
59
 
63
- const wrapper: React.FC<any> = ({ children }) => (
64
- <Provider store={store}>{children}</Provider>
60
+ const wrapper: React.FC<any> = ({ children, ...props }) => (
61
+ <WrappedWithProviders store={props.store || store}>
62
+ {children}
63
+ </WrappedWithProviders>
65
64
  );
66
65
 
67
66
  it("returns cached feed", () => {
@@ -110,8 +109,10 @@ describe("useFeedLoader", () => {
110
109
  describe("without cached feeds", () => {
111
110
  const feedUrl = "test://testfakeurl2";
112
111
 
113
- const wrapper: React.FC<any> = ({ children, store }) => (
114
- <Provider store={store}>{children}</Provider>
112
+ const wrapper: React.FC<any> = ({ children, ...props }) => (
113
+ <WrappedWithProviders store={props.store}>
114
+ {children}
115
+ </WrappedWithProviders>
115
116
  );
116
117
 
117
118
  it("It loads data for new url and returns it", () => {
@@ -123,10 +124,10 @@ describe("useFeedLoader", () => {
123
124
  .spyOn(zappPipesModule, "loadPipesData")
124
125
  .mockImplementation(jest.fn());
125
126
 
126
- const initialStore = mockStore({
127
+ const initialStore = {
127
128
  plugins: [],
128
129
  zappPipes: { "test://testfakeurl": "foobar" },
129
- });
130
+ };
130
131
 
131
132
  const { result, rerender } = renderHook(
132
133
  () => useFeedLoader({ feedUrl: "test://testfakeurl2" }),
@@ -135,15 +136,19 @@ describe("useFeedLoader", () => {
135
136
 
136
137
  expect(result.current.data).toBeNull();
137
138
 
138
- expect(loadPipesDataSpy).toBeCalledWith(feedUrl, {
139
+ expect(loadPipesDataSpy).toHaveBeenCalledWith(feedUrl, {
139
140
  clearCache: true,
140
141
  riverId: undefined,
142
+ callback: expect.any(Function),
143
+ resolvers: {
144
+ screen: expect.any(ScreenStateResolver),
145
+ },
141
146
  });
142
147
 
143
- const store2 = mockStore({
148
+ const store2 = {
144
149
  plugins: [],
145
150
  zappPipes: { "test://testfakeurl2": mockZappPipesData },
146
- });
151
+ };
147
152
 
148
153
  rerender({ store: store2 });
149
154
 
@@ -164,10 +169,10 @@ describe("useFeedLoader", () => {
164
169
  .spyOn(reactReduxModules, "useDispatch")
165
170
  .mockImplementation(() => jest.fn());
166
171
 
167
- const initialStore = mockStore({
172
+ const initialStore = {
168
173
  plugins: [],
169
174
  zappPipes: { "test://testfakeurl": "foobar" },
170
- });
175
+ };
171
176
 
172
177
  const { result, rerender } = renderHook(
173
178
  () => useFeedLoader({ feedUrl: "test://testfakeurl2" }),
@@ -176,15 +181,22 @@ describe("useFeedLoader", () => {
176
181
 
177
182
  expect(result.current.data).toBeNull();
178
183
 
179
- expect(loadPipesDataSpy).toBeCalledWith(feedUrl, {
184
+ expect(loadPipesDataSpy.mock.calls[0][0]).toBe(feedUrl);
185
+
186
+ expect(loadPipesDataSpy.mock.calls[0][1]).toMatchObject({
180
187
  clearCache: true,
181
188
  riverId: undefined,
189
+ resolvers: {
190
+ screen: {
191
+ screenStateStore: expect.any(Function),
192
+ },
193
+ },
182
194
  });
183
195
 
184
- const store2 = mockStore({
196
+ const store2 = {
185
197
  plugins: [],
186
198
  zappPipes: { "test://testfakeurl2": mockZappPipesData },
187
- });
199
+ };
188
200
 
189
201
  rerender({ store: store2 });
190
202
 
@@ -197,8 +209,10 @@ describe("useFeedLoader", () => {
197
209
  const feedUrl = "test://testfakeurl";
198
210
  const feedUrlWithNext = "test://withnexttestfakeurl";
199
211
 
200
- const wrapper: React.FC<any> = ({ children, store }) => (
201
- <Provider store={store}>{children}</Provider>
212
+ const wrapper: React.FC<any> = ({ children, ...props }) => (
213
+ <WrappedWithProviders store={props.store || {}}>
214
+ {children}
215
+ </WrappedWithProviders>
202
216
  );
203
217
 
204
218
  describe("reloadData", () => {
@@ -211,10 +225,10 @@ describe("useFeedLoader", () => {
211
225
  .spyOn(reactReduxModules, "useDispatch")
212
226
  .mockImplementation(() => jest.fn());
213
227
 
214
- const initialStore = mockStore({
228
+ const initialStore = {
215
229
  plugins: [],
216
230
  zappPipes: { [feedUrl]: "foobar" },
217
- });
231
+ };
218
232
 
219
233
  const { result } = renderHook(() => useFeedLoader({ feedUrl }), {
220
234
  wrapper,
@@ -223,11 +237,24 @@ describe("useFeedLoader", () => {
223
237
 
224
238
  const { reloadData } = result.current;
225
239
 
226
- reloadData();
240
+ reloadData?.();
241
+
242
+ expect(loadPipesDataSpy).toHaveBeenCalled();
243
+
244
+ expect(
245
+ loadPipesDataSpy.mock.calls[loadPipesDataSpy.mock.calls.length - 1][0]
246
+ ).toBe(feedUrl);
227
247
 
228
- expect(loadPipesDataSpy).toBeCalledWith(feedUrl, {
248
+ expect(
249
+ loadPipesDataSpy.mock.calls[loadPipesDataSpy.mock.calls.length - 1][1]
250
+ ).toMatchObject({
229
251
  clearCache: true,
230
252
  silentRefresh: true,
253
+ resolvers: {
254
+ screen: {
255
+ screenStateStore: expect.any(Function),
256
+ },
257
+ },
231
258
  });
232
259
 
233
260
  loadPipesDataSpy.mockRestore();
@@ -247,10 +274,10 @@ describe("useFeedLoader", () => {
247
274
  .spyOn(reactReduxModules, "useDispatch")
248
275
  .mockImplementation(() => jest.fn());
249
276
 
250
- const initialStore = mockStore({
277
+ const initialStore = {
251
278
  plugins: [],
252
279
  zappPipes: { [feedUrlWithNext]: { data: { next: nextUrl } } },
253
- });
280
+ };
254
281
 
255
282
  const { result } = renderHook(
256
283
  () => useFeedLoader({ feedUrl: feedUrlWithNext }),
@@ -262,11 +289,24 @@ describe("useFeedLoader", () => {
262
289
 
263
290
  const { loadNext } = result.current;
264
291
 
265
- loadNext();
292
+ loadNext?.();
293
+
294
+ expect(loadPipesDataSpy).toHaveBeenCalled();
295
+
296
+ expect(
297
+ loadPipesDataSpy.mock.calls[loadPipesDataSpy.mock.calls.length - 1][0]
298
+ ).toBe(nextUrl);
266
299
 
267
- expect(loadPipesDataSpy).toBeCalledWith(nextUrl, {
300
+ expect(
301
+ loadPipesDataSpy.mock.calls[loadPipesDataSpy.mock.calls.length - 1][1]
302
+ ).toMatchObject({
268
303
  parentFeed: feedUrlWithNext,
269
304
  silentRefresh: true,
305
+ resolvers: {
306
+ screen: {
307
+ screenStateStore: expect.any(Function),
308
+ },
309
+ },
270
310
  });
271
311
 
272
312
  loadPipesDataSpy.mockRestore();
@@ -11,3 +11,5 @@ export { useBuildPipesUrl } from "./useBuildPipesUrl";
11
11
  export { usePipesCacheReset } from "./usePipesCacheReset";
12
12
 
13
13
  export { useBatchLoading } from "./useBatchLoading";
14
+
15
+ export { useLoadPipesDataDispatch } from "./useLoadPipesDataDispatch";