@applicaster/zapp-react-native-utils 13.0.0-rc.5 → 13.0.0-rc.51

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 (141) hide show
  1. package/README.md +0 -10
  2. package/actionsExecutor/ActionExecutor.ts +16 -9
  3. package/actionsExecutor/ActionExecutorContext.tsx +74 -9
  4. package/alertUtils/alert.ts +148 -0
  5. package/alertUtils/index.ts +1 -148
  6. package/analyticsUtils/AnalyticPlayerListener.ts +18 -1
  7. package/analyticsUtils/__tests__/__snapshots__/analyticsManagerNoModule.test.js.snap +9 -9
  8. package/analyticsUtils/currentScreenProperities.ts +6 -4
  9. package/analyticsUtils/helpers/hooks.ts +1 -1
  10. package/appUtils/HooksManager/{Hook.js → Hook.ts} +35 -23
  11. package/appUtils/HooksManager/__tests__/__snapshots__/hook.test.js.snap +10 -8
  12. package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +693 -0
  13. package/appUtils/HooksManager/__tests__/hook.test.js +196 -184
  14. package/appUtils/HooksManager/__tests__/hooksManager.test.js +96 -99
  15. package/appUtils/HooksManager/{constants.js → constants.ts} +1 -1
  16. package/appUtils/HooksManager/{index.js → index.ts} +121 -112
  17. package/appUtils/HooksManager/types.ts +119 -0
  18. package/appUtils/RiverFocusManager/index.js +17 -12
  19. package/appUtils/accessibilityManager/index.ts +42 -1
  20. package/appUtils/contextKeysManager/contextResolver.ts +77 -0
  21. package/appUtils/contextKeysManager/index.ts +2 -2
  22. package/appUtils/contextKeysManager/utils/index.ts +2 -1
  23. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +7 -6
  24. package/appUtils/focusManager/index.ts +100 -65
  25. package/appUtils/focusManager/treeDataStructure/Tree/index.js +25 -3
  26. package/appUtils/focusManager/treeDataStructure/Utils/index.js +1 -3
  27. package/appUtils/focusManager/utils/enums.ts +4 -0
  28. package/appUtils/focusManagerAux/utils/index.ts +4 -3
  29. package/appUtils/{index.js → index.ts} +1 -1
  30. package/appUtils/keyCodes/__tests__/__snapshots__/keyCodes.test.js.snap +2 -2
  31. package/appUtils/keyCodes/__tests__/keyCodes.test.js +4 -4
  32. package/appUtils/keyCodes/{index.js → index.ts} +13 -7
  33. package/appUtils/keyCodes/keys/index.ts +3 -0
  34. package/appUtils/keyCodes/{keys.android.js → keys/keyEventMapper.ts} +0 -19
  35. package/appUtils/keyCodes/keys/keys.android.ts +18 -0
  36. package/appUtils/keyCodes/keys/keys.ios.ts +25 -0
  37. package/appUtils/keyCodes/keys/keys.ts +15 -0
  38. package/appUtils/keyCodes/{keysByPlatform.js → keys/keysByPlatform.ts} +4 -0
  39. package/appUtils/keyCodes/keysByPlatform.ts +8 -0
  40. package/appUtils/keyInputHandler/KeyInputHandler.ts +68 -0
  41. package/appUtils/orientationHelper.ts +1 -1
  42. package/appUtils/platform/const.ts +14 -0
  43. package/appUtils/platform/platformUtils.ts +47 -18
  44. package/appUtils/playerManager/index.ts +2 -2
  45. package/appUtils/playerManager/player.ts +19 -7
  46. package/appUtils/playerManager/playerNative.ts +3 -2
  47. package/appUtils/playerManager/usePlayerControllerSetup.tsx +3 -3
  48. package/arrayUtils/__tests__/__snapshots__/arrayUtils.test.ts.snap +4 -4
  49. package/domUtils/{cookieManager.js → cookieManager.ts} +1 -2
  50. package/equalUtils/__tests__/isEqual/combination.test.ts +263 -0
  51. package/equalUtils/index.ts +49 -30
  52. package/focusManager/FocusManager.ts +11 -1
  53. package/focusManager/index.ts +41 -4
  54. package/functionUtils/__tests__/__snapshots__/functionUtils.test.js.snap +4 -4
  55. package/functionUtils/index.ts +15 -11
  56. package/idleUtils/__tests__/withTimeout$.test.ts +37 -0
  57. package/idleUtils/index.ts +1 -1
  58. package/idleUtils/withTimeout.ts +15 -2
  59. package/logger/const.ts +9 -67
  60. package/manifestUtils/__tests__/createConfig.test.js +16 -16
  61. package/manifestUtils/sharedConfiguration/screenPicker/__tests__/utils.test.js +304 -0
  62. package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +875 -0
  63. package/manifestUtils/sharedConfiguration/screenPicker/utils.js +130 -0
  64. package/modalState/index.ts +1 -5
  65. package/navigationUtils/__tests__/__snapshots__/navigationUtils.test.js.snap +6 -6
  66. package/navigationUtils/__tests__/itemTypes.test.js +2 -2
  67. package/navigationUtils/__tests__/navigationUtils.test.js +2 -2
  68. package/navigationUtils/index.ts +17 -8
  69. package/package.json +5 -6
  70. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +1 -1
  71. package/reactHooks/autoscrolling/__tests__/useTrackedView.test.tsx +1 -1
  72. package/reactHooks/cell-click/__tests__/index.test.js +10 -2
  73. package/reactHooks/cell-click/index.ts +7 -1
  74. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +4 -4
  75. package/reactHooks/feed/__tests__/useFeedLoader.test.tsx +10 -11
  76. package/reactHooks/feed/useFeedLoader.tsx +1 -1
  77. package/reactHooks/feed/usePipesCacheReset.ts +5 -5
  78. package/reactHooks/flatList/__tests__/index.test.tsx +30 -21
  79. package/reactHooks/layout/__tests__/index.test.tsx +10 -10
  80. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.native.test.js +14 -28
  81. package/reactHooks/layout/useDimensions/helpers/__tests__/getInitialDimensions.test.js +1 -1
  82. package/reactHooks/layout/useDimensions/useDimensions.ts +8 -0
  83. package/reactHooks/navigation/__mocks__/useNavigation.ts +3 -0
  84. package/reactHooks/navigation/__tests__/index.test.tsx +0 -4
  85. package/reactHooks/navigation/index.ts +35 -236
  86. package/reactHooks/navigation/useGetBottomTabBarHeight.ts +12 -0
  87. package/reactHooks/navigation/useGetNavBarTopBorderWidth.ts +14 -0
  88. package/reactHooks/navigation/useGetTabBarHeight.ts +10 -0
  89. package/reactHooks/navigation/useIsScreenActive.ts +17 -0
  90. package/reactHooks/navigation/useNavigationPluginData.ts +15 -0
  91. package/reactHooks/navigation/useNavigationType.ts +15 -0
  92. package/reactHooks/navigation/usePathname.ts +4 -0
  93. package/reactHooks/navigation/useProfilerLogging.ts +15 -0
  94. package/reactHooks/navigation/useRoute.ts +100 -0
  95. package/reactHooks/navigation/useUniqueRouteSuffix.ts +41 -0
  96. package/reactHooks/player/TVSeekControlller/ISeekController.ts +32 -0
  97. package/reactHooks/player/TVSeekControlller/LongPressSeekController.ts +71 -0
  98. package/reactHooks/player/TVSeekControlller/TVSeekController.ts +258 -0
  99. package/reactHooks/player/TVSeekControlller/TapSeekController.ts +53 -0
  100. package/reactHooks/player/__tests__/{useAutoSeek.test.tsx → useAutoSeek._test.tsx} +2 -3
  101. package/reactHooks/player/const.ts +0 -4
  102. package/reactHooks/player/index.ts +0 -6
  103. package/reactHooks/state/useRefWithInitialValue.ts +14 -0
  104. package/reactHooks/state/useStateFromSubscribe.ts +23 -0
  105. package/reactHooks/usePluginConfiguration.ts +1 -1
  106. package/reactHooks/useSubscriberFor.ts +4 -3
  107. package/reactUtils/__tests__/__snapshots__/reactUtilsHelpers.test.js.snap +16 -4
  108. package/reactUtils/__tests__/reactUtils.test.js +1 -37
  109. package/reactUtils/__tests__/reactUtilsHelpers.test.js +72 -71
  110. package/reactUtils/createContext/__tests__/__snapshots__/helpers.test.js.snap +13 -79
  111. package/reactUtils/createContext/__tests__/__snapshots__/{index.test.js.snap → index.test.ts.snap} +2 -2
  112. package/reactUtils/createContext/__tests__/__snapshots__/provider.test.js.snap +3 -28
  113. package/reactUtils/createContext/__tests__/__snapshots__/withConsumer.test.js.snap +3 -4
  114. package/reactUtils/createContext/__tests__/__snapshots__/withProvider.test.js.snap +7 -3
  115. package/reactUtils/createContext/__tests__/helpers.test.js +107 -121
  116. package/reactUtils/createContext/__tests__/{index.test.js → index.test.ts} +2 -2
  117. package/reactUtils/createContext/__tests__/provider.test.js +4 -6
  118. package/reactUtils/createContext/__tests__/withConsumer.test.js +12 -12
  119. package/reactUtils/createContext/__tests__/withProvider.test.js +4 -4
  120. package/reactUtils/createContext/helpers.ts +6 -1
  121. package/reactUtils/createContext/index.ts +11 -25
  122. package/reactUtils/index.ts +0 -25
  123. package/screenState/index.ts +24 -10
  124. package/testUtils/index.tsx +0 -10
  125. package/theme/__mocks__/index.ts +4 -0
  126. package/theme/index.ts +1 -1
  127. package/time/Timer.ts +5 -2
  128. package/types.ts +1 -0
  129. package/zappFrameworkUtils/presentPluginOneTime.ts +2 -3
  130. package/appUtils/keyCodes/keys.ios.js +0 -46
  131. package/reactHooks/player/useAutoSeek.tsx +0 -87
  132. package/reactHooks/player/useSeek.tsx +0 -66
  133. package/reactHooks/player/useTapSeek.tsx +0 -58
  134. package/reactUtils/createContext/__tests__/index-no-react.test.js +0 -27
  135. /package/appUtils/HooksManager/{logger.js → logger.ts} +0 -0
  136. /package/appUtils/{directionHelper.js → directionHelper.ts} +0 -0
  137. /package/appUtils/keyCodes/{androidTVKeys.js → androidTVKeys.ts} +0 -0
  138. /package/appUtils/keyCodes/{keys.web.js → keys/keys.web.ts} +0 -0
  139. /package/appUtils/{localizationsHelper.js → localizationsHelper.ts} +0 -0
  140. /package/domUtils/{logger.js → logger.ts} +0 -0
  141. /package/reactHooks/player/__tests__/{useTapSeek.test.ts → useTapSeek._test.ts} +0 -0
@@ -0,0 +1,130 @@
1
+ const defaultPlatforms = {
2
+ tvos: "tvOS",
3
+ android_tv: "Android TV",
4
+ lg_tv: "LG TV",
5
+ samsung_tv: "Samsung TV",
6
+ };
7
+
8
+ const global_defaults = {
9
+ fontSize: 20,
10
+ lineHeight: 40,
11
+ letterSpacing: 0.4,
12
+ };
13
+
14
+ const generateFontConfiguration = (platforms = defaultPlatforms) => {
15
+ const platformEntries = Object.entries(platforms);
16
+ const defaultsEntries = Object.entries(global_defaults);
17
+ const splitCamelCase = (str) => str.replace(/([a-z](?=[A-Z]))/g, "$1_");
18
+
19
+ return platformEntries.reduce((acc, [platformKey, platformValue]) => {
20
+ acc.push(
21
+ ...defaultsEntries.reduce((acc2, [valueKey, defaultValue]) => {
22
+ acc2.push({
23
+ type: "number_input",
24
+ label: `${platformValue} ${splitCamelCase(valueKey).replace(
25
+ "_",
26
+ " "
27
+ )}`,
28
+ key: `${platformKey}_${splitCamelCase(valueKey)}`.toLowerCase(),
29
+ initial_value: defaultValue,
30
+ });
31
+
32
+ return acc2;
33
+ }, [])
34
+ );
35
+
36
+ return acc;
37
+ }, []);
38
+ };
39
+
40
+ const conditional_rule = (key, condition_value) => ({
41
+ key,
42
+ condition_value,
43
+ });
44
+
45
+ const createConditionalConfig = (rules, matchAll = false) => ({
46
+ rules: matchAll ? "all_conditions" : "conditional",
47
+ conditional_fields: rules.map((field) => conditional_rule(...field)),
48
+ });
49
+
50
+ const conditional_horizontal_type = createConditionalConfig([
51
+ ["styles/screen_picker_type", "horizontal"],
52
+ ]);
53
+
54
+ const conditional_vertical_type = createConditionalConfig([
55
+ ["styles/screen_picker_type", "vertical"],
56
+ ]);
57
+
58
+ const conditional_horizontal_type_item_fixed = createConditionalConfig(
59
+ [
60
+ ["styles/screen_picker_type", "horizontal"],
61
+ ["styles/screen_picker_item_size", "fixed"],
62
+ ],
63
+ true
64
+ );
65
+
66
+ const conditional_horizontal_type_item_dynamic = createConditionalConfig(
67
+ [
68
+ ["styles/screen_picker_type", "horizontal"],
69
+ ["screen_picker_horizontal_display_type", "dynamic"],
70
+ ],
71
+ true
72
+ );
73
+
74
+ const conditional_horizontal_display_type_fixed = createConditionalConfig(
75
+ [
76
+ ["styles/screen_picker_type", "horizontal"],
77
+ ["styles/screen_picker_horizontal_display_type", "fixed"],
78
+ ],
79
+ true
80
+ );
81
+
82
+ const conditional_horizontal_asset_on = createConditionalConfig(
83
+ [
84
+ ["styles/screen_picker_type", "horizontal"],
85
+ ["styles/screen_picker_asset_switch", true],
86
+ ],
87
+ true
88
+ );
89
+
90
+ const createVariationFields = ({
91
+ prefix = "screen_picker",
92
+ key,
93
+ type = "number_input",
94
+ label = "",
95
+ variants: [a, b],
96
+ }) => {
97
+ return [
98
+ {
99
+ type,
100
+ key: `${prefix}${prefix.length > 0 ? "_" : ""}${
101
+ a?.key ?? "vertical"
102
+ }_${key}`,
103
+ label: a?.label ?? label,
104
+ initial_value: a.initial_value,
105
+ ...conditional_vertical_type,
106
+ },
107
+ {
108
+ type,
109
+ key: `${prefix}${prefix.length > 0 ? "_" : ""}${
110
+ b.key ?? "horizontal"
111
+ }_${key}`,
112
+ label: b?.label ?? label,
113
+ initial_value: b.initial_value,
114
+ ...conditional_horizontal_type,
115
+ },
116
+ ];
117
+ };
118
+
119
+ module.exports = {
120
+ generateFontConfiguration,
121
+ createVariationFields,
122
+ createConditionalConfig,
123
+ conditional_rule,
124
+ conditional_horizontal_type,
125
+ conditional_vertical_type,
126
+ conditional_horizontal_type_item_fixed,
127
+ conditional_horizontal_type_item_dynamic,
128
+ conditional_horizontal_display_type_fixed,
129
+ conditional_horizontal_asset_on,
130
+ };
@@ -31,11 +31,7 @@ export const useModalStore = create<ModalStore>((set) => ({
31
31
  set((state) => ({
32
32
  modalState: { ...state.modalState, ...newState },
33
33
  })),
34
- openModal: ({
35
- item,
36
- options = {},
37
- props = { screenData: {} },
38
- }: OpenModalArg) =>
34
+ openModal: ({ item, options = {}, props }: OpenModalArg) =>
39
35
  set({
40
36
  modalState: {
41
37
  visible: true,
@@ -1,19 +1,19 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`getNavigationProps returns the props otherwise 1`] = `
4
- Object {
5
- "assets": Object {
4
+ {
5
+ "assets": {
6
6
  "appLogo": "appLogo.png",
7
7
  },
8
8
  "home": false,
9
- "nav_items": Array [
10
- Object {
9
+ "nav_items": [
10
+ {
11
11
  "type": "label",
12
12
  },
13
13
  ],
14
- "rules": Object {},
14
+ "rules": {},
15
15
  "selected": "A1234",
16
- "styles": Object {
16
+ "styles": {
17
17
  "style": "foo",
18
18
  },
19
19
  "title": "testTitle",
@@ -61,8 +61,8 @@ describe("getTypeMatcher", () => {
61
61
 
62
62
  describe("isItemOfType", () => {
63
63
  it("is a curried function", () => {
64
- expect(itemIsOfType(river, SCREEN_TYPES.RIVER)).toBeBoolean();
65
- expect(itemIsOfType(river)).toBeFunction();
64
+ expect(itemIsOfType(river, SCREEN_TYPES.RIVER)).toBeTruthy();
65
+ expect(itemIsOfType(river)).toBeInstanceOf(Function);
66
66
  });
67
67
 
68
68
  it("returns true if the item is of the given type", () => {
@@ -243,7 +243,7 @@ describe("getTargetRoute", () => {
243
243
  it("returns a valid path when initial pathname is /", () => {
244
244
  const targetRoute = getTargetRoute(river, "/", { layoutVersion });
245
245
  expect(targetRoute).toEqual(`/river/${river.id}`);
246
- expect(targetRoute).not.toInclude("//");
246
+ expect(targetRoute).not.toContainEntry("//");
247
247
  });
248
248
  });
249
249
 
@@ -273,7 +273,7 @@ describe("getTargetRoute", () => {
273
273
  it("returns a valid path when initial pathname is /", () => {
274
274
  const targetRoute = getTargetRoute(river, "/", { layoutVersion });
275
275
  expect(targetRoute).toEqual(`/river/${river.id}`);
276
- expect(targetRoute).not.toInclude("//");
276
+ expect(targetRoute).not.toContainEntry("//");
277
277
  });
278
278
  });
279
279
  });
@@ -324,7 +324,13 @@ export function getPathAttributes({
324
324
  * @param {object} rivers
325
325
  * @returns {object}
326
326
  */
327
- export function getRiverFromRoute({ route, rivers }) {
327
+ export function getRiverFromRoute({
328
+ route,
329
+ rivers,
330
+ }: {
331
+ route: string;
332
+ rivers: Record<string, ZappRiver>;
333
+ }) {
328
334
  if (!route) {
329
335
  return null;
330
336
  }
@@ -437,7 +443,7 @@ export const runZappHooksForEntry = async (
437
443
 
438
444
  let success;
439
445
  let payload;
440
- const rivers = appStore.get("rivers");
446
+ const rivers: Record<string, ZappRiver> = appStore.get("rivers");
441
447
  const plugins = appStore.get("plugins");
442
448
  const appData = appStore.get("appData");
443
449
 
@@ -492,13 +498,16 @@ export const runZappHooksForEntry = async (
492
498
  payload = _payload;
493
499
  };
494
500
 
495
- HooksManager(hooksOptions)
501
+ const hooksManager = HooksManager(hooksOptions);
502
+
503
+ hooksManager.subscriber
496
504
  .on(HOOKS_EVENTS.PRESENT_SCREEN_HOOK, handleHookPresent)
497
505
  .on(HOOKS_EVENTS.START_BACKGROUND_HOOK, handleBackgroundHook)
498
506
  .on(HOOKS_EVENTS.ERROR, onFinished(false))
499
507
  .on(HOOKS_EVENTS.CANCEL, onFinished(false))
500
- .on(HOOKS_EVENTS.COMPLETE, onFinished(true))
501
- .handleHooks(entry);
508
+ .on(HOOKS_EVENTS.COMPLETE, onFinished(true));
509
+
510
+ hooksManager.handleHooks(entry);
502
511
 
503
512
  // eslint-disable-next-line no-unmodified-loop-condition
504
513
  while (success === undefined) {
@@ -635,8 +644,8 @@ export const getScreenId = (
635
644
  fallbackRiver: ZappRiver
636
645
  ) => {
637
646
  return screenData?.targetScreen
638
- ? screenData?.targetScreen?.id ?? fallbackRiver.id
647
+ ? (screenData?.targetScreen?.id ?? fallbackRiver.id)
639
648
  : "screen_id" in screenData
640
- ? screenData.screen_id
641
- : fallbackRiver.id;
649
+ ? screenData.screen_id
650
+ : fallbackRiver.id;
642
651
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "13.0.0-rc.5",
3
+ "version": "13.0.0-rc.51",
4
4
  "description": "Applicaster Zapp React Native utilities package",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,11 +28,9 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "13.0.0-rc.5",
31
+ "@applicaster/applicaster-types": "13.0.0-rc.51",
32
32
  "buffer": "^5.2.1",
33
33
  "camelize": "^1.0.0",
34
- "create-react-context": "^0.2.3",
35
- "create-react-ref": "^0.1.0",
36
34
  "dayjs": "^1.11.10",
37
35
  "memoizee": "0.4.15",
38
36
  "prop-types": "^15.0.0",
@@ -42,8 +40,9 @@
42
40
  "@applicaster/zapp-pipes-v2-client": "*",
43
41
  "@react-native-community/netinfo": "*",
44
42
  "immer": "*",
45
- "react": "17.0.2",
46
- "react-native": "0.68.6",
43
+ "react": "*",
44
+ "react-native": "*",
45
+ "uglify-js": "*",
47
46
  "validate-color": "*",
48
47
  "zustand": "*"
49
48
  },
@@ -14,7 +14,7 @@ jest.mock(
14
14
 
15
15
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation");
16
16
 
17
- jest.useFakeTimers();
17
+ jest.useFakeTimers({ legacyFakeTimers: true });
18
18
 
19
19
  const {
20
20
  useTrackCurrentAutoScrollingElement,
@@ -19,7 +19,7 @@ jest.mock(
19
19
  })
20
20
  );
21
21
 
22
- jest.useFakeTimers();
22
+ jest.useFakeTimers({ legacyFakeTimers: true });
23
23
 
24
24
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation");
25
25
 
@@ -5,14 +5,14 @@ import { ActionExecutorContext } from "@applicaster/zapp-react-native-utils/acti
5
5
 
6
6
  import { waitFor } from "@testing-library/react-native";
7
7
 
8
- const navigator = {
8
+ const mockNavigator = {
9
9
  getPathname: () => "pathnameMock",
10
10
  push: jest.fn(),
11
11
  data: {},
12
12
  };
13
13
 
14
14
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
15
- useNavigation: () => navigator,
15
+ useNavigation: () => mockNavigator,
16
16
  useRoute: () => ({ pathname: "pathnameMock" }),
17
17
  useProfilerLogging: () => {
18
18
  return jest.fn();
@@ -25,7 +25,15 @@ jest.mock("@applicaster/zapp-react-native-utils/analyticsUtils/", () => ({
25
25
  }),
26
26
  }));
27
27
 
28
+ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
29
+ useTargetScreenData: jest.fn(() => ({})),
30
+ useCurrentScreenData: jest.fn(() => ({})),
31
+ }));
32
+
28
33
  jest.mock("@applicaster/zapp-react-native-ui-components/Contexts", () => ({
34
+ ...jest.requireActual(
35
+ "@applicaster/zapp-react-native-ui-components/Contexts"
36
+ ),
29
37
  ZappPipesEntryContext: {
30
38
  useZappPipesContext: jest.fn(() => [undefined, jest.fn()]),
31
39
  },
@@ -16,6 +16,7 @@ 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
20
 
20
21
  /**
21
22
  * If onCellTap is defined execute the function and
@@ -44,6 +45,7 @@ export const useCellClick = ({
44
45
 
45
46
  const onCellTap: Option<Function> = React.useContext(CellTapContext);
46
47
  const actionExecutor = React.useContext(ActionExecutorContext);
48
+ const screenData = useCurrentScreenData();
47
49
 
48
50
  const cellSelectable = toBooleanWithDefaultTrue(
49
51
  component?.rules?.component_cells_selectable
@@ -78,7 +80,10 @@ export const useCellClick = ({
78
80
  logOnPress(selectedItem, pathname, component, onCellTap);
79
81
 
80
82
  if (selectedItem) {
81
- await actionExecutor?.handleEntryActions(selectedItem);
83
+ await actionExecutor?.handleEntryActions(selectedItem, {
84
+ component,
85
+ screenData,
86
+ });
82
87
  }
83
88
 
84
89
  if (selectedItem?.type?.value === "action") {
@@ -111,6 +116,7 @@ export const useCellClick = ({
111
116
  pathname,
112
117
  push,
113
118
  sendAnalyticsOnPress,
119
+ screenData,
114
120
  ]
115
121
  );
116
122
 
@@ -7,12 +7,12 @@ const appData = {
7
7
  sdk_version: "2.0.0",
8
8
  };
9
9
 
10
- let INFLATED_URL;
10
+ const mockUseInflatedUrl = jest.fn();
11
11
 
12
12
  jest.mock(
13
13
  "@applicaster/zapp-react-native-utils/reactHooks/feed/useInflatedUrl",
14
14
  () => ({
15
- useInflatedUrl: () => INFLATED_URL,
15
+ useInflatedUrl: mockUseInflatedUrl,
16
16
  })
17
17
  );
18
18
 
@@ -20,7 +20,7 @@ const { useBuildPipesUrl } = require("../useBuildPipesUrl");
20
20
 
21
21
  describe("useBuildPipesUrl", () => {
22
22
  it("returns the proper url", async () => {
23
- INFLATED_URL = "http://foo.com/show/show-1";
23
+ mockUseInflatedUrl.mockReturnValue("http://foo.com/show/show-1");
24
24
  const url = "http://foo.com/show/{{showId}}";
25
25
 
26
26
  const mapping = {
@@ -65,7 +65,7 @@ describe("useBuildPipesUrl", () => {
65
65
  });
66
66
 
67
67
  it("returns empty object if url is not in endpoints", async () => {
68
- INFLATED_URL = "http://foobar.com/show-1";
68
+ mockUseInflatedUrl.mockReturnValue("http://foobar.com/show-1");
69
69
  const url = "http://foobar.com/{{showId}}";
70
70
 
71
71
  const mapping = {
@@ -6,42 +6,41 @@ import { Provider } from "react-redux";
6
6
  import * as React from "react";
7
7
  import configureStore from "redux-mock-store";
8
8
  import thunk from "redux-thunk";
9
- import * as navigationHooks from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
9
+ import * as useRouteHook from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute";
10
10
  import * as useNavigationHooks from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
11
+ import { useFeedLoader } from "../useFeedLoader";
11
12
 
12
13
  const mockStore = configureStore([thunk]);
13
14
 
14
- jest.useFakeTimers();
15
+ jest.useFakeTimers({ legacyFakeTimers: true });
15
16
 
16
- const logger = {
17
+ const mockLogger = {
17
18
  warning: jest.fn(),
18
19
  log: jest.fn(),
19
20
  info: jest.fn(),
20
21
  };
21
22
 
22
- const navigator = {
23
+ const mockNavigator: any = {
23
24
  currentRoute: "/river/A1234",
24
25
  getStack: jest.fn(() => []),
25
26
  };
26
27
 
27
- const routeData = {
28
+ const mockRouteData: any = {
28
29
  screenData: {},
29
30
  pathname: "/river/A1234",
30
31
  };
31
32
 
32
- jest.mock("../../logger", () => ({
33
+ jest.doMock("../../logger", () => ({
33
34
  reactHooksLogger: {
34
- addSubsystem: jest.fn(() => logger),
35
+ addSubsystem: jest.fn(() => mockLogger),
35
36
  },
36
37
  }));
37
38
 
38
39
  jest
39
40
  .spyOn(useNavigationHooks, "useNavigation")
40
- .mockImplementation(() => navigator);
41
+ .mockImplementation(() => mockNavigator);
41
42
 
42
- jest.spyOn(navigationHooks, "useRoute").mockImplementation(() => routeData);
43
-
44
- const { useFeedLoader } = require("../useFeedLoader");
43
+ jest.spyOn(useRouteHook, "useRoute").mockImplementation(() => mockRouteData);
45
44
 
46
45
  const mockZappPipesData = {
47
46
  data: {
@@ -87,7 +87,7 @@ export const useFeedLoader = ({
87
87
  );
88
88
  }
89
89
  }
90
- }, [callableFeedUrl, currentFeed?.data]);
90
+ }, [callableFeedUrl, currentFeed?.data?.next]);
91
91
 
92
92
  useEffect(() => {
93
93
  if (
@@ -1,12 +1,12 @@
1
1
  import React from "react";
2
2
  import { useDispatch } from "react-redux";
3
- import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
4
- import {
5
- getDatasourceUrl,
6
- usePipesContexts,
7
- } from "@applicaster/zapp-react-native-ui-components/Decorators/RiverFeedLoader/utils";
3
+
4
+ import { getDatasourceUrl } from "@applicaster/zapp-react-native-ui-components/Decorators/RiverFeedLoader/utils/getDatasourceUrl";
5
+ import { usePipesContexts } from "@applicaster/zapp-react-native-ui-components/Decorators/RiverFeedLoader/utils/usePipesContexts";
8
6
  import { clearPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
9
7
 
8
+ import { useRoute } from "../navigation/useRoute";
9
+
10
10
  /**
11
11
  * reset river components cache when screen is unmounted
12
12
  * @param {string} riverId screen id
@@ -1,6 +1,5 @@
1
1
  import * as React from "react";
2
- import { renderHook, act } from "@testing-library/react-hooks";
3
- import { render } from "@testing-library/react-native";
2
+ import { renderHook, render, act } from "@testing-library/react-native";
4
3
  import { View } from "react-native";
5
4
 
6
5
  import { useSequentialLoader, useSequentialRenderItem } from "..";
@@ -66,26 +65,28 @@ describe("flatList hooks", () => {
66
65
 
67
66
  expect(result.current.allLoaded).toBe(false);
68
67
 
69
- result.current.renderItem(
70
- ({ onLoadFinished }) => {
71
- onLoadFinished();
72
- },
73
- { index: 1 }
74
- );
68
+ act(() => {
69
+ result.current.renderItem(
70
+ ({ onLoadFinished }) => {
71
+ onLoadFinished();
72
+ },
73
+ { index: 1 }
74
+ );
75
+ });
75
76
 
76
77
  expect(result.current.allLoaded).toBe(true);
77
78
  });
78
79
  });
79
80
 
80
81
  describe("Rendering wrapper", () => {
81
- it("wraps the elements in the View with display: none style", () => {
82
+ it("wraps the elements in the View with display: none style", async () => {
82
83
  const element1 = { id: 1 };
83
84
  const element2 = { id: 2 };
84
85
  const mockData = [element1, element2];
85
86
 
86
87
  const { result } = renderHook(() => useSequentialRenderItem(mockData));
87
88
 
88
- const { getByTestId } = render(
89
+ const res = render(
89
90
  result.current.renderItem(
90
91
  () => {
91
92
  return <View testID={"test"} />;
@@ -94,7 +95,9 @@ describe("flatList hooks", () => {
94
95
  )
95
96
  );
96
97
 
97
- const element = getByTestId("sequential-river-wrapper-1");
98
+ const element = res.root.findByProps({
99
+ testID: "sequential-river-wrapper-1",
100
+ });
98
101
 
99
102
  expect(element.props.style.display).toEqual("none");
100
103
  });
@@ -106,14 +109,16 @@ describe("flatList hooks", () => {
106
109
 
107
110
  const { result } = renderHook(() => useSequentialRenderItem(mockData));
108
111
 
109
- result.current.renderItem(
110
- ({ onLoadFinished }) => {
111
- onLoadFinished();
112
- },
113
- { item: element1, index: 0 }
114
- );
112
+ act(() => {
113
+ result.current.renderItem(
114
+ ({ onLoadFinished }) => {
115
+ onLoadFinished();
116
+ },
117
+ { item: element1, index: 0 }
118
+ );
119
+ });
115
120
 
116
- const { getByTestId } = render(
121
+ const { root } = render(
117
122
  result.current.renderItem(
118
123
  ({ onLoadFinished }) => {
119
124
  onLoadFinished();
@@ -124,7 +129,9 @@ describe("flatList hooks", () => {
124
129
  )
125
130
  );
126
131
 
127
- const element = getByTestId("sequential-river-wrapper-1");
132
+ const element = root.findByProps({
133
+ testID: "sequential-river-wrapper-1",
134
+ });
128
135
 
129
136
  expect(element.props.style.display).toEqual("flex");
130
137
  });
@@ -136,7 +143,7 @@ describe("flatList hooks", () => {
136
143
 
137
144
  const { result } = renderHook(() => useSequentialRenderItem(mockData));
138
145
 
139
- const { getByTestId } = render(
146
+ const { root } = render(
140
147
  result.current.renderItem(
141
148
  ({ onLoadFinished }) => {
142
149
  onLoadFinished();
@@ -147,7 +154,9 @@ describe("flatList hooks", () => {
147
154
  )
148
155
  );
149
156
 
150
- const element = getByTestId("sequential-river-wrapper-1");
157
+ const element = root.findByProps({
158
+ testID: "sequential-river-wrapper-1",
159
+ });
151
160
 
152
161
  expect(element.props.style.display).toEqual("none");
153
162
  });
@@ -14,10 +14,10 @@ const mocked_return_value = (tv) => ({
14
14
  });
15
15
 
16
16
  const platform = "android";
17
- let tv_flag = false;
17
+ let mock_tv_flag = false;
18
18
 
19
19
  ReactNative.Dimensions.get = jest.fn(
20
- (context) => mocked_return_value(tv_flag)[context]
20
+ (context) => mocked_return_value(mock_tv_flag)[context]
21
21
  );
22
22
 
23
23
  const mockRemoveFn = jest.fn();
@@ -43,7 +43,7 @@ jest.mock("react-native-safe-area-context", () => ({
43
43
 
44
44
  jest.mock("../../../reactUtils", () => ({
45
45
  platformSelect: jest.fn((specs) => specs[platform] || specs.default),
46
- isTV: jest.fn(() => tv_flag),
46
+ isTV: jest.fn(() => mock_tv_flag),
47
47
  }));
48
48
 
49
49
  jest.mock("../../navigation", () => ({
@@ -134,20 +134,20 @@ describe("useDimensions", () => {
134
134
 
135
135
  describe("it applies the scale to the width & height if needed", () => {
136
136
  it("applies the scale on TV, and screen context", () => {
137
- tv_flag = true;
138
- const { screen } = mocked_return_value(tv_flag);
137
+ mock_tv_flag = true;
138
+ const { screen } = mocked_return_value(mock_tv_flag);
139
139
  const { dimensions } = testHook("screen");
140
140
 
141
141
  expect(dimensions).toHaveProperty("height", screen.height * screen.scale);
142
142
  expect(dimensions).toHaveProperty("width", screen.width * screen.scale);
143
143
  expect(dimensions).toHaveProperty("scale", 1);
144
144
 
145
- tv_flag = false;
145
+ mock_tv_flag = false;
146
146
  });
147
147
 
148
148
  it("doesn't apply the scale on mobile with screen context", () => {
149
- tv_flag = false;
150
- const { screen } = mocked_return_value(tv_flag);
149
+ mock_tv_flag = false;
150
+ const { screen } = mocked_return_value(mock_tv_flag);
151
151
  const { dimensions } = testHook("screen");
152
152
 
153
153
  expect(dimensions).toHaveProperty("height", screen.height);
@@ -156,8 +156,8 @@ describe("useDimensions", () => {
156
156
  });
157
157
 
158
158
  it("doesn't apply the scale on TV with window context", () => {
159
- tv_flag = true;
160
- const { window } = mocked_return_value(tv_flag);
159
+ mock_tv_flag = true;
160
+ const { window } = mocked_return_value(mock_tv_flag);
161
161
  const { dimensions } = testHook("window");
162
162
 
163
163
  expect(dimensions).toHaveProperty("height", window.height);