@applicaster/zapp-react-native-ui-components 13.0.0-rc.14 → 13.0.0-rc.141

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 (226) hide show
  1. package/Components/AppContainer/__tests__/AppContainer.test.js +4 -6
  2. package/Components/AppContainer/__tests__/__snapshots__/AppContainer.test.js.snap +1 -1
  3. package/Components/AudioPlayer/index.tsx +15 -0
  4. package/Components/AudioPlayer/mobile/Layout.tsx +66 -0
  5. package/Components/AudioPlayer/mobile/__tests__/__snapshots__/audioPlayerMobileLayout.test.js.snap +66 -0
  6. package/Components/AudioPlayer/mobile/__tests__/audioPlayerMobileLayout.test.js +18 -0
  7. package/Components/AudioPlayer/mobile/index.tsx +18 -0
  8. package/Components/AudioPlayer/tv/Artwork.tsx +40 -0
  9. package/Components/AudioPlayer/{AudioPlayerLayout.tsx → tv/Layout.tsx} +37 -79
  10. package/Components/AudioPlayer/{Runtime.tsx → tv/Runtime.tsx} +2 -1
  11. package/Components/AudioPlayer/{Summary.tsx → tv/Summary.tsx} +12 -9
  12. package/Components/AudioPlayer/{Title.tsx → tv/Title.tsx} +12 -9
  13. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/Runtime.test.js +5 -8
  14. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/Runtime.test.js.snap +6 -6
  15. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/artWork.test.js.snap +11 -6
  16. package/Components/AudioPlayer/tv/__tests__/__snapshots__/audioPlayer.test.js.snap +170 -0
  17. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/channel.test.js.snap +3 -3
  18. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/summary.test.js.snap +3 -3
  19. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/title.test.js.snap +3 -3
  20. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/artWork.test.js +3 -5
  21. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/audioPlayer.test.js +9 -7
  22. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/channel.test.js +3 -5
  23. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/summary.test.js +3 -5
  24. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/title.test.js +3 -5
  25. package/Components/AudioPlayer/{helpers.tsx → tv/helpers.tsx} +3 -5
  26. package/Components/AudioPlayer/{AudioPlayer.tsx → tv/index.tsx} +14 -63
  27. package/Components/AudioPlayer/types.ts +40 -0
  28. package/Components/BaseFocusable/index.ios.ts +1 -1
  29. package/Components/BaseFocusable/index.tsx +67 -31
  30. package/Components/Cell/Cell.tsx +14 -14
  31. package/Components/Cell/CellWithFocusable.tsx +50 -59
  32. package/Components/Cell/CellWrapper.tsx +18 -0
  33. package/Components/Cell/TvOSCellComponent.tsx +20 -26
  34. package/Components/Cell/__tests__/CellWIthFocusable.test.js +13 -6
  35. package/Components/Cell/index.js +3 -1
  36. package/Components/Cell/styles.ts +17 -0
  37. package/Components/CellRendererResolver/__tests__/cellRendererResolver.test.js +50 -50
  38. package/Components/CellRendererResolver/index.ts +2 -1
  39. package/Components/ComponentResolver/__tests__/__snapshots__/componentResolver.test.js.snap +1 -42
  40. package/Components/ComponentResolver/__tests__/componentResolver.test.js +26 -30
  41. package/Components/ContentScreen/__tests__/contentScreen.test.js +3 -3
  42. package/Components/DisplayState/__tests__/__snapshots__/displayState.test.js.snap +2 -2
  43. package/Components/ErrorScreen/index.tsx +14 -6
  44. package/Components/Focusable/Focusable.tsx +1 -54
  45. package/Components/Focusable/FocusableTvOS.tsx +6 -2
  46. package/Components/Focusable/Touchable.tsx +19 -20
  47. package/Components/Focusable/index.android.tsx +10 -3
  48. package/Components/FocusableCell/index.tsx +1 -1
  49. package/Components/FocusableGroup/FocusableTvOS.tsx +34 -86
  50. package/Components/FocusableGroup/index.tsx +0 -3
  51. package/Components/FocusableList/index.tsx +26 -10
  52. package/Components/FocusableScrollView/index.tsx +43 -13
  53. package/Components/GeneralContentScreen/GeneralContentScreen.tsx +3 -0
  54. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +9 -0
  55. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +5 -3
  56. package/Components/GeneralContentScreen/utils/useEventAlerts.ts +30 -0
  57. package/Components/HandlePlayable/HandlePlayable.tsx +21 -27
  58. package/Components/Layout/TV/LayoutBackground.tsx +28 -0
  59. package/Components/Layout/TV/NavBarContainer.tsx +19 -23
  60. package/Components/Layout/TV/ScreenContainer.tsx +8 -2
  61. package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +5 -0
  62. package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +3 -1
  63. package/Components/Layout/TV/__tests__/__snapshots__/LayoutContainer.test.tsx.snap +1 -1
  64. package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +6 -5
  65. package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +12 -11
  66. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +15 -10
  67. package/Components/Layout/TV/__tests__/index.test.tsx +14 -4
  68. package/Components/Layout/TV/index.tsx +6 -20
  69. package/Components/Layout/TV/index.web.tsx +4 -1
  70. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -3
  71. package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +66 -0
  72. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +4 -1
  73. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +10 -15
  74. package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +11 -7
  75. package/Components/MasterCell/DefaultComponents/ImageBorderContainer/__tests__/index.test.ts +93 -0
  76. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +2 -2
  77. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +3 -3
  78. package/Components/MasterCell/DefaultComponents/SecondaryImage/utils.ts +1 -1
  79. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
  80. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/const.ts +3 -0
  81. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/index.ts +6 -6
  82. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/__snapshots__/index.test.tsx.snap +1 -1
  83. package/Components/MasterCell/SharedUI/ProgressBar/hooks/useFillInPercent.ts +2 -8
  84. package/Components/MasterCell/__tests__/__snapshots__/dataAdapter.test.js.snap +180 -180
  85. package/Components/MasterCell/__tests__/__snapshots__/elementMapper.test.js.snap +11 -19
  86. package/Components/MasterCell/__tests__/__snapshots__/masterCell.test.js.snap +6 -235
  87. package/Components/MasterCell/__tests__/elementMapper.test.js +18 -5
  88. package/Components/MasterCell/__tests__/masterCell.test.js +26 -26
  89. package/Components/MasterCell/hooks/useAsyncRendering/MasterCellAsyncRenderManager.ts +2 -2
  90. package/Components/MasterCell/hooks/useAsyncRendering/index.ts +2 -2
  91. package/Components/MasterCell/utils/behaviorProvider.ts +136 -0
  92. package/Components/MasterCell/utils/index.ts +9 -135
  93. package/Components/ModalComponent/BottomSheetModalContent.tsx +66 -54
  94. package/Components/ModalComponent/Button/Item.tsx +6 -5
  95. package/Components/ModalComponent/Button/assets.ts +1 -1
  96. package/Components/ModalComponent/Button/index.tsx +45 -62
  97. package/Components/ModalComponent/Header/index.tsx +12 -11
  98. package/Components/ModalComponent/utils.ts +55 -7
  99. package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +2 -2
  100. package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +2 -2
  101. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -5
  102. package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +7 -7
  103. package/Components/OfflineHandler/__tests__/index.test.tsx +28 -25
  104. package/Components/OfflineHandler/utils/index.ts +1 -1
  105. package/Components/PlayerContainer/PlayerContainer.tsx +76 -66
  106. package/Components/PlayerContainer/PlayerContainerContext.tsx +9 -0
  107. package/Components/PlayerContainer/ProgramInfo/index.tsx +2 -2
  108. package/Components/PlayerImageBackground/index.tsx +2 -2
  109. package/Components/River/ComponentsMap/ComponentsMap.tsx +49 -68
  110. package/Components/River/ComponentsMap/hooks/useLoadingState.ts +78 -51
  111. package/Components/River/RefreshControl.tsx +1 -1
  112. package/Components/River/RiverFooter.tsx +39 -9
  113. package/Components/River/RiverItem.tsx +44 -4
  114. package/Components/River/TV/index.tsx +6 -1
  115. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +115 -46
  116. package/Components/River/__tests__/__snapshots__/river.test.js.snap +21 -83
  117. package/Components/River/__tests__/componentsMap.test.js +64 -17
  118. package/Components/River/__tests__/river.test.js +75 -40
  119. package/Components/RouteManager/TestId.tsx +1 -5
  120. package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +11 -5
  121. package/Components/RouteManager/__tests__/routeManager.test.js +29 -14
  122. package/Components/RouteManager/__tests__/testId.test.js +4 -6
  123. package/Components/Screen/TV/__tests__/index.web.test.tsx +26 -0
  124. package/Components/Screen/TV/index.web.tsx +5 -6
  125. package/Components/Screen/__tests__/Screen.test.tsx +53 -31
  126. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +6 -6
  127. package/Components/Screen/hooks.ts +53 -0
  128. package/Components/Screen/index.tsx +16 -42
  129. package/Components/ScreenResolver/__tests__/screenResolver.test.js +95 -70
  130. package/Components/Tabs/Tab.tsx +12 -9
  131. package/Components/TextInputTv/__tests__/TextInputTv.test.js +42 -42
  132. package/Components/TextInputTv/__tests__/__snapshots__/TextInputTv.test.js.snap +7 -0
  133. package/Components/TextInputTv/index.tsx +6 -5
  134. package/Components/TopMarginApplicator/TopMarginApplicator.tsx +2 -3
  135. package/Components/Touchable/__tests__/__snapshots__/touchable.test.tsx.snap +2 -2
  136. package/Components/TrackedView/index.tsx +1 -0
  137. package/Components/Transitioner/AnimationManager.js +15 -15
  138. package/Components/Transitioner/Scene.tsx +53 -24
  139. package/Components/Transitioner/Transitioner.tsx +3 -3
  140. package/Components/Transitioner/__tests__/Scene.test.js +25 -14
  141. package/Components/Transitioner/__tests__/__snapshots__/AnimationManager.test.js.snap +26 -26
  142. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +10 -50
  143. package/Components/Transitioner/__tests__/__snapshots__/config.test.js.snap +20 -20
  144. package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +4 -4
  145. package/Components/Transitioner/__tests__/transitioner.test.js +13 -4
  146. package/Components/Transitioner/index.js +8 -4
  147. package/Components/VideoLive/LiveImageManager.ts +27 -1
  148. package/Components/VideoLive/PlayerLiveImageComponent.tsx +36 -24
  149. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +63 -8
  150. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +6 -10
  151. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +1 -1
  152. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +51 -31
  153. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +8 -4
  154. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +48 -23
  155. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +16 -15
  156. package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +108 -0
  157. package/Components/VideoModal/ModalAnimation/const.ts +5 -0
  158. package/Components/VideoModal/ModalAnimation/index.ts +4 -1
  159. package/Components/VideoModal/ModalAnimation/useModalAnimationContext.ts +6 -0
  160. package/Components/VideoModal/ModalAnimation/utils.ts +32 -2
  161. package/Components/VideoModal/OpaqueLayer.tsx +33 -0
  162. package/Components/VideoModal/PlayerDetails.tsx +18 -10
  163. package/Components/VideoModal/PlayerWrapper.tsx +51 -57
  164. package/Components/VideoModal/VideoModal.tsx +17 -11
  165. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +5 -2
  166. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +13 -10
  167. package/Components/VideoModal/__tests__/__snapshots__/PlayerDetails.test.tsx.snap +2 -40
  168. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +74 -104
  169. package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +51 -0
  170. package/Components/VideoModal/hooks/index.ts +7 -0
  171. package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +38 -0
  172. package/Components/VideoModal/hooks/utils/__tests__/showDetails.test.ts +91 -0
  173. package/Components/VideoModal/hooks/utils/index.ts +33 -0
  174. package/Components/VideoModal/utils.ts +6 -9
  175. package/Components/Viewport/ViewportAware/__tests__/__snapshots__/viewportAware.test.js.snap +24 -36
  176. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +12 -18
  177. package/Components/Viewport/ViewportTracker/__tests__/__snapshots__/viewportTracker.test.js.snap +1 -1
  178. package/Components/Viewport/__tests__/utils.test.js +5 -4
  179. package/Components/ZappUIComponent/Placeholder.tsx +3 -1
  180. package/Components/ZappUIComponent/__tests__/{ZappUIComponent.test.js → ZappUIComponent.test.tsx} +26 -10
  181. package/Components/ZappUIComponent/index.tsx +4 -17
  182. package/Components/default-cell-renderer/__tests__/defaultCellRenderer.test.tsx +20 -17
  183. package/Components/default-cell-renderer/viewTrees/tv/DefaultCell/__tests__/DefaultCell.test.tsx +15 -11
  184. package/Contexts/ComponentsMapOffsetContext/index.tsx +49 -0
  185. package/Contexts/ConfigutaionContext/__tests__/__snapshots__/ConfigurationProvider.test.tsx.snap +1 -1
  186. package/Contexts/FocusableGroupContext/withFocusableContext.tsx +4 -10
  187. package/Contexts/HeaderOffsetContext/index.tsx +4 -6
  188. package/Contexts/ScreenContext/index.tsx +6 -12
  189. package/Contexts/ScreenLayoutContext/index.tsx +5 -3
  190. package/Decorators/Navigator/__tests__/navigator.test.js +16 -16
  191. package/Decorators/Navigator/index.tsx +1 -1
  192. package/Decorators/RiverFeedLoader/__tests__/__snapshots__/riverFeedLoader.test.tsx.snap +77 -77
  193. package/Decorators/RiverFeedLoader/__tests__/riverFeedLoader.test.tsx +34 -39
  194. package/Decorators/RiverFeedLoader/__tests__/utils.test.ts +0 -9
  195. package/Decorators/RiverFeedLoader/index.tsx +1 -1
  196. package/Decorators/RiverFeedLoader/utils/getDatasourceUrl.ts +39 -0
  197. package/Decorators/RiverFeedLoader/utils/index.ts +29 -0
  198. package/Decorators/RiverFeedLoader/utils/usePipesContexts.ts +40 -0
  199. package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +27 -27
  200. package/Decorators/RiverResolver/index.tsx +6 -8
  201. package/Decorators/ZappPipesDataConnector/__tests__/Hero.js +1 -1
  202. package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +29 -22
  203. package/Decorators/ZappPipesDataConnector/index.tsx +7 -3
  204. package/package.json +13 -11
  205. package/tsconfig.json +2 -3
  206. package/.babelrc +0 -8
  207. package/Components/AudioPlayer/Artwork.tsx +0 -35
  208. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +0 -123
  209. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +0 -50
  210. package/Components/AudioPlayer/__tests__/audioPlayerLayout.test.js +0 -27
  211. package/Components/AudioPlayer/index.ts +0 -1
  212. package/Components/Cell/CellStyles/FallbackCellStyle/index.js +0 -157
  213. package/Components/Cell/CellStyles/Hero/index.js +0 -111
  214. package/Components/Cell/CellStyles/ScreenSelector/index.js +0 -68
  215. package/Components/Cell/CellStyles/cellStylesResolver.ts +0 -19
  216. package/Components/Cell/CellStyles/colors.js +0 -40
  217. package/Components/Cell/CellStyles/index.js +0 -15
  218. package/Components/CellRendererResolver/__tests__/__snapshots__/cellRendererResolver.test.js.snap +0 -53
  219. package/Components/RouteManager/__tests__/__snapshots__/testId.test.js.snap +0 -17
  220. package/Components/ScreenResolver/__tests__/__snapshots__/screenResolver.test.js.snap +0 -17
  221. package/Components/ZappUIComponent/__tests__/__snapshots__/ZappUIComponent.test.js.snap +0 -91
  222. package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +0 -338
  223. package/Decorators/Navigator/__tests__/__snapshots__/navigator.test.js.snap +0 -18
  224. package/Decorators/RiverFeedLoader/utils.ts +0 -100
  225. package/Decorators/RiverResolver/__tests__/__snapshots__/riverResolver.test.tsx.snap +0 -28
  226. /package/Components/AudioPlayer/{Channel.tsx → tv/Channel.tsx} +0 -0
@@ -1,157 +1,180 @@
1
1
  import React from "react";
2
2
  import { View } from "react-native";
3
- import { shallow } from "enzyme";
4
- import { shallowToJson } from "enzyme-to-json";
5
- import { connect as realConnect } from "react-redux";
3
+ import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
6
4
 
7
5
  const pluginConfiguration = { foo: "bar" };
8
6
 
9
- const ScreenType1 = jest.fn(() => <View />);
10
- const ScreenType2 = jest.fn(() => <View />);
7
+ const MockModuleView = (testID) => {
8
+ // eslint-disable-next-line react/display-name
9
+ return function (props) {
10
+ return <View testID={testID} {...props} />;
11
+ };
12
+ };
13
+
14
+ const ScreenType1 = MockModuleView("screen_type_1");
15
+ const ScreenType2 = MockModuleView("screen_type_2");
16
+ const PlayerController = MockModuleView("player_controller");
11
17
 
12
- const ScreenType3 = {
13
- module: jest.fn(() => <View />),
18
+ const mockScreenType3 = {
19
+ module: MockModuleView("screen_type_3"),
14
20
  name: "ScreenType3",
15
21
  type: "screen_type_3",
16
22
  configuration: pluginConfiguration,
17
23
  };
18
24
 
19
- const ScreenType4 = {
20
- module: jest.fn(() => <View />),
25
+ const mockScreenType4 = {
26
+ module: MockModuleView("screen_type_4"),
21
27
  name: "ScreenType4",
22
28
  type: "screen_type_4",
23
29
  };
24
30
 
25
- const PlayerController = jest.fn(() => <View />);
26
-
27
- const playerPlugin = {
28
- module: jest.fn(() => <View />),
31
+ const mockPlayerPlugin = {
32
+ module: MockModuleView("player_plugin"),
29
33
  name: "playerPlugin",
30
34
  type: "player",
31
35
  };
32
36
 
33
- const ScreenPlugin = {
34
- module: jest.fn(() => <View />),
37
+ const mockScreenPlugin = {
38
+ module: MockModuleView("screen_plugin"),
35
39
  type: "general",
36
40
  name: "Screen plugin",
37
41
  identifier: "screen-plugin",
38
42
  };
39
43
 
40
- const PluginWithConfig = {
41
- module: jest.fn(() => <View />),
44
+ const mockPluginWithConfig = {
45
+ module: MockModuleView("plugin_with_config"),
42
46
  type: "general",
43
47
  name: "Plugin with config",
44
48
  identifier: "plugin-with-config",
45
49
  configuration: pluginConfiguration,
46
50
  };
47
51
 
48
- const components = { ScreenType1, ScreenType2, PlayerController };
49
-
50
- const plugins = {
51
- ScreenType3,
52
- ScreenType4,
53
- playerPlugin,
54
- ScreenPlugin,
55
- PluginWithConfig,
52
+ const mockComponents = { ScreenType1, ScreenType2, PlayerController };
53
+
54
+ const mockState = {
55
+ components: mockComponents,
56
+ plugins: [
57
+ mockScreenType3,
58
+ mockScreenType4,
59
+ mockPlayerPlugin,
60
+ mockScreenPlugin,
61
+ mockPluginWithConfig,
62
+ ],
63
+ rivers: {
64
+ A1234: {},
65
+ },
56
66
  };
57
67
 
58
- const withAnalytics = {
59
- sendOnClickEvent: jest.fn(),
60
- sendMenuClickEvent: jest.fn(),
61
- sendMenuToggleEvent: jest.fn(),
62
- sendBackButtonClickEvent: jest.fn(),
63
- sendOnNavItemClickEvent: jest.fn(),
64
- sendHeaderClickEvent: jest.fn(),
65
- sendHardwareBackButtonClickEvent: jest.fn(),
66
- sendScreenEvent: jest.fn(),
67
- };
68
+ jest.mock(
69
+ "@applicaster/zapp-react-native-utils/analyticsUtils/helpers/hooks",
70
+ () => ({
71
+ useScreenAnalytics: jest.fn(),
72
+ })
73
+ );
68
74
 
69
- jest.mock("@applicaster/zapp-react-native-utils/analyticsUtils", () => ({
70
- useAnalytics: jest.fn().mockReturnValue(withAnalytics),
71
- }));
75
+ jest.mock(
76
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation",
77
+ () => ({
78
+ useNavigation: jest.fn(() => ({
79
+ closeVideoModal: jest.fn(),
80
+ videoModalState: {
81
+ mode: "test",
82
+ },
83
+ })),
84
+ })
85
+ );
72
86
 
73
- jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
74
- usePickFromState: jest.fn(() => ({ components, plugins })),
75
- }));
87
+ jest.mock(
88
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute",
89
+ () => ({
90
+ useRoute: jest.fn(() => ({ screenId: "1234" })),
91
+ })
92
+ );
76
93
 
77
94
  jest.mock(
78
- "@applicaster/zapp-react-native-utils/analyticsUtils/helpers/hooks",
95
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/useIsScreenActive",
79
96
  () => ({
80
- useScreenAnalytics: jest.fn(() => {}),
97
+ useIsScreenActive: () => ({
98
+ isScreenActive: true,
99
+ }),
81
100
  })
82
101
  );
83
102
 
84
- jest.mock("react-redux", () => ({
85
- useDispatch: jest.fn(() => () => {}),
86
- connect: realConnect,
87
- }));
103
+ jest.mock("../../PlayerContainer", () => {
104
+ const { View } = jest.requireActual("react-native");
88
105
 
89
- jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
90
- useNavigation: jest.fn(() => ({
91
- videoModalState: {
92
- mode: "test",
93
- },
94
- })),
95
- useRoute: jest.fn(() => ({ screenId: "1234" })),
96
- }));
106
+ return {
107
+ PlayerContainer: (props) => (
108
+ <View {...props}>
109
+ <props.Player />
110
+ </View>
111
+ ),
112
+ };
113
+ });
97
114
 
98
- const { ScreenResolverComponent: ScreenResolver } = require("..");
115
+ const getWrapper = (screenId, screenType, screenData) => {
116
+ const ScreenResolver = require("../").ScreenResolverComponent;
99
117
 
100
- const getWrapper = (screenId, screenType, screenData) =>
101
- shallow(
118
+ return renderWithProviders(
102
119
  <ScreenResolver
103
120
  {...{
104
121
  screenId,
105
122
  screenType,
106
123
  screenData,
107
124
  }}
108
- />
125
+ />,
126
+ mockState
109
127
  );
128
+ };
110
129
 
111
130
  describe("<ScreenResolver />", () => {
112
131
  it("renders correctly", () => {
113
132
  const wrapper = getWrapper("1234", "screen_type_1", {});
114
133
 
115
- expect(shallowToJson(wrapper)).toMatchSnapshot();
134
+ expect(wrapper.getByTestId("screen_type_1")).toBeDefined();
116
135
  });
117
136
 
118
137
  it("picks screen from plugins if it exists", () => {
119
138
  const wrapper = getWrapper("A1234", "screen_type_3", {});
120
139
 
121
- expect(wrapper.find(ScreenType3.module)).toHaveProperty("length", 1);
140
+ expect(wrapper.getByTestId("screen_type_3")).toBeDefined();
122
141
  });
123
142
 
124
143
  it("picks the screen from its identifier if it exists", () => {
125
144
  const wrapper = getWrapper("A1234", "screen-plugin", {});
126
145
 
127
- expect(wrapper.find(ScreenPlugin.module)).toHaveProperty("length", 1);
146
+ expect(wrapper.getByTestId("screen_plugin")).toBeDefined();
128
147
  });
129
148
 
130
149
  it("picks screen from components if it doesn't exist in plugins", () => {
131
150
  const wrapper = getWrapper("A1234", "screen_type_2", {});
132
151
 
133
- expect(wrapper.find(ScreenType2)).toHaveProperty("length", 1);
152
+ expect(wrapper.getByTestId("screen_type_2")).toBeDefined();
134
153
  });
135
154
 
136
155
  it("renders the screen and passes screenId & locationState as props", () => {
137
156
  const wrapper = getWrapper("A1234", "screen_type_3", "foo");
138
157
 
139
- const screenWrapper = wrapper.find(ScreenType3.module);
158
+ const screenWrapper = wrapper.getByTestId("screen_type_3");
140
159
 
141
- expect(screenWrapper.prop("screenId")).toEqual("A1234");
142
- expect(screenWrapper.prop("screenData")).toEqual("foo");
160
+ expect(screenWrapper.props).toMatchObject({
161
+ screenId: "A1234",
162
+ screenData: "foo",
163
+ });
143
164
  });
144
165
 
145
166
  it("renders null if the screen is not found", () => {
146
167
  const wrapper = getWrapper(null, "screen_type_5", {});
147
168
 
148
- expect(wrapper.getElement()).toBe(null);
169
+ expect(wrapper.queryAllByTestId("screen_type_5")).toBeEmpty();
149
170
  });
150
171
 
151
172
  it("injects the plugin configuration if it exists", () => {
152
173
  const wrapper = getWrapper("A1234", "plugin-with-config", {});
153
174
 
154
- expect(wrapper.find(PluginWithConfig.module).props()).toHaveProperty(
175
+ const screenWrapper = wrapper.getByTestId("plugin_with_config");
176
+
177
+ expect(screenWrapper.props).toHaveProperty(
155
178
  "configuration",
156
179
  expect.objectContaining(pluginConfiguration)
157
180
  );
@@ -160,7 +183,9 @@ describe("<ScreenResolver />", () => {
160
183
  it("injects the plugin configuration if it exists, even when plugin is resolved by type", () => {
161
184
  const wrapper = getWrapper("A1234", "screen_type_3", {});
162
185
 
163
- expect(wrapper.find(ScreenType3.module).props()).toHaveProperty(
186
+ const screenWrapper = wrapper.getByTestId("screen_type_3");
187
+
188
+ expect(screenWrapper.props).toHaveProperty(
164
189
  "configuration",
165
190
  expect.objectContaining(pluginConfiguration)
166
191
  );
@@ -168,6 +193,6 @@ describe("<ScreenResolver />", () => {
168
193
 
169
194
  it("wraps the player with the playerController component when the screenType is playable", () => {
170
195
  const wrapper = getWrapper("A1234", "playable", {});
171
- expect(shallowToJson(wrapper)).toMatchSnapshot();
196
+ expect(wrapper.getByTestId("player_plugin")).toBeDefined();
172
197
  });
173
198
  });
@@ -1,11 +1,11 @@
1
1
  /* eslint-disable react-native/no-unused-styles */
2
2
  import React from "react";
3
3
  import * as R from "ramda";
4
- import { View, Text, StyleSheet, TouchableWithoutFeedback } from "react-native";
4
+ import { StyleSheet, Text, TouchableWithoutFeedback, View } from "react-native";
5
5
  import { useConfiguration } from "@applicaster/zapp-react-native-utils/reactHooks/configuration";
6
6
  import {
7
- getStyleForPlatform,
8
7
  applyStringTransformation,
8
+ getStyleForPlatform,
9
9
  } from "@applicaster/zapp-react-native-utils/configurationUtils";
10
10
 
11
11
  type Props = {
@@ -69,8 +69,8 @@ const getStyles = (configuration, selected, focused) => {
69
69
  ? tab_cell_background_color_selected_active
70
70
  : tab_cell_background_color_selected_default
71
71
  : focused
72
- ? tab_cell_background_color_active
73
- : tab_cell_background_color_default,
72
+ ? tab_cell_background_color_active
73
+ : tab_cell_background_color_default,
74
74
  justifyContent: "center",
75
75
  alignItems: "center",
76
76
  position: "relative",
@@ -85,8 +85,8 @@ const getStyles = (configuration, selected, focused) => {
85
85
  ? tab_cell_border_color_active_focused
86
86
  : tab_cell_border_color_active
87
87
  : focused
88
- ? tab_cell_border_color_default_focused
89
- : tab_cell_border_color_default,
88
+ ? tab_cell_border_color_default_focused
89
+ : tab_cell_border_color_default,
90
90
  },
91
91
  label: {
92
92
  fontFamily: text_label_font_family,
@@ -98,8 +98,8 @@ const getStyles = (configuration, selected, focused) => {
98
98
  ? text_label_selected_active_font_color
99
99
  : text_label_selected_default_font_color
100
100
  : focused
101
- ? text_label_active_font_color
102
- : text_label_default_font_color,
101
+ ? text_label_active_font_color
102
+ : text_label_default_font_color,
103
103
  },
104
104
  underline: {
105
105
  position: "absolute",
@@ -138,6 +138,7 @@ const Tab = ({ title, selected, handleOnPress }: Props, ref: any) => {
138
138
 
139
139
  return (
140
140
  <TouchableWithoutFeedback
141
+ testID="tab-touchable"
141
142
  onPressIn={handleOnPressIn}
142
143
  onPressOut={handleOnPressOut}
143
144
  onPress={handleOnPress}
@@ -147,7 +148,9 @@ const Tab = ({ title, selected, handleOnPress }: Props, ref: any) => {
147
148
  <Text numberOfLines={1} style={styles.label}>
148
149
  {tabTitle}
149
150
  </Text>
150
- {selected && <View testID="underline" style={styles.underline} />}
151
+ {selected ? (
152
+ <View testID="underline" style={styles.underline} />
153
+ ) : null}
151
154
  </View>
152
155
  </View>
153
156
  </TouchableWithoutFeedback>
@@ -1,18 +1,13 @@
1
1
  import React from "react";
2
- import TestRenderer from "react-test-renderer";
3
-
4
- jest.mock("react-native", () => {
5
- const RNMock = jest.genMockFromModule("react-native");
6
- const { TextInput } = jest.requireActual("react-native");
7
-
8
- return {
9
- ...RNMock,
10
- TextInput,
11
- Platform: {
12
- OS: "samsung_tv",
13
- isTV: true,
14
- },
15
- };
2
+ import { Platform } from "react-native";
3
+ import { render } from "@testing-library/react-native";
4
+
5
+ Platform.OS = "samsung_tv";
6
+
7
+ Object.defineProperty(Platform, "isTV", {
8
+ get() {
9
+ return true;
10
+ },
16
11
  });
17
12
 
18
13
  jest.mock("@applicaster/zapp-react-native-utils/localizationUtils", () => ({
@@ -20,12 +15,12 @@ jest.mock("@applicaster/zapp-react-native-utils/localizationUtils", () => ({
20
15
  }));
21
16
 
22
17
  const { TextInputTv } = require("../");
23
- const { Platform, TextInput } = require("react-native");
18
+ const testIDToTest = "TextInput-tv";
24
19
 
25
20
  describe("<TextInputTv />", () => {
26
21
  it("renders", () => {
27
- const testInstance = TestRenderer.create(<TextInputTv />);
28
- expect(testInstance.toJSON).toBeTruthy();
22
+ const { toJSON } = render(<TextInputTv />);
23
+ expect(toJSON()).toMatchSnapshot();
29
24
  });
30
25
 
31
26
  describe("on native", () => {
@@ -34,8 +29,8 @@ describe("<TextInputTv />", () => {
34
29
  });
35
30
 
36
31
  it("returns React-Native TextInput component if not on samsung", () => {
37
- const testInstance = TestRenderer.create(<TextInputTv />);
38
- expect(testInstance.root.findByType(TextInput)).toBeTruthy();
32
+ const { getByTestId } = render(<TextInputTv />);
33
+ expect(getByTestId(testIDToTest)).toBeTruthy();
39
34
  });
40
35
  });
41
36
 
@@ -45,29 +40,30 @@ describe("<TextInputTv />", () => {
45
40
  });
46
41
 
47
42
  it("returns React input component if on samsung", () => {
48
- const testInstance = TestRenderer.create(<TextInputTv type="samsung" />);
49
- expect(testInstance.root.findByType("input")).toBeTruthy();
43
+ const { getByTestId } = render(<TextInputTv type="samsung" />);
44
+ expect(getByTestId(testIDToTest)).toBeTruthy();
50
45
  });
51
46
 
52
47
  it("flattens styles", () => {
53
48
  Platform.OS = "samsung_tv";
54
49
  const style = [{ width: 200 }, { height: 200 }];
55
- const testInstance = TestRenderer.create(<TextInputTv style={style} />);
56
50
 
57
- expect(typeof testInstance.root.findByType("input").props.style).toBe(
58
- "object"
51
+ const { getByTestId } = render(
52
+ <TextInputTv type="samsung" style={style} />
59
53
  );
54
+
55
+ expect(getByTestId(testIDToTest).props.style).toBeObject();
60
56
  });
61
57
 
62
58
  it("maps onChangeText to onChange", () => {
63
59
  Platform.OS = "samsung_tv";
64
60
  const onChangeText = jest.fn();
65
61
 
66
- const testInstance = TestRenderer.create(
67
- <TextInputTv onChangeText={onChangeText} />
62
+ const { getByTestId } = render(
63
+ <TextInputTv type="samsung" onChangeText={onChangeText} />
68
64
  );
69
65
 
70
- const inputInstance = testInstance.root.findByType("input");
66
+ const inputInstance = getByTestId(testIDToTest);
71
67
  expect(inputInstance.props.onChange).toBeDefined();
72
68
  expect(inputInstance.props.onChangeText).toBeUndefined();
73
69
  });
@@ -76,11 +72,11 @@ describe("<TextInputTv />", () => {
76
72
  Platform.OS = "samsung_tv";
77
73
  const onChangeText = jest.fn();
78
74
 
79
- const testInstance = TestRenderer.create(
80
- <TextInputTv onChangeText={onChangeText} />
75
+ const { getByTestId } = render(
76
+ <TextInputTv type="samsung" onChangeText={onChangeText} />
81
77
  );
82
78
 
83
- const inputInstance = testInstance.root.findByType("input");
79
+ const inputInstance = getByTestId(testIDToTest);
84
80
  const value = "foobar";
85
81
  inputInstance.props.onChange({ target: { value: value } });
86
82
  expect(onChangeText).toBeCalledWith(value);
@@ -89,11 +85,12 @@ describe("<TextInputTv />", () => {
89
85
  it("maps onEndEditing to onBlur", () => {
90
86
  Platform.OS = "samsung_tv";
91
87
 
92
- const testInstance = TestRenderer.create(
93
- <TextInputTv onEndEditing={() => null} />
88
+ const { getByTestId } = render(
89
+ <TextInputTv type="samsung" onEndEditing={() => null} />
94
90
  );
95
91
 
96
- const inputInstance = testInstance.root.findByType("input");
92
+ const inputInstance = getByTestId(testIDToTest);
93
+
97
94
  expect(inputInstance.props.onBlur).toBeDefined();
98
95
  expect(inputInstance.props.onEndEditing).toBeUndefined();
99
96
  });
@@ -101,11 +98,12 @@ describe("<TextInputTv />", () => {
101
98
  it("maps onPress to onClick", () => {
102
99
  Platform.OS = "samsung_tv";
103
100
 
104
- const testInstance = TestRenderer.create(
105
- <TextInputTv onPress={() => null} />
101
+ const { getByTestId } = render(
102
+ <TextInputTv type="samsung" onPress={() => null} />
106
103
  );
107
104
 
108
- const inputInstance = testInstance.root.findByType("input");
105
+ const inputInstance = getByTestId(testIDToTest);
106
+
109
107
  expect(inputInstance.props.onClick).toBeDefined();
110
108
  expect(inputInstance.props.onPress).toBeUndefined();
111
109
  });
@@ -113,22 +111,24 @@ describe("<TextInputTv />", () => {
113
111
  it("replaces secureTextEntry with type:'password'", () => {
114
112
  Platform.OS = "samsung_tv";
115
113
 
116
- const testInstance = TestRenderer.create(
117
- <TextInputTv secureTextEntry={true} />
114
+ const { getByTestId } = render(
115
+ <TextInputTv type="samsung" secureTextEntry />
118
116
  );
119
117
 
120
- const inputInstance = testInstance.root.findByType("input");
118
+ const inputInstance = getByTestId(testIDToTest);
119
+
121
120
  expect(inputInstance.props.type).toBe("password");
122
121
  });
123
122
 
124
123
  it("removes 'onChangeText', 'secureTextEntry', 'onEndEditing', 'onPress' props", () => {
125
124
  Platform.OS = "samsung_tv";
126
125
 
127
- const testInstance = TestRenderer.create(
128
- <TextInputTv onChangeText secureTextEntry onEndEditing />
126
+ const { getByTestId } = render(
127
+ <TextInputTv type="samsung" onChangeText secureTextEntry onEndEditing />
129
128
  );
130
129
 
131
- const inputInstance = testInstance.root.findByType("input");
130
+ const inputInstance = getByTestId(testIDToTest);
131
+
132
132
  expect(inputInstance.props.onChangeText).toBeUndefined();
133
133
  expect(inputInstance.props.secureTextEntry).toBeUndefined();
134
134
  expect(inputInstance.props.onEndEditing).toBeUndefined();
@@ -0,0 +1,7 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`<TextInputTv /> renders 1`] = `
4
+ <input
5
+ testID="TextInput-tv"
6
+ />
7
+ `;
@@ -94,8 +94,8 @@ function TextInputTV(props: Props, ref) {
94
94
  styles.textAlign === "center"
95
95
  ? styles.textAlign
96
96
  : styles.textAlign === "left"
97
- ? "right"
98
- : "left";
97
+ ? "right"
98
+ : "left";
99
99
 
100
100
  return { style: { ...styles, textAlign } };
101
101
  }
@@ -174,11 +174,12 @@ function TextInputTV(props: Props, ref) {
174
174
 
175
175
  return isWebPlatform ? (
176
176
  <>
177
- {additional && additional()}
178
- <input ref={ref} {...inputProps} />
177
+ {additional ? additional() : null}
178
+ {/* eslint-disable-next-line react/no-unknown-property */}
179
+ <input testID="TextInput-tv" ref={ref} {...inputProps} />
179
180
  </>
180
181
  ) : (
181
- <TextInput ref={ref} {...inputProps} />
182
+ <TextInput testID="TextInput-tv" ref={ref} {...inputProps} />
182
183
  );
183
184
  }
184
185
 
@@ -2,6 +2,7 @@ import React from "react";
2
2
  import { View, ViewProps, ViewStyle } from "react-native";
3
3
  import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
4
4
  import { useCurrentScreenData } from "@applicaster/zapp-react-native-utils/reactHooks";
5
+ import { isFirstComponentScreenPicker } from "@applicaster/zapp-react-native-utils/componentsUtils";
5
6
 
6
7
  interface IProps {
7
8
  targetScreenId?: string;
@@ -31,11 +32,9 @@ export const useMarginTop = (targetScreenId: string): number => {
31
32
  * ScreenPicker is a component but should really be a screen.
32
33
  * We need to skip margin top for it as it's already applied to the target screen
33
34
  **/
34
- const isScreenPicker =
35
- screenData?.ui_components?.[0]?.component_type === "screen-picker-qb-tv";
36
35
 
37
36
  // ignore margin on screenPicker
38
- if (isScreenPicker) {
37
+ if (isFirstComponentScreenPicker(screenData?.ui_components)) {
39
38
  return 0;
40
39
  }
41
40
 
@@ -14,7 +14,7 @@ exports[`<Touchable /> when not running in automated tests environment renders c
14
14
  onResponderTerminationRequest={[Function]}
15
15
  onStartShouldSetResponder={[Function]}
16
16
  style={
17
- Object {
17
+ {
18
18
  "opacity": 1,
19
19
  }
20
20
  }
@@ -40,7 +40,7 @@ exports[`<Touchable /> when running in automated tests environment has accessibl
40
40
  onResponderTerminationRequest={[Function]}
41
41
  onStartShouldSetResponder={[Function]}
42
42
  style={
43
- Object {
43
+ {
44
44
  "opacity": 1,
45
45
  }
46
46
  }
@@ -12,6 +12,7 @@ type TrackedViewProps = {
12
12
  onPositionUpdated: (props: { rect?: Record<string, number> }) => void;
13
13
  testId?: string | undefined;
14
14
  groupId?: string;
15
+ clipThreshold?: number;
15
16
  };
16
17
 
17
18
  export const TrackedView = memo(function TrackedView(props: TrackedViewProps) {
@@ -2,21 +2,21 @@ import { Animated } from "react-native";
2
2
 
3
3
  import { NAV_ACTION_PUSH, NAV_ACTION_BACK } from "./Transitioner";
4
4
 
5
- type TransitionConfig = {
6
- duration: number,
7
- easing: any,
8
- from: {
9
- style: any,
10
- },
11
- to: {
12
- style: any,
13
- },
14
- };
5
+ // type TransitionConfig = {
6
+ // duration: number;
7
+ // easing: any;
8
+ // from: {
9
+ // style: any;
10
+ // };
11
+ // to: {
12
+ // style: any;
13
+ // };
14
+ // };
15
15
 
16
- type Props = {
17
- transitionConfig: TransitionConfig,
18
- contentStyle: { [string]: any },
19
- };
16
+ // type Props = {
17
+ // transitionConfig: TransitionConfig;
18
+ // contentStyle: { [string]: any };
19
+ // };
20
20
 
21
21
  /**
22
22
  * Manages animation for the Transitioner,
@@ -25,7 +25,7 @@ type Props = {
25
25
  * which must have a proper structure, see types above ^.
26
26
  */
27
27
  export class AnimationManager {
28
- constructor(props: Props) {
28
+ constructor(props) {
29
29
  this.animatedValue = new Animated.Value(0.0);
30
30
 
31
31
  this.config = props.transitionConfig(