@applicaster/zapp-react-native-ui-components 13.0.0-alpha.1436249127 → 13.0.0-alpha.1488035644

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 (112) hide show
  1. package/Components/AppContainer/__tests__/__snapshots__/AppContainer.test.js.snap +1 -1
  2. package/Components/AudioPlayer/__tests__/__snapshots__/Runtime.test.js.snap +4 -4
  3. package/Components/AudioPlayer/__tests__/__snapshots__/artWork.test.js.snap +3 -3
  4. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +6 -6
  5. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +7 -7
  6. package/Components/AudioPlayer/__tests__/__snapshots__/channel.test.js.snap +3 -3
  7. package/Components/AudioPlayer/__tests__/__snapshots__/summary.test.js.snap +2 -2
  8. package/Components/AudioPlayer/__tests__/__snapshots__/title.test.js.snap +2 -2
  9. package/Components/BaseFocusable/index.ios.ts +1 -1
  10. package/Components/BaseFocusable/index.tsx +1 -1
  11. package/Components/Cell/Cell.tsx +7 -3
  12. package/Components/Cell/CellWithFocusable.tsx +13 -10
  13. package/Components/Cell/TvOSCellComponent.tsx +0 -4
  14. package/Components/CellRendererResolver/__tests__/__snapshots__/cellRendererResolver.test.js.snap +20 -20
  15. package/Components/CellRendererResolver/__tests__/cellRendererResolver.test.js +5 -3
  16. package/Components/ComponentResolver/__tests__/__snapshots__/componentResolver.test.js.snap +5 -5
  17. package/Components/ComponentResolver/__tests__/componentResolver.test.js +11 -9
  18. package/Components/DisplayState/__tests__/__snapshots__/displayState.test.js.snap +2 -2
  19. package/Components/Focusable/FocusableTvOS.tsx +1 -1
  20. package/Components/Focusable/Touchable.tsx +19 -20
  21. package/Components/FocusableList/index.tsx +0 -1
  22. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +9 -0
  23. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +1 -1
  24. package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +1 -0
  25. package/Components/Layout/TV/__tests__/__snapshots__/LayoutContainer.test.tsx.snap +1 -1
  26. package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +3 -3
  27. package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +9 -9
  28. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +1 -1
  29. package/Components/Layout/TV/__tests__/index.test.tsx +7 -3
  30. package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +66 -0
  31. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +4 -1
  32. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +6 -12
  33. package/Components/MasterCell/DefaultComponents/ImageBorderContainer/__tests__/index.test.ts +93 -0
  34. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +3 -3
  35. package/Components/MasterCell/DefaultComponents/SecondaryImage/utils.ts +1 -1
  36. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
  37. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/__snapshots__/index.test.tsx.snap +1 -1
  38. package/Components/MasterCell/__tests__/__snapshots__/dataAdapter.test.js.snap +180 -180
  39. package/Components/MasterCell/__tests__/__snapshots__/elementMapper.test.js.snap +7 -7
  40. package/Components/MasterCell/__tests__/__snapshots__/masterCell.test.js.snap +34 -45
  41. package/Components/MasterCell/elementMapper.tsx +12 -1
  42. package/Components/MasterCell/hooks/useAsyncRendering/index.ts +2 -2
  43. package/Components/MasterCell/index.tsx +84 -18
  44. package/Components/MasterCell/utils/index.ts +1 -1
  45. package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +7 -7
  46. package/Components/OfflineHandler/__tests__/index.test.tsx +28 -25
  47. package/Components/PlayerContainer/PlayerContainer.tsx +5 -11
  48. package/Components/PlayerContainer/PlayerContainerContext.tsx +9 -0
  49. package/Components/River/RefreshControl.tsx +1 -1
  50. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +17 -17
  51. package/Components/River/__tests__/__snapshots__/river.test.js.snap +12 -12
  52. package/Components/River/__tests__/componentsMap.test.js +61 -13
  53. package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +1 -1
  54. package/Components/RouteManager/__tests__/__snapshots__/testId.test.js.snap +1 -1
  55. package/Components/Screen/__tests__/Screen.test.tsx +41 -27
  56. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +4 -4
  57. package/Components/ScreenResolver/__tests__/__snapshots__/screenResolver.test.js.snap +2 -2
  58. package/Components/ScreenResolver/__tests__/screenResolver.test.js +31 -27
  59. package/Components/Tabs/Tab.tsx +7 -6
  60. package/Components/TextInputTv/__tests__/TextInputTv.test.js +42 -42
  61. package/Components/TextInputTv/__tests__/__snapshots__/TextInputTv.test.js.snap +7 -0
  62. package/Components/TextInputTv/index.tsx +4 -4
  63. package/Components/Touchable/__tests__/__snapshots__/touchable.test.tsx.snap +2 -2
  64. package/Components/Transitioner/AnimationManager.js +8 -8
  65. package/Components/Transitioner/__tests__/__snapshots__/AnimationManager.test.js.snap +26 -26
  66. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +9 -9
  67. package/Components/Transitioner/__tests__/__snapshots__/config.test.js.snap +20 -20
  68. package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +2 -2
  69. package/Components/VideoLive/LiveImageManager.ts +27 -1
  70. package/Components/VideoLive/PlayerLiveImageComponent.tsx +18 -16
  71. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +63 -8
  72. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +5 -10
  73. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +5 -1
  74. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +5 -1
  75. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +8 -7
  76. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +4 -10
  77. package/Components/VideoModal/ModalAnimation/index.ts +2 -1
  78. package/Components/VideoModal/ModalAnimation/useModalAnimationContext.ts +6 -0
  79. package/Components/VideoModal/ModalAnimation/utils.ts +2 -2
  80. package/Components/VideoModal/OpaqueLayer.tsx +33 -0
  81. package/Components/VideoModal/PlayerWrapper.tsx +16 -35
  82. package/Components/VideoModal/VideoModal.tsx +14 -23
  83. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +5 -2
  84. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +13 -10
  85. package/Components/VideoModal/__tests__/__snapshots__/PlayerDetails.test.tsx.snap +4 -4
  86. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +66 -156
  87. package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +89 -0
  88. package/Components/VideoModal/hooks/index.ts +7 -0
  89. package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +49 -0
  90. package/Components/VideoModal/hooks/utils/__tests__/showDetails.test.ts +91 -0
  91. package/Components/VideoModal/hooks/utils/index.ts +33 -0
  92. package/Components/VideoModal/utils.ts +3 -5
  93. package/Components/Viewport/ViewportAware/__tests__/__snapshots__/viewportAware.test.js.snap +2 -2
  94. package/Components/Viewport/ViewportTracker/__tests__/__snapshots__/viewportTracker.test.js.snap +1 -1
  95. package/Components/ZappUIComponent/__tests__/__snapshots__/ZappUIComponent.test.js.snap +11 -11
  96. package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +30 -62
  97. package/Contexts/ConfigutaionContext/__tests__/__snapshots__/ConfigurationProvider.test.tsx.snap +1 -1
  98. package/Contexts/ScreenContext/index.tsx +3 -2
  99. package/Decorators/Navigator/__tests__/__snapshots__/navigator.test.js.snap +2 -2
  100. package/Decorators/RiverFeedLoader/__tests__/__snapshots__/riverFeedLoader.test.tsx.snap +77 -77
  101. package/Decorators/RiverFeedLoader/__tests__/riverFeedLoader.test.tsx +34 -39
  102. package/Decorators/RiverFeedLoader/__tests__/utils.test.ts +0 -9
  103. package/Decorators/RiverFeedLoader/index.tsx +1 -1
  104. package/Decorators/RiverFeedLoader/utils/getDatasourceUrl.ts +39 -0
  105. package/Decorators/RiverFeedLoader/utils/index.ts +29 -0
  106. package/Decorators/RiverFeedLoader/utils/usePipesContexts.ts +40 -0
  107. package/Decorators/RiverResolver/__tests__/__snapshots__/riverResolver.test.tsx.snap +5 -5
  108. package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +16 -10
  109. package/Decorators/ZappPipesDataConnector/__tests__/Hero.js +1 -1
  110. package/Decorators/ZappPipesDataConnector/index.tsx +32 -2
  111. package/package.json +12 -6
  112. package/Decorators/RiverFeedLoader/utils.ts +0 -100
@@ -9,11 +9,14 @@ type ContextProps = {
9
9
  setIsLanguageOverlayVisible: (isVisible) => void;
10
10
  setShowComponentsContainer: (isVisible) => void;
11
11
  showComponentsContainer: boolean;
12
+ setIsSeekBarTouch: (isTouch) => void;
13
+ isSeekBarTouch: boolean;
12
14
  };
13
15
 
14
16
  export const PlayerContainerContext = createContext({
15
17
  ignoreOffsetContainer: false,
16
18
  isLanguageOverlayVisible: false,
19
+ isSeekBarTouch: false,
17
20
  } as ContextProps);
18
21
 
19
22
  type Props = {
@@ -40,6 +43,8 @@ export const PlayerContainerContextProvider = ({
40
43
  const [showComponentsContainer, setShowComponentsContainer] =
41
44
  React.useState(true);
42
45
 
46
+ const [isSeekBarTouch, setIsSeekBarTouch] = React.useState(false);
47
+
43
48
  const value = React.useMemo(
44
49
  () => ({
45
50
  ignoreOffsetContainer,
@@ -49,6 +54,8 @@ export const PlayerContainerContextProvider = ({
49
54
  setIsLanguageOverlayVisible,
50
55
  showComponentsContainer,
51
56
  setShowComponentsContainer: inline ? setShowComponentsContainer : null,
57
+ isSeekBarTouch,
58
+ setIsSeekBarTouch,
52
59
  }),
53
60
  [
54
61
  ignoreOffsetContainer,
@@ -58,6 +65,8 @@ export const PlayerContainerContextProvider = ({
58
65
  setIsLanguageOverlayVisible,
59
66
  showComponentsContainer,
60
67
  setShowComponentsContainer,
68
+ isSeekBarTouch,
69
+ setIsSeekBarTouch,
61
70
  ]
62
71
  );
63
72
 
@@ -9,7 +9,7 @@ import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
9
9
  import { useLocalizedStrings } from "@applicaster/zapp-react-native-utils/localizationUtils";
10
10
  import { useAnalytics } from "@applicaster/zapp-react-native-utils/analyticsUtils";
11
11
  import { useSendAnalyticsEventWithFunction } from "@applicaster/zapp-react-native-utils/analyticsUtils/helpers/hooks";
12
- import { useCurrentScreenData } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
12
+ import { useCurrentScreenData } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useCurrentScreenData";
13
13
  import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
14
14
  import { useDispatch } from "react-redux";
15
15
  import { useShallow } from "zustand/react/shallow";
@@ -3,7 +3,7 @@
3
3
  exports[`componentsMap renders renders components map correctly 1`] = `
4
4
  <View
5
5
  style={
6
- Object {
6
+ {
7
7
  "flex": 1,
8
8
  }
9
9
  }
@@ -11,7 +11,7 @@ exports[`componentsMap renders renders components map correctly 1`] = `
11
11
  <View
12
12
  onLayout={[Function]}
13
13
  style={
14
- Object {
14
+ {
15
15
  "flex": 1,
16
16
  }
17
17
  }
@@ -19,7 +19,7 @@ exports[`componentsMap renders renders components map correctly 1`] = `
19
19
  <RCTScrollView
20
20
  ListFooterComponent={[Function]}
21
21
  contentContainerStyle={
22
- Object {
22
+ {
23
23
  "paddingBottom": undefined,
24
24
  "paddingLeft": undefined,
25
25
  "paddingRight": undefined,
@@ -27,22 +27,22 @@ exports[`componentsMap renders renders components map correctly 1`] = `
27
27
  }
28
28
  }
29
29
  data={
30
- Array [
31
- Object {
30
+ [
31
+ {
32
32
  "component_type": "hero",
33
33
  "id": "A1",
34
- "styles": Object {
35
- "cell_styles": Array [
34
+ "styles": {
35
+ "cell_styles": [
36
36
  "some",
37
37
  "obsolete",
38
38
  "ids",
39
39
  ],
40
40
  },
41
41
  },
42
- Object {
42
+ {
43
43
  "component_type": "grid",
44
44
  "id": "A2",
45
- "styles": Object {
45
+ "styles": {
46
46
  "master_cell_id": "uuid-5678-B",
47
47
  },
48
48
  },
@@ -66,12 +66,12 @@ exports[`componentsMap renders renders components map correctly 1`] = `
66
66
  renderItem={[Function]}
67
67
  scrollEventThrottle={16}
68
68
  scrollIndicatorInsets={
69
- Object {
69
+ {
70
70
  "right": 1,
71
71
  }
72
72
  }
73
- stickyHeaderIndices={Array []}
74
- viewabilityConfigCallbackPairs={Array []}
73
+ stickyHeaderIndices={[]}
74
+ viewabilityConfigCallbackPairs={[]}
75
75
  windowSize={12}
76
76
  >
77
77
  <View>
@@ -81,7 +81,7 @@ exports[`componentsMap renders renders components map correctly 1`] = `
81
81
  >
82
82
  <View
83
83
  style={
84
- Object {
84
+ {
85
85
  "display": "flex",
86
86
  }
87
87
  }
@@ -89,7 +89,7 @@ exports[`componentsMap renders renders components map correctly 1`] = `
89
89
  <View
90
90
  onLayout={[Function]}
91
91
  style={
92
- Object {
92
+ {
93
93
  "flex": 1,
94
94
  }
95
95
  }
@@ -104,7 +104,7 @@ exports[`componentsMap renders renders components map correctly 1`] = `
104
104
  >
105
105
  <View
106
106
  style={
107
- Object {
107
+ {
108
108
  "display": "none",
109
109
  }
110
110
  }
@@ -112,7 +112,7 @@ exports[`componentsMap renders renders components map correctly 1`] = `
112
112
  <View
113
113
  onLayout={[Function]}
114
114
  style={
115
- Object {
115
+ {
116
116
  "flex": 1,
117
117
  }
118
118
  }
@@ -127,7 +127,7 @@ exports[`componentsMap renders renders components map correctly 1`] = `
127
127
  <View
128
128
  renderToHardwareTextureAndroid={true}
129
129
  style={
130
- Object {
130
+ {
131
131
  "alignItems": "center",
132
132
  "height": null,
133
133
  "justifyContent": "center",
@@ -6,42 +6,42 @@ exports[`When River has a general_content type <River /> renders correctly 1`] =
6
6
  >
7
7
  <RiverWithData
8
8
  appData={
9
- Object {
9
+ {
10
10
  "layoutVersion": "v1",
11
11
  }
12
12
  }
13
13
  dispatch={[Function]}
14
14
  rivers={
15
- Object {
16
- "A1234": Object {
15
+ {
16
+ "A1234": {
17
17
  "home": true,
18
18
  "id": "A1234",
19
19
  "name": "foo",
20
20
  "type": "general_content",
21
- "ui_components": Array [
22
- Object {
21
+ "ui_components": [
22
+ {
23
23
  "component_type": "hero",
24
24
  },
25
- Object {
25
+ {
26
26
  "component_type": "grid",
27
27
  },
28
28
  ],
29
29
  },
30
- "B4567": Object {
30
+ "B4567": {
31
31
  "id": "B4567",
32
32
  },
33
- "C0987": Object {
33
+ "C0987": {
34
34
  "home": false,
35
35
  "id": "C0987",
36
36
  "name": "Some-Screen-Plugin",
37
37
  "type": "some-screen-plugin",
38
- "ui_components": Array [],
38
+ "ui_components": [],
39
39
  },
40
40
  }
41
41
  }
42
42
  screenId="A1234"
43
43
  store={
44
- Object {
44
+ {
45
45
  "clearActions": [Function],
46
46
  "dispatch": [Function],
47
47
  "getActions": [Function],
@@ -64,13 +64,13 @@ exports[`When River has a general_content type <RiverComponent /> renders correc
64
64
  exports[`When River has any other type other than general_content <RiverComponent /> renders correctly 1`] = `
65
65
  <WithProvider
66
66
  screenData={
67
- Object {
67
+ {
68
68
  "groupId": undefined,
69
69
  "home": false,
70
70
  "id": "C0987",
71
71
  "name": "Some-Screen-Plugin",
72
72
  "type": "some-screen-plugin",
73
- "ui_components": Array [],
73
+ "ui_components": [],
74
74
  }
75
75
  }
76
76
  screenId="C0987"
@@ -75,28 +75,70 @@ const riverComponents = [
75
75
  },
76
76
  ];
77
77
 
78
- const screenData = {
78
+ const mockScreenData = {
79
79
  ui_components: riverComponents,
80
80
  rules: { pull_to_refresh_enabled: false },
81
81
  id: "A1234",
82
82
  };
83
83
 
84
+ jest.mock("@applicaster/zapp-react-native-redux/AppStore", () => ({
85
+ appStore: {
86
+ get: jest.fn((prop) => mockStore[prop]),
87
+ getState: jest.fn(),
88
+ },
89
+ }));
90
+
84
91
  jest.mock("@applicaster/zapp-react-native-utils/localizationUtils", () => ({
85
92
  useIsRTL: jest.fn(() => mock_rtl_flag),
86
93
  }));
87
94
 
88
- jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
89
- useNavigation: jest.fn(() => ({ currentRoute: "/river/A1234" })),
90
- useRoute: jest.fn(() => ({ pathname: "/river/A1234", screenData })),
91
- useProfilerLogging: jest.fn(),
92
- useIsScreenActive: jest.fn().mockReturnValue(true),
93
- }));
95
+ jest.mock(
96
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation",
97
+ () => ({
98
+ useNavigation: jest.fn(() => ({ currentRoute: "/river/A1234" })),
99
+ })
100
+ );
94
101
 
95
- jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
96
- useCurrentScreenData: jest.fn(() => screenData),
97
- useScreenData: jest.fn(() => screenData),
98
- useScreenContext: jest.fn(() => screenData),
99
- }));
102
+ jest.mock(
103
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute",
104
+ () => ({
105
+ useRoute: jest.fn(() => ({
106
+ pathname: "/river/A1234",
107
+ screenData: mockScreenData,
108
+ })),
109
+ })
110
+ );
111
+
112
+ jest.mock(
113
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/useIsScreenActive",
114
+ () => ({
115
+ useIsScreenActive: jest.fn().mockReturnValue(true),
116
+ })
117
+ );
118
+
119
+ jest.mock(
120
+ "@applicaster/zapp-react-native-utils/reactHooks/screen/useCurrentScreenData",
121
+ () => ({
122
+ useCurrentScreenData: jest.fn(() => mockScreenData),
123
+ })
124
+ );
125
+
126
+ jest.mock(
127
+ "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenData",
128
+ () => ({
129
+ useScreenData: jest.fn(() => mockScreenData),
130
+ })
131
+ );
132
+
133
+ jest.mock(
134
+ "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext",
135
+ () => ({
136
+ ...jest.requireActual(
137
+ "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext"
138
+ ),
139
+ useScreenContext: jest.fn(() => mockScreenData),
140
+ })
141
+ );
100
142
 
101
143
  const { View } = require("react-native");
102
144
  const { ComponentsMap } = require("../ComponentsMap/ComponentsMap");
@@ -118,7 +160,13 @@ const plugins = [];
118
160
  const navigation = {};
119
161
 
120
162
  const props = { components, cellStyles, riverComponents, navigation };
121
- const store = mockStore({ components, cellStyles, plugins });
163
+
164
+ const store = mockStore({
165
+ components,
166
+ cellStyles,
167
+ plugins,
168
+ getState: jest.fn(),
169
+ });
122
170
 
123
171
  jest.useFakeTimers();
124
172
 
@@ -7,7 +7,7 @@ exports[`<RouteManager /> renders correctly 1`] = `
7
7
  <WithProvider
8
8
  pathname="/river/A1234"
9
9
  screenData={
10
- Object {
10
+ {
11
11
  "id": "A1234",
12
12
  }
13
13
  }
@@ -4,7 +4,7 @@ exports[`TestId renders correctly and assigns the testID to a wrapping view 1`]
4
4
  <View
5
5
  accessibilityLabel="A1234"
6
6
  style={
7
- Object {
7
+ {
8
8
  "flex": 1,
9
9
  }
10
10
  }
@@ -46,27 +46,37 @@ jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
46
46
  })),
47
47
  }));
48
48
 
49
- const NavBar = jest.fn((props) => <View testID="navBar" {...props} />);
49
+ const mockNavBar = jest.fn((props) => {
50
+ const View = jest.requireActual("react-native").View;
51
+
52
+ return <View testID="navBar" {...props} />;
53
+ });
50
54
 
51
55
  jest.mock(
52
56
  "@applicaster/zapp-react-native-app/App/Layout/layoutHelpers",
53
57
  () => ({
54
- getNavigationPluginModule: () => NavBar,
58
+ getNavigationPluginModule: () => mockNavBar,
55
59
  })
56
60
  );
57
61
 
58
- jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
59
- ...(jest.requireActual(
60
- "@applicaster/zapp-react-native-utils/reactHooks/screen"
61
- ) as any),
62
- useScreenData: jest.fn(() => ({
63
- id: "testId",
64
- navigations: [{ id: "testId", category: "nav_bar" }],
65
- })),
66
- useCurrentScreenData: jest.fn(() => ({
67
- id: "testId",
68
- })),
69
- }));
62
+ jest.mock(
63
+ "@applicaster/zapp-react-native-utils/reactHooks/screen/useCurrentScreenData",
64
+ () => ({
65
+ useCurrentScreenData: jest.fn(() => ({
66
+ id: "testId",
67
+ })),
68
+ })
69
+ );
70
+
71
+ jest.mock(
72
+ "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenData",
73
+ () => ({
74
+ useScreenData: jest.fn(() => ({
75
+ id: "testId",
76
+ navigations: [{ id: "testId", category: "nav_bar" }],
77
+ })),
78
+ })
79
+ );
70
80
 
71
81
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
72
82
  isNavBarVisible: mockIsNavBarVisible,
@@ -84,20 +94,24 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
84
94
  useIsScreenActive: jest.fn().mockReturnValue(true),
85
95
  }));
86
96
 
87
- jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
88
- usePickFromState: () => ({
89
- plugins: [
90
- {
91
- name: "Offline Plugin",
92
- identifier: "offline-experience",
93
- type: "general",
94
- module: {
95
- OfflineFallbackScreen: ({ children }) => <View>{children}</View>, // eslint-disable-line
97
+ jest.mock("@applicaster/zapp-react-native-redux/hooks/usePickFromState", () => {
98
+ const View = jest.requireActual("react-native").View;
99
+
100
+ return {
101
+ usePickFromState: () => ({
102
+ plugins: [
103
+ {
104
+ name: "Offline Plugin",
105
+ identifier: "offline-experience",
106
+ type: "general",
107
+ module: {
108
+ OfflineFallbackScreen: ({ children }) => <View>{children}</View>, // eslint-disable-line
109
+ },
96
110
  },
97
- },
98
- ],
99
- }),
100
- }));
111
+ ],
112
+ }),
113
+ };
114
+ });
101
115
 
102
116
  const {
103
117
  allowedOrientationsForScreen,
@@ -3,7 +3,7 @@
3
3
  exports[`<Screen Component /> when the navbar should be hidden renders correctly 1`] = `
4
4
  <View
5
5
  style={
6
- Object {
6
+ {
7
7
  "backgroundColor": "blue",
8
8
  "flex": 1,
9
9
  "paddingTop": 0,
@@ -22,7 +22,7 @@ exports[`<Screen Component /> when the navbar should be hidden renders correctly
22
22
  <View
23
23
  pathname="/river/testId"
24
24
  screenData={
25
- Object {
25
+ {
26
26
  "id": "testId",
27
27
  }
28
28
  }
@@ -35,7 +35,7 @@ exports[`<Screen Component /> when the navbar should be hidden renders correctly
35
35
  exports[`<Screen Component /> when the navbar should show renders correctly 1`] = `
36
36
  <View
37
37
  style={
38
- Object {
38
+ {
39
39
  "backgroundColor": "blue",
40
40
  "flex": 1,
41
41
  "paddingTop": 0,
@@ -54,7 +54,7 @@ exports[`<Screen Component /> when the navbar should show renders correctly 1`]
54
54
  <View
55
55
  pathname="/river/testId"
56
56
  screenData={
57
- Object {
57
+ {
58
58
  "id": "testId",
59
59
  }
60
60
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  exports[`<ScreenResolver /> renders correctly 1`] = `
4
4
  <mockConstructor
5
- screenData={Object {}}
5
+ screenData={{}}
6
6
  screenId="1234"
7
7
  screenType="screen_type_1"
8
8
  />
@@ -11,7 +11,7 @@ exports[`<ScreenResolver /> renders correctly 1`] = `
11
11
  exports[`<ScreenResolver /> wraps the player with the playerController component when the screenType is playable 1`] = `
12
12
  <HandlePlayable
13
13
  isModal={false}
14
- item={Object {}}
14
+ item={{}}
15
15
  mode="FULLSCREEN"
16
16
  />
17
17
  `;
@@ -2,42 +2,39 @@ import React from "react";
2
2
  import { View } from "react-native";
3
3
  import { shallow } from "enzyme";
4
4
  import { shallowToJson } from "enzyme-to-json";
5
- import { connect as realConnect } from "react-redux";
6
-
7
5
  const pluginConfiguration = { foo: "bar" };
8
6
 
9
7
  const ScreenType1 = jest.fn(() => <View />);
10
8
  const ScreenType2 = jest.fn(() => <View />);
9
+ const PlayerController = jest.fn(() => <View />);
11
10
 
12
- const ScreenType3 = {
11
+ const mockScreenType3 = {
13
12
  module: jest.fn(() => <View />),
14
13
  name: "ScreenType3",
15
14
  type: "screen_type_3",
16
15
  configuration: pluginConfiguration,
17
16
  };
18
17
 
19
- const ScreenType4 = {
18
+ const mockScreenType4 = {
20
19
  module: jest.fn(() => <View />),
21
20
  name: "ScreenType4",
22
21
  type: "screen_type_4",
23
22
  };
24
23
 
25
- const PlayerController = jest.fn(() => <View />);
26
-
27
- const playerPlugin = {
24
+ const mockPlayerPlugin = {
28
25
  module: jest.fn(() => <View />),
29
26
  name: "playerPlugin",
30
27
  type: "player",
31
28
  };
32
29
 
33
- const ScreenPlugin = {
30
+ const mockScreenPlugin = {
34
31
  module: jest.fn(() => <View />),
35
32
  type: "general",
36
33
  name: "Screen plugin",
37
34
  identifier: "screen-plugin",
38
35
  };
39
36
 
40
- const PluginWithConfig = {
37
+ const mockPluginWithConfig = {
41
38
  module: jest.fn(() => <View />),
42
39
  type: "general",
43
40
  name: "Plugin with config",
@@ -47,15 +44,7 @@ const PluginWithConfig = {
47
44
 
48
45
  const components = { ScreenType1, ScreenType2, PlayerController };
49
46
 
50
- const plugins = {
51
- ScreenType3,
52
- ScreenType4,
53
- playerPlugin,
54
- ScreenPlugin,
55
- PluginWithConfig,
56
- };
57
-
58
- const withAnalytics = {
47
+ const mockWithAnalytics = {
59
48
  sendOnClickEvent: jest.fn(),
60
49
  sendMenuClickEvent: jest.fn(),
61
50
  sendMenuToggleEvent: jest.fn(),
@@ -66,24 +55,39 @@ const withAnalytics = {
66
55
  sendScreenEvent: jest.fn(),
67
56
  };
68
57
 
58
+ const mockUsePickFromState = jest.fn(() => {
59
+ return {
60
+ components,
61
+ plugins: {
62
+ ScreenType3: mockScreenType3,
63
+ ScreenType4: mockScreenType4,
64
+ playerPlugin: mockPlayerPlugin,
65
+ ScreenPlugin: mockScreenPlugin,
66
+ PluginWithConfig: mockPluginWithConfig,
67
+ },
68
+ };
69
+ });
70
+
69
71
  jest.mock("@applicaster/zapp-react-native-utils/analyticsUtils", () => ({
70
- useAnalytics: jest.fn().mockReturnValue(withAnalytics),
72
+ useAnalytics: jest.fn().mockReturnValue(mockWithAnalytics),
71
73
  }));
72
74
 
73
75
  jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
74
- usePickFromState: jest.fn(() => ({ components, plugins })),
76
+ usePickFromState: mockUsePickFromState,
75
77
  }));
76
78
 
79
+ const mockUseScreenAnalytics = jest.fn();
80
+
77
81
  jest.mock(
78
82
  "@applicaster/zapp-react-native-utils/analyticsUtils/helpers/hooks",
79
83
  () => ({
80
- useScreenAnalytics: jest.fn(() => {}),
84
+ useScreenAnalytics: mockUseScreenAnalytics,
81
85
  })
82
86
  );
83
87
 
84
88
  jest.mock("react-redux", () => ({
89
+ ...jest.requireActual("react-redux"),
85
90
  useDispatch: jest.fn(() => () => {}),
86
- connect: realConnect,
87
91
  }));
88
92
 
89
93
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
@@ -118,13 +122,13 @@ describe("<ScreenResolver />", () => {
118
122
  it("picks screen from plugins if it exists", () => {
119
123
  const wrapper = getWrapper("A1234", "screen_type_3", {});
120
124
 
121
- expect(wrapper.find(ScreenType3.module)).toHaveProperty("length", 1);
125
+ expect(wrapper.find(mockScreenType3.module)).toHaveProperty("length", 1);
122
126
  });
123
127
 
124
128
  it("picks the screen from its identifier if it exists", () => {
125
129
  const wrapper = getWrapper("A1234", "screen-plugin", {});
126
130
 
127
- expect(wrapper.find(ScreenPlugin.module)).toHaveProperty("length", 1);
131
+ expect(wrapper.find(mockScreenPlugin.module)).toHaveProperty("length", 1);
128
132
  });
129
133
 
130
134
  it("picks screen from components if it doesn't exist in plugins", () => {
@@ -136,7 +140,7 @@ describe("<ScreenResolver />", () => {
136
140
  it("renders the screen and passes screenId & locationState as props", () => {
137
141
  const wrapper = getWrapper("A1234", "screen_type_3", "foo");
138
142
 
139
- const screenWrapper = wrapper.find(ScreenType3.module);
143
+ const screenWrapper = wrapper.find(mockScreenType3.module);
140
144
 
141
145
  expect(screenWrapper.prop("screenId")).toEqual("A1234");
142
146
  expect(screenWrapper.prop("screenData")).toEqual("foo");
@@ -151,7 +155,7 @@ describe("<ScreenResolver />", () => {
151
155
  it("injects the plugin configuration if it exists", () => {
152
156
  const wrapper = getWrapper("A1234", "plugin-with-config", {});
153
157
 
154
- expect(wrapper.find(PluginWithConfig.module).props()).toHaveProperty(
158
+ expect(wrapper.find(mockPluginWithConfig.module).props()).toHaveProperty(
155
159
  "configuration",
156
160
  expect.objectContaining(pluginConfiguration)
157
161
  );
@@ -160,7 +164,7 @@ describe("<ScreenResolver />", () => {
160
164
  it("injects the plugin configuration if it exists, even when plugin is resolved by type", () => {
161
165
  const wrapper = getWrapper("A1234", "screen_type_3", {});
162
166
 
163
- expect(wrapper.find(ScreenType3.module).props()).toHaveProperty(
167
+ expect(wrapper.find(mockScreenType3.module).props()).toHaveProperty(
164
168
  "configuration",
165
169
  expect.objectContaining(pluginConfiguration)
166
170
  );