@applicaster/zapp-react-native-utils 12.0.0-alpha.5251355865 → 12.0.0-alpha.5347482137

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 (87) hide show
  1. package/analyticsUtils/AnalyticsEvents/index.ts +13 -0
  2. package/analyticsUtils/AnalyticsEvents/searchEvents.ts +21 -0
  3. package/analyticsUtils/AnalyticsEvents/sendShareEvent.ts +21 -0
  4. package/analyticsUtils/analyticsPlugins.ts +25 -0
  5. package/analyticsUtils/events.ts +12 -0
  6. package/analyticsUtils/helpers/hooks.ts +1 -1
  7. package/analyticsUtils/index.tsx +12 -0
  8. package/appUtils/HooksManager/index.js +3 -1
  9. package/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +2 -3
  10. package/appUtils/focusManager/__tests__/focusManager.test.js +4 -24
  11. package/appUtils/focusManager/__tests__/index.test.ts +2 -3
  12. package/appUtils/focusManager/index.ts +76 -56
  13. package/appUtils/focusManager/treeDataStructure/Utils/index.js +75 -35
  14. package/appUtils/focusManager/utils/index.ts +100 -0
  15. package/appUtils/focusManagerAux/index.ts +76 -0
  16. package/appUtils/focusManagerAux/utils/index.ts +100 -0
  17. package/appUtils/keyCodes/keys.web.js +8 -0
  18. package/appUtils/keyCodes/keysByPlatform.js +11 -1
  19. package/appUtils/platform/const.ts +25 -0
  20. package/appUtils/platform/index.ts +3 -0
  21. package/appUtils/platform/platformUtils.ts +223 -0
  22. package/appUtils/playerManager/conts.ts +6 -0
  23. package/appUtils/playerManager/index.ts +11 -5
  24. package/appUtils/playerManager/nativePlayerManager.ts +12 -0
  25. package/appUtils/playerManager/player.ts +43 -3
  26. package/appUtils/playerManager/playerFactory.ts +12 -10
  27. package/appUtils/playerManager/playerNative.ts +14 -14
  28. package/appUtils/playerManager/usePlayerControllerSetup.tsx +6 -1
  29. package/arrayUtils/__tests__/isFilledArray.test.ts +63 -0
  30. package/arrayUtils/index.ts +5 -0
  31. package/booleanUtils/index.ts +4 -4
  32. package/cellUtils/__tests__/cellUtils.test.ts +9 -20
  33. package/cellUtils/index.ts +10 -14
  34. package/dateUtils/index.ts +11 -0
  35. package/focusManager/index.ts +1 -1
  36. package/headersUtils/index.ts +1 -0
  37. package/inflatedUrlUtils/index.ts +4 -4
  38. package/keyboardState/index.ts +0 -0
  39. package/localizationUtils/__tests__/localizationUtils.test.ts +72 -53
  40. package/localizationUtils/index.ts +13 -19
  41. package/logger/index.ts +1 -1
  42. package/manifestUtils/defaultManifestConfigurations/generalContent.js +6 -0
  43. package/manifestUtils/defaultManifestConfigurations/player.js +2 -1
  44. package/manifestUtils/index.js +5 -1
  45. package/manifestUtils/secondaryImage/index.js +18 -15
  46. package/numberUtils/__tests__/isLikeNumber.test.ts +18 -0
  47. package/numberUtils/index.ts +9 -18
  48. package/package.json +2 -2
  49. package/playerUtils/configurationGenerator.ts +3 -1
  50. package/reactHooks/autoscrolling/__tests__/useTrackCurrentAutoScrollingElement.test.ts +2 -0
  51. package/reactHooks/autoscrolling/__tests__/{useTrackedView.test.ts → useTrackedView.test.tsx} +18 -1
  52. package/reactHooks/cell-click/__tests__/index.test.js +10 -1
  53. package/reactHooks/cell-click/index.ts +12 -12
  54. package/reactHooks/feed/__tests__/useBuildPipesUrl.test.tsx +30 -70
  55. package/reactHooks/feed/__tests__/useFeedRefresh.test.tsx +6 -2
  56. package/reactHooks/feed/__tests__/useInflatedUrl.test.ts +18 -3
  57. package/reactHooks/feed/useBuildPipesUrl.ts +7 -10
  58. package/reactHooks/feed/useFeedRefresh.tsx +9 -7
  59. package/reactHooks/feed/useInflatedUrl.ts +44 -15
  60. package/reactHooks/flatList/useLoadNextPageIfNeeded.ts +16 -9
  61. package/reactHooks/layout/__tests__/{index.test.js → index.test.tsx} +44 -29
  62. package/reactHooks/layout/getDeviceInfo/index.ts +4 -2
  63. package/reactHooks/layout/types/index.ts +2 -0
  64. package/reactHooks/layout/useDimensions/useDimensions.ts +13 -7
  65. package/reactHooks/navigation/__mocks__/index.ts +15 -0
  66. package/reactHooks/navigation/__mocks__/useNavigation.ts +3 -0
  67. package/reactHooks/navigation/__tests__/index.test.tsx +11 -8
  68. package/reactHooks/navigation/index.ts +60 -21
  69. package/reactHooks/resolvers/__tests__/useCellResolver.test.tsx +3 -1
  70. package/reactHooks/screen/__tests__/useCurrentScreenData.test.tsx +21 -23
  71. package/reactHooks/screen/index.ts +2 -0
  72. package/reactHooks/screen/useScreenBackgroundColor.ts +23 -0
  73. package/reactHooks/screen/useScreenContext.ts +3 -3
  74. package/reactHooks/screen/useScreenData.ts +1 -1
  75. package/reactHooks/screen/useTargetScreenData.ts +7 -0
  76. package/reactHooks/state/useRivers.ts +3 -1
  77. package/reactHooks/videoModal/hooks/useVideoModalScreenData.tsx +10 -9
  78. package/reactUtils/index.ts +102 -0
  79. package/riverComponetsMeasurementProvider/index.tsx +2 -2
  80. package/screenState/index.ts +0 -8
  81. package/stringUtils/index.ts +5 -0
  82. package/testUtils/getByTestId.ts +14 -0
  83. package/testUtils/index.tsx +24 -22
  84. package/types.ts +4 -0
  85. package/appUtils/focusManager/FocusableEvents.ts +0 -8
  86. package/appUtils/focusManager/treeDataStructure/Utils/__tests__/Utils_android.test.js +0 -1094
  87. package/appUtils/focusManager/treeDataStructure/Utils/index.android.js +0 -261
@@ -1,59 +1,59 @@
1
- import * as ReactNative from "react-native";
2
-
3
- const mocked_state = {
4
- remoteConfigurations: { localizations: {} },
5
- appData: {
6
- languageCode: "en",
7
- countryCode: "US",
8
- },
9
- };
10
-
11
- let mocked_locale = ["en-US"];
12
-
13
- jest.doMock("react-redux", () => ({
14
- useSelector: jest.fn((fn) => fn(mocked_state)),
15
- }));
1
+ import { NativeModules } from "react-native";
16
2
 
17
- const SettingsManager = {
3
+ const settingsManagerMock = {
18
4
  getConstants: jest.fn(() => ({
19
- settings: { AppleLanguages: mocked_locale },
5
+ settings: { AppleLanguages: ["en-US"] },
20
6
  })),
21
7
  };
22
8
 
23
- const QuickBrickCommunicationModule = {
9
+ const qbCommunicationModuleMock = {
24
10
  languageLocale: "en",
25
11
  countryLocale: "US",
12
+ uiLanguage: "en-US",
26
13
  };
27
14
 
28
- ReactNative.NativeModules.SettingsManager = SettingsManager;
29
-
30
- ReactNative.NativeModules.QuickBrickCommunicationModule =
31
- QuickBrickCommunicationModule;
32
-
33
- const { useIsRTL } = require("../index");
15
+ NativeModules.SettingsManager = settingsManagerMock;
16
+ NativeModules.QuickBrickCommunicationModule = qbCommunicationModuleMock;
34
17
 
35
18
  describe("localizationUtils", () => {
19
+ beforeEach(() => {
20
+ jest.resetModules();
21
+ });
22
+
36
23
  describe("when the app has a single locale", () => {
37
24
  describe("when the app has only a RTL language as locale", () => {
38
25
  beforeEach(() => {
39
- mocked_state.remoteConfigurations.localizations = {
40
- he: "http://url.com",
26
+ jest.resetModules();
27
+ const RN = require("react-native");
28
+
29
+ RN.NativeModules.QuickBrickCommunicationModule = {
30
+ languageLocale: "he",
31
+ countryLocale: "IL",
32
+ uiLanguage: "he-HE",
41
33
  };
42
34
  });
43
35
 
44
36
  it("useIsRTL returns true", () => {
37
+ const { useIsRTL } = require("../index");
45
38
  expect(useIsRTL()).toBe(true);
46
39
  });
47
40
  });
48
41
 
49
42
  describe("when the app has only a LTR language as locale", () => {
50
43
  beforeEach(() => {
51
- mocked_state.remoteConfigurations.localizations = {
52
- en: "http://url.com",
44
+ jest.resetModules();
45
+
46
+ const RN = require("react-native");
47
+
48
+ RN.NativeModules.QuickBrickCommunicationModule = {
49
+ languageLocale: "en",
50
+ countryLocale: "US",
51
+ uiLanguage: "en",
53
52
  };
54
53
  });
55
54
 
56
55
  it("useIsRTL returns false", () => {
56
+ const { useIsRTL } = require("../index");
57
57
  expect(useIsRTL()).toBe(false);
58
58
  });
59
59
  });
@@ -63,45 +63,56 @@ describe("localizationUtils", () => {
63
63
  describe("when device locale is in the app's locales", () => {
64
64
  describe("when device locale is LTR", () => {
65
65
  beforeEach(() => {
66
- mocked_state.remoteConfigurations.localizations = {
67
- he: "http://url.com",
68
- en: "http://url.com",
69
- };
66
+ jest.resetModules();
67
+
68
+ const RN = require("react-native");
70
69
 
71
- mocked_locale = ["en-US"];
70
+ RN.NativeModules.QuickBrickCommunicationModule = {
71
+ languageLocale: "en",
72
+ countryLocale: "US",
73
+ uiLanguage: "en-US",
74
+ };
72
75
  });
73
76
 
74
77
  it("useIsRTL returns false", () => {
78
+ const { useIsRTL } = require("../index");
75
79
  expect(useIsRTL()).toBe(false);
76
80
  });
77
81
  });
78
82
 
79
83
  describe("when device locale is RTL", () => {
80
84
  beforeEach(() => {
81
- mocked_state.remoteConfigurations.localizations = {
82
- he: "http://url.com",
83
- en: "http://url.com",
84
- };
85
+ jest.resetModules();
86
+ const RN = require("react-native");
85
87
 
86
- mocked_locale = ["he-HE"];
88
+ RN.NativeModules.QuickBrickCommunicationModule = {
89
+ languageLocale: "he",
90
+ countryLocale: "IL",
91
+ uiLanguage: "he",
92
+ };
87
93
  });
88
94
 
89
95
  it("useIsRTL returns true", () => {
96
+ const { useIsRTL } = require("../index");
90
97
  expect(useIsRTL()).toBe(true);
91
98
  });
92
99
  });
93
100
 
94
101
  describe("when a device has a secondary language in a supported language", () => {
95
102
  beforeEach(() => {
96
- mocked_state.remoteConfigurations.localizations = {
97
- en: "http://url.com",
98
- he: "http://url.com",
99
- };
103
+ jest.resetModules();
104
+
105
+ const RN = require("react-native");
100
106
 
101
- mocked_locale = ["es-SP", "he-HE"];
107
+ RN.NativeModules.QuickBrickCommunicationModule = {
108
+ languageLocale: "he",
109
+ countryLocale: "IL",
110
+ uiLanguage: "he",
111
+ };
102
112
  });
103
113
 
104
114
  it("useIsRTL returns true", () => {
115
+ const { useIsRTL } = require("../index");
105
116
  expect(useIsRTL()).toBe(true);
106
117
  });
107
118
  });
@@ -110,30 +121,38 @@ describe("localizationUtils", () => {
110
121
  describe("when device locale is not in the app's locales", () => {
111
122
  describe("when first app locale is LTR", () => {
112
123
  beforeEach(() => {
113
- mocked_state.remoteConfigurations.localizations = {
114
- en: "http://url.com",
115
- he: "http://url.com",
116
- };
124
+ jest.resetModules();
125
+
126
+ const RN = require("react-native");
117
127
 
118
- mocked_locale = ["fr-FR"];
128
+ RN.NativeModules.QuickBrickCommunicationModule = {
129
+ languageLocale: "fr",
130
+ countryLocale: "FR",
131
+ uiLanguage: "fr-FR",
132
+ };
119
133
  });
120
134
 
121
135
  it("useIsRTL returns false", () => {
136
+ const { useIsRTL } = require("../index");
122
137
  expect(useIsRTL()).toBe(false);
123
138
  });
124
139
  });
125
140
 
126
141
  describe("when first app locale is RTL", () => {
127
142
  beforeEach(() => {
128
- mocked_state.remoteConfigurations.localizations = {
129
- he: "http://url.com",
130
- en: "http://url.com",
131
- };
143
+ jest.resetModules();
144
+
145
+ const RN = require("react-native");
132
146
 
133
- mocked_locale = ["fr-FR"];
147
+ RN.NativeModules.QuickBrickCommunicationModule = {
148
+ languageLocale: "he",
149
+ countryLocale: "HE",
150
+ uiLanguage: "he",
151
+ };
134
152
  });
135
153
 
136
154
  it("useIsRTL returns true", () => {
155
+ const { useIsRTL } = require("../index");
137
156
  expect(useIsRTL()).toBe(true);
138
157
  });
139
158
  });
@@ -1,10 +1,9 @@
1
1
  import * as R from "ramda";
2
2
  import { ViewStyle } from "react-native";
3
- import { useSelector } from "react-redux";
4
3
 
5
- import { getDeviceLocales } from "./deviceLocales";
6
4
  import { useMemo } from "react";
7
5
  import { getUILanguage } from "../appUtils/localizationsHelper";
6
+ import { utilsLogger } from "../logger";
8
7
 
9
8
  export {
10
9
  getLocale,
@@ -45,31 +44,26 @@ export function useLocalizedStrings({ localizations }) {
45
44
  return result;
46
45
  }
47
46
 
48
- function getLocaleToUse(languageCodes, localizations) {
49
- const matchingLanguages = languageCodes.filter(
50
- R.contains(R.__, localizations)
51
- );
47
+ export function getIsRTL(): boolean {
48
+ const uiLanguage = getUILanguage();
49
+
50
+ if (!uiLanguage) {
51
+ utilsLogger.error({ message: "getUILanguage returned null or undefined" });
52
52
 
53
- if (matchingLanguages?.length) {
54
- return R.head(matchingLanguages);
53
+ return false;
55
54
  }
56
55
 
57
- return R.head(localizations);
58
- }
56
+ const [languageCode] = uiLanguage.split("-");
59
57
 
60
- export function getIsRTLFromLocalizations(localizations): boolean {
61
- const deviceLocales = getDeviceLocales() || [];
62
- const localeToUse = getLocaleToUse(deviceLocales, R.keys(localizations));
58
+ const lowerCaseLanguageCode = languageCode.toLocaleLowerCase();
63
59
 
64
- return R.contains(localeToUse, RTL_LOCALES);
60
+ const isRTL = R.contains(lowerCaseLanguageCode, RTL_LOCALES);
61
+
62
+ return isRTL;
65
63
  }
66
64
 
67
65
  export function useIsRTL(): boolean {
68
- const localizations = useSelector(
69
- R.path(["remoteConfigurations", "localizations"])
70
- );
71
-
72
- return getIsRTLFromLocalizations(localizations);
66
+ return getIsRTL();
73
67
  }
74
68
 
75
69
  export const applyRTLStylesIfNeeded = (
package/logger/index.ts CHANGED
@@ -72,7 +72,7 @@ const { quickBrickLogger, coreLogger, logger, logLevels, utilsLogger } =
72
72
  function useLogger(
73
73
  logger: XRayLoggerI,
74
74
  eventData: UseLoggerHookArgs,
75
- deps = []
75
+ deps: string[] = []
76
76
  ) {
77
77
  const {
78
78
  level = logLevels.verbose,
@@ -245,6 +245,12 @@ const generalContent = () => ({
245
245
  ],
246
246
  initial_value: "reloading...",
247
247
  },
248
+ {
249
+ type: "text_input",
250
+ label: "Navigation Bar Screen Title",
251
+ key: "screen_title",
252
+ initial_value: null,
253
+ },
248
254
  ],
249
255
  },
250
256
  advertising: {
@@ -1663,7 +1663,8 @@ function getPlayerConfiguration({ platform }) {
1663
1663
  platform.includes("lg") ||
1664
1664
  platform.includes("samsung") ||
1665
1665
  platform.includes("android_tv") ||
1666
- platform.includes("amazon")
1666
+ platform.includes("amazon") ||
1667
+ platform.includes("vizio")
1667
1668
  ) {
1668
1669
  styles.fields.push(
1669
1670
  // Captions Menu
@@ -22,7 +22,11 @@ const {
22
22
  const { buttonKey } = require("./buttons");
23
23
  const { tvBadges } = require("./tvBadges");
24
24
  const { mobileProgressBar, tvProgressBar } = require("./progressBar");
25
- const { secondaryImage, getUpdatedSecondaryImageKeys } = require("./secondaryImage");
25
+
26
+ const {
27
+ secondaryImage,
28
+ getUpdatedSecondaryImageKeys,
29
+ } = require("./secondaryImage");
26
30
 
27
31
  module.exports = {
28
32
  fontKey,
@@ -132,29 +132,32 @@ function secondaryImage({
132
132
 
133
133
  const POSITION_OVER_IMAGE = toSnakeCase(position_over_image);
134
134
 
135
- const getUpdatedSecondaryImageKeys = (secondaryImageManifest) => secondaryImageManifest.fields.reduce((acc, item) => {
136
- const key = item.key;
135
+ const getUpdatedSecondaryImageKeys = (secondaryImageManifest) =>
136
+ secondaryImageManifest.fields.reduce((acc, item) => {
137
+ const key = item.key;
137
138
 
138
- const conditionalFields = (item.conditional_fields || []).map((field) => field.key);
139
+ const conditionalFields = (item.conditional_fields || []).map(
140
+ (field) => field.key
141
+ );
139
142
 
140
- const updatedConditionalFields = conditionalFields.reduce((acc, field) => {
141
- const updatedKey = field.replace("secondary_image_", "nested_image_");
143
+ const updatedConditionalFields = conditionalFields.reduce((acc, field) => {
144
+ const updatedKey = field.replace("secondary_image_", "nested_image_");
145
+
146
+ return {
147
+ ...acc,
148
+ [updatedKey]: field,
149
+ };
150
+ }, {});
151
+
152
+ const updatedKey = key.replace("secondary_image_", "nested_image_");
142
153
 
143
154
  return {
144
155
  ...acc,
145
- [updatedKey]: field,
156
+ ...updatedConditionalFields,
157
+ [updatedKey]: key,
146
158
  };
147
159
  }, {});
148
160
 
149
- const updatedKey = key.replace("secondary_image_", "nested_image_");
150
-
151
- return {
152
- ...acc,
153
- ...updatedConditionalFields,
154
- [updatedKey]: key,
155
- };
156
- }, {});
157
-
158
161
  module.exports = {
159
162
  secondaryImage,
160
163
  getUpdatedSecondaryImageKeys,
@@ -7,12 +7,24 @@ describe("isLikeNumber", () => {
7
7
  expect(isLikeNumber(value)).toBe(true);
8
8
  });
9
9
 
10
+ it("value is a number", () => {
11
+ const value = 123.45;
12
+
13
+ expect(isLikeNumber(value)).toBe(true);
14
+ });
15
+
10
16
  it("value is a string as number", () => {
11
17
  const value = "123";
12
18
 
13
19
  expect(isLikeNumber(value)).toBe(true);
14
20
  });
15
21
 
22
+ it("value is a string as number", () => {
23
+ const value = "123.45";
24
+
25
+ expect(isLikeNumber(value)).toBe(true);
26
+ });
27
+
16
28
  it("value is empty string", () => {
17
29
  const value = "";
18
30
 
@@ -54,4 +66,10 @@ describe("isLikeNumber", () => {
54
66
 
55
67
  expect(isLikeNumber(value)).toBe(false);
56
68
  });
69
+
70
+ it("NaN is not a number", () => {
71
+ const value = NaN;
72
+
73
+ expect(isLikeNumber(value)).toBe(false);
74
+ });
57
75
  });
@@ -50,28 +50,19 @@ export const toFiniteNumberWithDefault = (
50
50
  return possibleNumber;
51
51
  };
52
52
 
53
- export const isLikeNumber = (value: any): boolean => {
54
- if (R.isEmpty(value)) {
55
- return false;
56
- }
57
-
58
- if (R.is(Number, value)) {
59
- return true;
60
- }
53
+ export const isLikeNumber = (value: unknown): boolean => {
54
+ const possibleNumber = toNumber(value);
61
55
 
62
- if (R.is(String, value)) {
63
- const onlyDigit = value
64
- .split("")
65
- .filter((char) =>
66
- ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"].includes(char)
67
- )
68
- .join("");
69
-
70
- return value === onlyDigit;
56
+ if (R.isNil(possibleNumber)) {
57
+ return false;
71
58
  }
72
59
 
73
- return false;
60
+ return true;
74
61
  };
75
62
 
76
63
  export const isZero = (value: unknown): boolean =>
77
64
  Object.is(value, -0) || Object.is(value, 0);
65
+
66
+ export const isMinusZero = (value: number) => {
67
+ return 1 / value === -Infinity;
68
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "12.0.0-alpha.5251355865",
3
+ "version": "12.0.0-alpha.5347482137",
4
4
  "description": "Applicaster Zapp React Native utilities package",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "12.0.0-alpha.5251355865",
31
+ "@applicaster/applicaster-types": "12.0.0-alpha.5347482137",
32
32
  "buffer": "^5.2.1",
33
33
  "camelize": "^1.0.0",
34
34
  "create-react-context": "^0.2.3",
@@ -22,6 +22,7 @@ function getDevice(platform) {
22
22
  case "android_tv_for_quickbrick":
23
23
  case "lg_tv":
24
24
  case "samsung_tv":
25
+ case "vizio":
25
26
  case "web":
26
27
  return "tv";
27
28
  }
@@ -1659,7 +1660,8 @@ function getPlayerConfiguration({ platform }) {
1659
1660
  platform.includes("lg") ||
1660
1661
  platform.includes("samsung") ||
1661
1662
  platform.includes("android_tv") ||
1662
- platform.includes("amazon")
1663
+ platform.includes("amazon") ||
1664
+ platform.includes("vizio")
1663
1665
  ) {
1664
1666
  styles.fields.push(
1665
1667
  // Captions Menu for TV
@@ -12,6 +12,8 @@ jest.mock(
12
12
  })
13
13
  );
14
14
 
15
+ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation");
16
+
15
17
  jest.useFakeTimers();
16
18
 
17
19
  const {
@@ -1,4 +1,8 @@
1
+ import React from "react";
2
+
1
3
  import { act, renderHook } from "@testing-library/react-hooks";
4
+ import { Provider } from "react-redux";
5
+ import configureStore from "redux-mock-store";
2
6
 
3
7
  const mockUpdateComponentsPositions = jest.fn();
4
8
 
@@ -17,11 +21,24 @@ jest.mock(
17
21
 
18
22
  jest.useFakeTimers();
19
23
 
24
+ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation");
25
+
26
+ const mockStore = configureStore();
27
+
28
+ const store = mockStore({ appData: {} });
29
+
30
+ const Wrapper = ({ children }: { children: React.ReactChild }) => (
31
+ /* @ts-ignore */
32
+ <Provider store={store}>{children}</Provider>
33
+ );
34
+
20
35
  const { useTrackedView } = require("../useTrackedView");
21
36
 
22
37
  describe("useTrackCurrentAutoScrollingElement", () => {
23
38
  it("should update position for selected component", async () => {
24
- const { result } = renderHook(() => useTrackedView("123"));
39
+ const { result } = renderHook(() => useTrackedView("123"), {
40
+ wrapper: Wrapper,
41
+ });
25
42
 
26
43
  // Fast-forward until all timers have been executed
27
44
  jest.advanceTimersByTime(3000);
@@ -1,11 +1,14 @@
1
1
  import * as React from "react";
2
2
  import { cleanup, renderHook } from "@testing-library/react-hooks";
3
3
  import { CellTapContext } from "@applicaster/zapp-react-native-ui-components/Contexts/CellTapContext";
4
+ import { ActionExecutorContext } from "@applicaster/zapp-react-native-utils/actionsExecutor/ActionExecutorContext";
5
+
4
6
  import { waitFor } from "@testing-library/react-native";
5
7
 
6
8
  const navigator = {
7
9
  getPathname: () => "pathnameMock",
8
10
  push: jest.fn(),
11
+ data: {},
9
12
  };
10
13
 
11
14
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
@@ -42,9 +45,15 @@ const mockProps = {
42
45
 
43
46
  const onCellTap = jest.fn();
44
47
 
48
+ const actionExecutor = {
49
+ handleEntryActions: jest.fn(() => Promise.resolve()),
50
+ };
51
+
45
52
  const wrapper = ({ children }) => (
46
53
  <CellTapContext.Provider value={onCellTap}>
47
- {children}
54
+ <ActionExecutorContext.Provider value={actionExecutor}>
55
+ {children}
56
+ </ActionExecutorContext.Provider>
48
57
  </CellTapContext.Provider>
49
58
  );
50
59
 
@@ -11,9 +11,9 @@ import {
11
11
  } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
12
12
  import { ZappPipesEntryContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
13
13
  import { toBooleanWithDefaultTrue } from "@applicaster/zapp-react-native-utils/booleanUtils";
14
- import { noop } from "../../functionUtils";
15
- import { useContext } from "react";
16
- import { ActionExecutorContext } from "../../actionsExecutor/ActionExecutorContext";
14
+ import { ActionExecutorContext } from "@applicaster/zapp-react-native-utils/actionsExecutor/ActionExecutorContext";
15
+
16
+ import { isFunction, noop } from "../../functionUtils";
17
17
  import { useSendAnalyticsOnPress } from "../analytics";
18
18
  import { logOnPress, warnEmptyContentType } from "./helpers";
19
19
 
@@ -30,12 +30,12 @@ type Props = {
30
30
  zappPipesData?: ZappPipesData;
31
31
  };
32
32
 
33
- export const useCellClick = (props: Props) => {
34
- const { component, zappPipesData } = props;
33
+ export const useCellClick = ({ component, zappPipesData, item }: Props) => {
35
34
  const { push, currentRoute } = useNavigation();
36
35
  const { pathname } = useRoute();
37
- const onCellTap = React.useContext(CellTapContext);
38
- const actionExecutor = useContext(ActionExecutorContext);
36
+
37
+ const onCellTap: Option<Function> = React.useContext(CellTapContext);
38
+ const actionExecutor = React.useContext(ActionExecutorContext);
39
39
 
40
40
  const cellSelectable = toBooleanWithDefaultTrue(
41
41
  component?.rules?.component_cells_selectable
@@ -47,7 +47,7 @@ export const useCellClick = (props: Props) => {
47
47
  const logTimestamp = useProfilerLogging();
48
48
 
49
49
  const sendAnalyticsOnPress = useSendAnalyticsOnPress(
50
- props.item,
50
+ item,
51
51
  component,
52
52
  zappPipesData
53
53
  );
@@ -56,7 +56,7 @@ export const useCellClick = (props: Props) => {
56
56
  async (_item?: ZappEntry | any, _index?: number) => {
57
57
  // Making sure we are not getting GestureResponderEvent in here.
58
58
  const isZappEntry = _item?.id && _item?.type;
59
- const selectedItem = isZappEntry ? _item : props.item;
59
+ const selectedItem = isZappEntry ? _item : item;
60
60
  setEntryContext?.(selectedItem);
61
61
 
62
62
  if (!selectedItem?.type?.value) {
@@ -80,10 +80,10 @@ export const useCellClick = (props: Props) => {
80
80
  });
81
81
  }
82
82
  } else {
83
- if (typeof onCellTap === "function") {
84
- onCellTap(selectedItem, _index);
83
+ if (isFunction(onCellTap)) {
84
+ onCellTap?.(selectedItem, _index);
85
85
  } else {
86
- if (currentRoute === pathname || pathname === "videoModal") {
86
+ if (currentRoute === pathname || pathname.includes("video-modal")) {
87
87
  const targetScreen = component?.data?.target;
88
88
 
89
89
  push(