@applicaster/zapp-react-native-ui-components 13.0.0-alpha.8532113155 → 13.0.0-alpha.8541129242

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 (91) hide show
  1. package/Components/AnimatedInOut/index.tsx +5 -3
  2. package/Components/AppContainer/__tests__/AppContainer.test.js +4 -6
  3. package/Components/AudioPlayer/__tests__/Runtime.test.js +5 -8
  4. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +54 -111
  5. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +36 -20
  6. package/Components/AudioPlayer/__tests__/artWork.test.js +3 -5
  7. package/Components/AudioPlayer/__tests__/audioPlayer.test.js +3 -5
  8. package/Components/AudioPlayer/__tests__/audioPlayerLayout.test.js +7 -8
  9. package/Components/AudioPlayer/__tests__/channel.test.js +3 -5
  10. package/Components/AudioPlayer/__tests__/summary.test.js +3 -5
  11. package/Components/AudioPlayer/__tests__/title.test.js +3 -5
  12. package/Components/BaseFocusable/index.tsx +1 -2
  13. package/Components/Cell/Cell.tsx +1 -0
  14. package/Components/Cell/CellWithFocusable.tsx +1 -0
  15. package/Components/Cell/TvOSCellComponent.tsx +20 -22
  16. package/Components/Cell/index.js +3 -1
  17. package/Components/CellRendererResolver/__tests__/cellRendererResolver.test.js +46 -48
  18. package/Components/ComponentResolver/__tests__/__snapshots__/componentResolver.test.js.snap +1 -42
  19. package/Components/ComponentResolver/__tests__/componentResolver.test.js +16 -22
  20. package/Components/ContentScreen/__tests__/contentScreen.test.js +3 -3
  21. package/Components/ErrorScreen/index.tsx +6 -6
  22. package/Components/Focusable/Focusable.tsx +1 -0
  23. package/Components/Focusable/FocusableTvOS.tsx +5 -1
  24. package/Components/Focusable/index.android.tsx +10 -3
  25. package/Components/FocusableGroup/FocusableTvOS.tsx +34 -83
  26. package/Components/FocusableGroup/index.tsx +1 -3
  27. package/Components/FocusableList/index.tsx +26 -9
  28. package/Components/FocusableScrollView/index.tsx +43 -13
  29. package/Components/Layout/TV/NavBarContainer.tsx +19 -23
  30. package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +3 -2
  31. package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +3 -2
  32. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -3
  33. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +2 -2
  34. package/Components/MasterCell/SharedUI/ProgressBar/hooks/useFillInPercent.ts +2 -8
  35. package/Components/MasterCell/__tests__/__snapshots__/elementMapper.test.js.snap +4 -12
  36. package/Components/MasterCell/__tests__/__snapshots__/masterCell.test.js.snap +0 -229
  37. package/Components/MasterCell/__tests__/elementMapper.test.js +18 -5
  38. package/Components/MasterCell/__tests__/masterCell.test.js +26 -26
  39. package/Components/ModalComponent/Button/index.tsx +6 -6
  40. package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +2 -2
  41. package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +2 -2
  42. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -5
  43. package/Components/PlayerContainer/PlayerContainer.tsx +8 -8
  44. package/Components/PlayerContainer/ProgramInfo/index.tsx +2 -2
  45. package/Components/PlayerImageBackground/index.tsx +23 -3
  46. package/Components/River/ComponentsMap/ComponentsMap.tsx +0 -1
  47. package/Components/River/TV/index.tsx +6 -1
  48. package/Components/River/__tests__/__snapshots__/river.test.js.snap +20 -82
  49. package/Components/River/__tests__/river.test.js +75 -40
  50. package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +11 -4
  51. package/Components/RouteManager/__tests__/routeManager.test.js +29 -14
  52. package/Components/RouteManager/__tests__/testId.test.js +8 -6
  53. package/Components/Screen/index.tsx +4 -4
  54. package/Components/ScreenResolver/__tests__/screenResolver.test.js +91 -70
  55. package/Components/Tabs/Tab.tsx +5 -3
  56. package/Components/TextInputTv/index.tsx +2 -1
  57. package/Components/Transitioner/Scene.tsx +1 -1
  58. package/Components/Transitioner/Transitioner.tsx +3 -3
  59. package/Components/Transitioner/__tests__/Scene.test.js +25 -14
  60. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +12 -68
  61. package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +2 -2
  62. package/Components/Transitioner/__tests__/transitioner.test.js +13 -4
  63. package/Components/VideoLive/PlayerLiveImageComponent.tsx +3 -3
  64. package/Components/VideoLive/animationUtils.ts +7 -4
  65. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +11 -11
  66. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +7 -7
  67. package/Components/VideoModal/PlayerDetails.tsx +9 -6
  68. package/Components/VideoModal/PlayerWrapper.tsx +2 -2
  69. package/Components/Viewport/ViewportAware/__tests__/__snapshots__/viewportAware.test.js.snap +24 -36
  70. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +12 -18
  71. package/Components/Viewport/__tests__/utils.test.js +5 -4
  72. package/Components/ZappUIComponent/Placeholder.tsx +3 -1
  73. package/Components/ZappUIComponent/__tests__/{ZappUIComponent.test.js → ZappUIComponent.test.tsx} +26 -10
  74. package/Components/ZappUIComponent/index.tsx +3 -16
  75. package/Components/default-cell-renderer/__tests__/defaultCellRenderer.test.tsx +20 -17
  76. package/Components/default-cell-renderer/viewTrees/tv/DefaultCell/__tests__/DefaultCell.test.tsx +15 -11
  77. package/Contexts/ComponentsMapOffsetContext/index.tsx +49 -0
  78. package/Decorators/Navigator/__tests__/navigator.test.js +16 -16
  79. package/Decorators/Navigator/index.tsx +1 -1
  80. package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +18 -24
  81. package/Decorators/RiverResolver/index.tsx +1 -1
  82. package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +29 -22
  83. package/package.json +7 -7
  84. package/Components/Cell/CellWithFocusable.ios.tsx +0 -126
  85. package/Components/CellRendererResolver/__tests__/__snapshots__/cellRendererResolver.test.js.snap +0 -53
  86. package/Components/RouteManager/__tests__/__snapshots__/testId.test.js.snap +0 -17
  87. package/Components/ScreenResolver/__tests__/__snapshots__/screenResolver.test.js.snap +0 -17
  88. package/Components/ZappUIComponent/__tests__/__snapshots__/ZappUIComponent.test.js.snap +0 -91
  89. package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +0 -338
  90. package/Decorators/Navigator/__tests__/__snapshots__/navigator.test.js.snap +0 -18
  91. package/Decorators/RiverResolver/__tests__/__snapshots__/riverResolver.test.tsx.snap +0 -28
@@ -1,16 +1,25 @@
1
1
  import * as React from "react";
2
2
  import { View } from "react-native";
3
- import { shallow } from "enzyme";
4
- import { shallowToJson } from "enzyme-to-json";
3
+ import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
5
4
 
6
5
  import { testCellStyle } from "./TestCellStyle";
7
6
  import { singleView } from "./SingleView";
8
7
  import { entry } from "./testEntry";
9
8
  import { singleElement } from "./testElements";
10
9
 
11
- jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
12
- useRoute: jest.fn(() => ({ screenData: { id: "test" } })),
13
- }));
10
+ jest.mock(
11
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute",
12
+ () => ({
13
+ useRoute: jest.fn(() => ({ screenData: { id: "test" } })),
14
+ })
15
+ );
16
+
17
+ jest.mock(
18
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/useIsScreenActive",
19
+ () => ({
20
+ useIsScreenActive: jest.fn(() => true),
21
+ })
22
+ );
14
23
 
15
24
  jest.mock("@applicaster/zapp-react-native-utils/screenState", () => ({
16
25
  useScreenState: jest.fn(() => ({
@@ -27,36 +36,27 @@ describe("masterCellBuilder", () => {
27
36
  describe("when using default options", () => {
28
37
  const MasterCell = masterCellBuilder({ cellConfiguration: testCellStyle });
29
38
 
30
- it("returns a function", () => {
31
- expect(MasterCell).toMatchSnapshot();
32
- });
33
-
34
39
  it("renders correctly", () => {
35
- const wrapper = shallow(
36
- <View>
40
+ const wrapper = renderWithProviders(
41
+ <View testID="master-cell">
37
42
  <MasterCell item={entry} />
38
43
  </View>
39
44
  );
40
45
 
41
- expect(shallowToJson(wrapper)).toMatchSnapshot();
42
- });
43
-
44
- it("can be invoked as a React Component", () => {
45
- const wrapper = shallow(<MasterCell item={entry} state={null} />);
46
-
47
- expect(shallowToJson(wrapper)).toMatchSnapshot();
46
+ expect(wrapper.getByTestId("master-cell").children[0]).toBeDefined();
48
47
  });
49
48
  });
50
49
 
51
- describe("when using custom containerStyle", () => {
50
+ describe.skip("when using custom containerStyle", () => {
52
51
  const MasterCell = masterCellBuilder({
53
52
  cellConfiguration: singleView,
54
53
  containerStyle: { backgroundColor: "black" },
55
54
  });
56
55
 
57
56
  it("renders correctly", () => {
58
- const renderer = shallow(<MasterCell item={entry} />);
59
- expect(shallowToJson(renderer)).toMatchSnapshot();
57
+ renderWithProviders(<MasterCell item={entry} />);
58
+
59
+ // TODO define the test need
60
60
  });
61
61
  });
62
62
 
@@ -69,14 +69,14 @@ describe("masterCellBuilder", () => {
69
69
  });
70
70
 
71
71
  it("renders correctly", () => {
72
- const renderer = shallow(<MasterCell item={entry} />);
73
- expect(shallowToJson(renderer)).toMatchSnapshot();
72
+ renderWithProviders(<MasterCell item={entry} />);
73
+ // TODO define the test need
74
74
 
75
75
  expect(dataAdapter).toHaveBeenCalledWith(singleView);
76
76
  });
77
77
  });
78
78
 
79
- describe("when using custom default components", () => {
79
+ describe.skip("when using custom default components", () => {
80
80
  // the collapsable prop is added here to easily check from the snapshot that the mock
81
81
  // component is being used instead of the default one
82
82
  const CustomView = jest.fn((props) => <View {...props} collapsable />);
@@ -88,8 +88,8 @@ describe("masterCellBuilder", () => {
88
88
  });
89
89
 
90
90
  it("renders correctly", () => {
91
- const renderer = shallow(<MasterCell item={entry} />);
92
- expect(shallowToJson(renderer)).toMatchSnapshot();
91
+ renderWithProviders(<MasterCell item={entry} />);
92
+ // TODO define the test need
93
93
  });
94
94
  });
95
95
  });
@@ -3,8 +3,8 @@ import { StyleSheet, TouchableOpacity, View } from "react-native";
3
3
  import { Item, ItemProps } from "./Item";
4
4
  import { ItemIcon, ItemIconProps } from "./ItemIcon";
5
5
  import { ItemLabel, ItemLabelProps } from "./ItemLabel";
6
- import { defaultSelectedAsset } from "./assets";
7
6
  import * as assets from "./assets";
7
+ import { defaultSelectedAsset } from "./assets";
8
8
 
9
9
  type ButtonProps = {
10
10
  configuration: any;
@@ -92,18 +92,18 @@ export function Button({
92
92
  >
93
93
  <Item {...itemProps} focused={focused} selected={selected}>
94
94
  <View style={styles.label_icon_container}>
95
- {itemIconProps.asset && itemIconProps.asset.length > 0 && (
95
+ {itemIconProps.asset && itemIconProps.asset.length > 0 ? (
96
96
  <ItemIcon {...itemIconProps} />
97
- )}
98
- {itemLabelProps.label && (
97
+ ) : null}
98
+ {itemLabelProps.label ? (
99
99
  <ItemLabel
100
100
  {...itemLabelProps}
101
101
  focused={focused}
102
102
  selected={selected}
103
103
  />
104
- )}
104
+ ) : null}
105
105
  </View>
106
- {selected && <ItemIcon {...selectedItemIconProps} />}
106
+ {selected ? <ItemIcon {...selectedItemIconProps} /> : null}
107
107
  </Item>
108
108
  </TouchableOpacity>
109
109
  </View>
@@ -90,7 +90,7 @@ export const NotificationView = (props: Props) => {
90
90
  return (
91
91
  <div onClick={onClose}>
92
92
  {children}
93
- {open && (
93
+ {open ? (
94
94
  <div style={styles.body}>
95
95
  <div style={styles.title}>
96
96
  <h2>{MSG}</h2>
@@ -98,7 +98,7 @@ export const NotificationView = (props: Props) => {
98
98
 
99
99
  <h4 style={styles.subtitle}>{EXTRA_MSG}</h4>
100
100
  </div>
101
- )}
101
+ ) : null}
102
102
  </div>
103
103
  );
104
104
  };
@@ -85,7 +85,7 @@ export const NotificationView = (props: Props) => {
85
85
  return (
86
86
  <div onClick={onClose}>
87
87
  {children}
88
- {shown && (
88
+ {shown ? (
89
89
  <div style={styles.body}>
90
90
  <div style={styles.title}>
91
91
  <h2>{title}</h2>
@@ -93,7 +93,7 @@ export const NotificationView = (props: Props) => {
93
93
 
94
94
  <h4 style={styles.subtitle}>{subtitle}</h4>
95
95
  </div>
96
- )}
96
+ ) : null}
97
97
  </div>
98
98
  );
99
99
  };
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
  import { Text, Animated } from "react-native";
3
3
 
4
- import { shallow } from "enzyme";
5
4
  import renderer from "react-test-renderer";
6
5
 
7
6
  jest.useFakeTimers();
@@ -40,10 +39,6 @@ const {
40
39
  } = require("../NotificationView");
41
40
 
42
41
  describe("NotificationView", () => {
43
- it("renders", () => {
44
- shallow(<NotificationView dismiss={dismiss} />);
45
- });
46
-
47
42
  it("Show online message when Online", () => {
48
43
  const component = renderer.create(
49
44
  <NotificationView online dismiss={dismiss} />
@@ -1,17 +1,17 @@
1
1
  import * as React from "react";
2
+ import { useEffect, useReducer } from "react";
2
3
  // @ts-ignore
3
- import { View, ViewStyle, TVMenuControl } from "react-native";
4
+ import { TVMenuControl, View, ViewStyle } from "react-native";
4
5
  import * as R from "ramda";
5
6
  import uuid from "uuid/v4";
6
7
  import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils/playerManager";
7
8
  import {
8
9
  isApplePlatform,
9
- platformSelect,
10
10
  isTV,
11
+ platformSelect,
11
12
  } from "@applicaster/zapp-react-native-utils/reactUtils";
12
13
 
13
14
  import { TVEventHandlerComponent } from "@applicaster/zapp-react-native-tvos-ui-components/Components/TVEventHandlerComponent";
14
- import { useEffect, useReducer } from "react";
15
15
  import { usePrevious } from "@applicaster/zapp-react-native-utils/reactHooks/utils";
16
16
  import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
17
17
  import {
@@ -29,10 +29,10 @@ import {
29
29
  import { ProgramInfo } from "./ProgramInfo";
30
30
  import { AudioPlayer } from "../AudioPlayer";
31
31
  import {
32
- playerContainerLogger,
33
32
  log_debug,
34
33
  log_info,
35
34
  log_warning,
35
+ playerContainerLogger,
36
36
  } from "./logger";
37
37
  import { usePlayer } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayer";
38
38
  import { useSetNavbarState } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
@@ -53,8 +53,8 @@ import { usePlayNextOverlay } from "@applicaster/zapp-react-native-utils/appUtil
53
53
  import { PlayNextState } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/OverlayObserver/OverlaysObserver";
54
54
 
55
55
  import {
56
- useModalAnimationContext,
57
56
  PlayerAnimationStateEnum,
57
+ useModalAnimationContext,
58
58
  } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
59
59
 
60
60
  type Props = {
@@ -683,10 +683,10 @@ const PlayerContainerComponent = (props: Props) => {
683
683
 
684
684
  {renderRestPlayers(restPlayerProps)}
685
685
 
686
- {state.error && <ErrorDisplay error={state.error} />}
686
+ {state.error ? <ErrorDisplay error={state.error} /> : null}
687
687
  </View>
688
688
  {/* Components container */}
689
- {isInlineTV && context.showComponentsContainer && (
689
+ {isInlineTV && context.showComponentsContainer ? (
690
690
  <View
691
691
  style={styles.inlineRiver}
692
692
  testID={"inline-river-component-wrapper"}
@@ -717,7 +717,7 @@ const PlayerContainerComponent = (props: Props) => {
717
717
  )}
718
718
  </ComponentFocusableWrapperView>
719
719
  </View>
720
- )}
720
+ ) : null}
721
721
  </View>
722
722
  </FocusableGroup>
723
723
  </TVEventHandlerComponent>
@@ -114,12 +114,12 @@ function ProgramInfoComponent({
114
114
  return (
115
115
  <View style={container}>
116
116
  <View style={programStyles.programInfo.container}>
117
- {logo && (
117
+ {logo ? (
118
118
  <Image
119
119
  source={{ uri: logo }}
120
120
  style={programStyles.programInfo.logo}
121
121
  />
122
- )}
122
+ ) : null}
123
123
  {!isAudioContent && transportInfo}
124
124
  </View>
125
125
  </View>
@@ -1,4 +1,4 @@
1
- import React, { PropsWithChildren } from "react";
1
+ import React, { PropsWithChildren, useEffect, useState } from "react";
2
2
  import { ImageBackground, View } from "react-native";
3
3
 
4
4
  import { imageSrcFromMediaItem } from "@applicaster/zapp-react-native-utils/configurationUtils";
@@ -12,6 +12,7 @@ import {
12
12
  type Props = PropsWithChildren<{
13
13
  entry: ZappEntry;
14
14
  style?: { [K: string]: any };
15
+ docked?: boolean;
15
16
  imageStyle?: { [K: string]: any };
16
17
  imageKey?: string;
17
18
  defaultImageDimensions?: { [K: string]: any };
@@ -23,6 +24,7 @@ const PlayerImageBackgroundComponent = ({
23
24
  entry,
24
25
  children,
25
26
  style,
27
+ docked,
26
28
  imageStyle,
27
29
  imageKey,
28
30
  defaultImageDimensions,
@@ -34,8 +36,22 @@ const PlayerImageBackgroundComponent = ({
34
36
 
35
37
  const { playerAnimationState } = useModalAnimationContext();
36
38
 
39
+ const [lastNonNullAnimationState, setLastNonNullAnimationState] =
40
+ useState(playerAnimationState);
41
+
42
+ useEffect(() => {
43
+ if (playerAnimationState !== null) {
44
+ setLastNonNullAnimationState(playerAnimationState);
45
+ }
46
+ }, [playerAnimationState]);
47
+
37
48
  if (!source) return <>{children}</>;
38
49
 
50
+ const imageBackgroundStyle =
51
+ lastNonNullAnimationState !== PlayerAnimationStateEnum.minimize && !docked
52
+ ? defaultImageDimensions
53
+ : imageSize;
54
+
39
55
  return (
40
56
  <View
41
57
  style={
@@ -45,13 +61,17 @@ const PlayerImageBackgroundComponent = ({
45
61
  }
46
62
  >
47
63
  <AnimationComponent
48
- style={style}
64
+ style={
65
+ playerAnimationState === PlayerAnimationStateEnum.maximaze
66
+ ? defaultImageDimensions
67
+ : style
68
+ }
49
69
  animationType={ComponentAnimationType.player}
50
70
  additionalData={defaultImageDimensions}
51
71
  >
52
72
  <ImageBackground
53
73
  resizeMode="cover"
54
- style={imageSize}
74
+ style={imageBackgroundStyle}
55
75
  imageStyle={imageStyle}
56
76
  source={source}
57
77
  >
@@ -279,7 +279,6 @@ function ComponentsMapComponent(props: Props) {
279
279
  initialNumToRender={3}
280
280
  maxToRenderPerBatch={10}
281
281
  windowSize={12}
282
- listKey={riverId}
283
282
  keyExtractor={keyExtractor}
284
283
  renderItem={renderRiverItem}
285
284
  data={riverComponents}
@@ -1,4 +1,9 @@
1
+ import { compose } from "ramda";
1
2
  import { River as RiverComponent } from "./River";
2
3
  import { withTvEventHandler } from "./withTVEventHandler";
4
+ import { withComponentsMapOffsetContext } from "../../../Contexts/ComponentsMapOffsetContext";
3
5
 
4
- export const River = withTvEventHandler(RiverComponent);
6
+ export const River = compose(
7
+ withTvEventHandler,
8
+ withComponentsMapOffsetContext
9
+ )(RiverComponent);
@@ -1,89 +1,27 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`When River has a general_content type <River /> renders correctly 1`] = `
4
- <ContextProvider
5
- value={null}
6
- >
7
- <RiverWithData
8
- appData={
9
- {
10
- "layoutVersion": "v1",
11
- }
12
- }
13
- dispatch={[Function]}
14
- rivers={
15
- {
16
- "A1234": {
17
- "home": true,
18
- "id": "A1234",
19
- "name": "foo",
20
- "type": "general_content",
21
- "ui_components": [
22
- {
23
- "component_type": "hero",
24
- },
25
- {
26
- "component_type": "grid",
27
- },
28
- ],
29
- },
30
- "B4567": {
31
- "id": "B4567",
32
- },
33
- "C0987": {
34
- "home": false,
35
- "id": "C0987",
36
- "name": "Some-Screen-Plugin",
37
- "type": "some-screen-plugin",
38
- "ui_components": [],
39
- },
40
- }
41
- }
42
- screenId="A1234"
43
- store={
44
- {
45
- "clearActions": [Function],
46
- "dispatch": [Function],
47
- "getActions": [Function],
48
- "getState": [Function],
49
- "replaceReducer": [Function],
50
- "subscribe": [Function],
51
- }
52
- }
53
- />
54
- </ContextProvider>
55
- `;
56
-
57
- exports[`When River has a general_content type <RiverComponent /> renders correctly 1`] = `
58
- <GeneralContentScreen
59
- groupId="ZF-C4"
60
- screenId="A1234"
61
- />
62
- `;
63
-
64
- exports[`When River has any other type other than general_content <RiverComponent /> renders correctly 1`] = `
65
- <WithProvider
66
- screenData={
3
+ exports[`When River has a general_content type renders River component correctly 1`] = `
4
+ <View
5
+ onLayout={[Function]}
6
+ style={
67
7
  {
68
- "groupId": undefined,
69
- "home": false,
70
- "id": "C0987",
71
- "name": "Some-Screen-Plugin",
72
- "type": "some-screen-plugin",
73
- "ui_components": [],
8
+ "flex": 1,
74
9
  }
75
10
  }
76
- screenId="C0987"
77
- screenType="some-screen-plugin"
78
- />
79
- `;
80
-
81
- exports[`When River has feed url <RiverComponent /> renders correctly 1`] = `
82
- <Connect(FeedLoaderComponent)
83
- feedUrl="https://some-feed-url.net"
84
- refreshCallback={[Function]}
85
- refreshing={false}
11
+ testID="on-layout-view"
86
12
  >
87
- <Component />
88
- </Connect(FeedLoaderComponent)>
13
+ <View
14
+ style={
15
+ {
16
+ "display": "none",
17
+ "flex": 1,
18
+ }
19
+ }
20
+ >
21
+ <View
22
+ screenId="A1234"
23
+ testID="general-content-screen"
24
+ />
25
+ </View>
26
+ </View>
89
27
  `;
@@ -1,13 +1,50 @@
1
1
  import React from "react";
2
- import { shallow } from "enzyme";
3
- import { shallowToJson } from "enzyme-to-json";
2
+ import { render, screen } from "@testing-library/react-native";
4
3
  import configureStore from "redux-mock-store";
4
+ import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
5
+ import { Provider } from "react-redux";
5
6
 
6
- import { GeneralContentScreen } from "../../GeneralContentScreen";
7
- import { FeedLoader } from "../../FeedLoader";
8
- import { River } from "../index";
9
- import { RiverComponent } from "../River";
7
+ import { River } from "../";
10
8
  import { ScreenResolver } from "../../ScreenResolver";
9
+ import { RiverComponent } from "../River";
10
+
11
+ jest.mock(
12
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/useIsScreenActive",
13
+ () => ({
14
+ useIsScreenActive: jest.fn(() => true),
15
+ })
16
+ );
17
+
18
+ jest.mock(
19
+ "@applicaster/zapp-react-native-ui-components/Components/GeneralContentScreen",
20
+ () => {
21
+ const { View } = jest.requireActual("react-native");
22
+
23
+ return {
24
+ GeneralContentScreen: (props) => (
25
+ <View testID="general-content-screen" {...props} />
26
+ ),
27
+ };
28
+ }
29
+ );
30
+
31
+ jest.mock(
32
+ "@applicaster/zapp-react-native-utils/analyticsUtils/helpers/hooks",
33
+ () => ({
34
+ useScreenAnalytics: jest.fn(),
35
+ })
36
+ );
37
+
38
+ jest.mock(
39
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation",
40
+ () => ({
41
+ useNavigation: jest.fn(() => ({
42
+ videoModalState: {
43
+ mode: "test",
44
+ },
45
+ })),
46
+ })
47
+ );
11
48
 
12
49
  const river = {
13
50
  home: true,
@@ -55,24 +92,24 @@ const appData = { layoutVersion: "v1" };
55
92
  const store = configureStore()({ rivers, appData });
56
93
 
57
94
  describe("When River has a general_content type", () => {
58
- const wrapper = shallow(<RiverComponent {...riverProps} />);
59
-
60
- describe("<RiverComponent />", () => {
61
- it("renders correctly", () => {
62
- expect(shallowToJson(wrapper)).toMatchSnapshot();
63
- });
64
-
65
- it("it returns a GeneralContentScreen", () => {
66
- expect(wrapper.find(GeneralContentScreen).length).toBe(1);
67
- });
95
+ it("renders GeneralContentScreen correctly", () => {
96
+ const { getByTestId } = render(
97
+ <Provider store={store}>
98
+ <RiverComponent {...riverProps} />
99
+ </Provider>
100
+ );
101
+
102
+ expect(getByTestId("general-content-screen")).toBeTruthy();
68
103
  });
69
104
 
70
- describe("<River />", () => {
71
- const wrapper = shallow(<River screenId="A1234" store={store} />);
105
+ it("renders River component correctly", () => {
106
+ const wrapper = render(
107
+ <Provider store={store}>
108
+ <River screenId="A1234" />
109
+ </Provider>
110
+ );
72
111
 
73
- it("renders correctly", () => {
74
- expect(shallowToJson(wrapper)).toMatchSnapshot();
75
- });
112
+ expect(wrapper.toJSON()).toMatchSnapshot();
76
113
  });
77
114
  });
78
115
 
@@ -83,16 +120,10 @@ describe("When River has any other type other than general_content", () => {
83
120
  appData,
84
121
  };
85
122
 
86
- const wrapper = shallow(<RiverComponent {...riverPropsWithScreenPlugin} />);
87
-
88
- describe("<RiverComponent />", () => {
89
- it("renders correctly", () => {
90
- expect(shallowToJson(wrapper)).toMatchSnapshot();
91
- });
123
+ it("renders ScreenResolver correctly", () => {
124
+ renderWithProviders(<RiverComponent {...riverPropsWithScreenPlugin} />);
92
125
 
93
- it("it returns a ScreenResolver", () => {
94
- expect(wrapper.find(ScreenResolver).length).toBe(1);
95
- });
126
+ expect(screen.UNSAFE_getByType(ScreenResolver)).toBeDefined();
96
127
  });
97
128
  });
98
129
 
@@ -104,15 +135,19 @@ describe("When River has feed url", () => {
104
135
  appData: { layoutVersion: "v1" },
105
136
  };
106
137
 
107
- const wrapper = shallow(<RiverComponent {...riverPropsWithFeedUrl} />);
108
-
109
- describe("<RiverComponent />", () => {
110
- it("renders correctly", () => {
111
- expect(shallowToJson(wrapper)).toMatchSnapshot();
112
- });
113
-
114
- it("it returns a FeedLoader if it's a v1 layout", () => {
115
- expect(wrapper.find(FeedLoader).length).toBe(1);
116
- });
138
+ it("renders FeedLoader when layout is v1", () => {
139
+ const wrapper = renderWithProviders(
140
+ <RiverComponent {...riverPropsWithFeedUrl} />,
141
+ {
142
+ zappPipes: {
143
+ "https://some-feed-url.net": {
144
+ loading: false,
145
+ data: { entry: [] },
146
+ },
147
+ },
148
+ }
149
+ );
150
+
151
+ expect(wrapper.getByTestId("general-content-screen")).toBeDefined();
117
152
  });
118
153
  });
@@ -1,10 +1,16 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`<RouteManager /> renders correctly 1`] = `
4
- <TestId
5
- screenId="A1234"
4
+ <View
5
+ accessibilityLabel="A1234"
6
+ style={
7
+ {
8
+ "flex": 1,
9
+ }
10
+ }
11
+ testID="A1234"
6
12
  >
7
- <WithProvider
13
+ <View
8
14
  pathname="/river/A1234"
9
15
  screenData={
10
16
  {
@@ -13,6 +19,7 @@ exports[`<RouteManager /> renders correctly 1`] = `
13
19
  }
14
20
  screenId="A1234"
15
21
  screenType="river"
22
+ testID="screen-resolver"
16
23
  />
17
- </TestId>
24
+ </View>
18
25
  `;