@quintype/native-components 2.22.5-beta.0 → 2.22.5

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 (45) hide show
  1. package/bin-dev-scripts/standard-version-release.sh +11 -11
  2. package/package.json +1 -1
  3. package/src/components/AlsoRead/index.js +4 -4
  4. package/src/components/AuthorRow/index.js +3 -3
  5. package/src/components/BackNavigator/index.js +6 -6
  6. package/src/components/Button/index.js +1 -1
  7. package/src/components/CollectionCard/index.js +10 -20
  8. package/src/components/CollectionCardNew/index.js +84 -0
  9. package/src/components/CollectionTitle/CollectionTitle.test.js +12 -0
  10. package/src/components/CollectionTitle/__snapshots__/CollectionTitle.test.js.snap +3 -0
  11. package/src/components/CollectionTitle/index.js +38 -19
  12. package/src/components/CollectionTitle/styles.js +13 -11
  13. package/src/components/CollectionTitleNew/index.js +44 -0
  14. package/src/components/CollectionTitleNew/styles.js +20 -0
  15. package/src/components/CustomSwitch/index.js +4 -4
  16. package/src/components/DailyMotionPlayer/index.js +2 -2
  17. package/src/components/Header/index.js +2 -2
  18. package/src/components/Html/index.js +4 -4
  19. package/src/components/IconText/index.js +4 -4
  20. package/src/components/JSEmbedElement/index.js +3 -3
  21. package/src/components/LightBoxImage/index.js +2 -2
  22. package/src/components/PDFReader/index.js +8 -7
  23. package/src/components/PrimaryStoryCard/PrimaryStoryCard.test.js +43 -0
  24. package/src/components/PrimaryStoryCard/index.js +63 -44
  25. package/src/components/PrimaryStoryCard/styles.js +28 -32
  26. package/src/components/PrimaryStoryCardNew/index.js +134 -0
  27. package/src/components/PrimaryStoryCardNew/styles.js +70 -0
  28. package/src/components/RadioButton/index.js +3 -3
  29. package/src/components/Rating/index.js +1 -1
  30. package/src/components/RelatedStoriesCard/index.js +12 -2
  31. package/src/components/SecondaryStoryCard/SecondaryStoryCard.test.js +51 -0
  32. package/src/components/SecondaryStoryCard/index.js +62 -37
  33. package/src/components/SecondaryStoryCard/styles.js +34 -37
  34. package/src/components/SecondaryStoryCardNew/index.js +140 -0
  35. package/src/components/SecondaryStoryCardNew/styles.js +82 -0
  36. package/src/components/Story/index.js +13 -12
  37. package/src/components/StoryHeader/index.js +8 -8
  38. package/src/components/StoryText/index.js +2 -5
  39. package/src/components/Text/index.js +1 -3
  40. package/src/components/TextA/index.js +4 -4
  41. package/src/components/TextBigFact/index.js +4 -4
  42. package/src/components/TextBlockQuote/index.js +5 -5
  43. package/src/components/TextBlurb/index.js +3 -3
  44. package/src/components/TextQandA/index.js +3 -2
  45. package/src/components/index.js +4 -0
@@ -1,15 +1,15 @@
1
- #!/bin/bash -e
1
+ # #!/bin/bash -e
2
2
 
3
- npm install
4
- git diff --quiet
3
+ # npm install
4
+ # git diff --quiet
5
5
 
6
- BRANCH=$(git symbolic-ref --short HEAD)
6
+ # BRANCH=$(git symbolic-ref --short HEAD)
7
7
 
8
- if [ "$BRANCH" == 'master' ]
9
- then
10
- npx standard-version
11
- else
12
- npx standard-version --prerelease "$(git symbolic-ref --short HEAD | sed s:/:-:g )" --skip.changelog=true
13
- fi
8
+ # if [ "$BRANCH" == 'master' ]
9
+ # then
10
+ # npx standard-version
11
+ # else
12
+ # npx standard-version --prerelease "$(git symbolic-ref --short HEAD | sed s:/:-:g )" --skip.changelog=true
13
+ # fi
14
14
 
15
- git push --follow-tags origin "$BRANCH"
15
+ # git push --follow-tags origin "$BRANCH"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/native-components",
3
- "version": "2.22.5-beta.0",
3
+ "version": "2.22.5",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,10 +1,10 @@
1
- import get from 'lodash/get';
2
1
  import React, { useContext } from 'react';
3
- import { TouchableOpacity, View } from 'react-native';
4
- import { FallbackIcon } from '../../Icons/FallBackIcon';
5
- import { AppTheme } from '../../utils';
2
+ import get from 'lodash/get';
3
+ import { View, TouchableOpacity } from 'react-native';
6
4
  import { ResponsiveImage, Text } from '../index';
7
5
  import { alsoReadStyles } from './styles';
6
+ import { FallbackIcon } from '../../Icons/FallBackIcon';
7
+ import { AppTheme } from '../../utils';
8
8
 
9
9
  export const AlsoRead = (props) => {
10
10
  const {
@@ -2,12 +2,12 @@ import PropTypes from 'prop-types';
2
2
  import React, { useContext } from 'react';
3
3
  import { View } from 'react-native';
4
4
  import Icon from 'react-native-vector-icons/FontAwesome';
5
- import { ActionText } from '../ActionText/ActionText';
6
5
  import { ResponsiveImage, Text } from '../index';
6
+ import { ActionText } from '../ActionText/ActionText';
7
7
 
8
- import { COMP_CONTENT_CONSTANTS } from '../../constants/component-constants/content-constants/constants';
9
- import { AppTheme } from '../../utils';
10
8
  import { authorRowStyleSheet } from './styles';
9
+ import { AppTheme } from '../../utils';
10
+ import { COMP_CONTENT_CONSTANTS } from '../../constants/component-constants/content-constants/constants';
11
11
 
12
12
  export const AuthorRow = ({
13
13
  authors,
@@ -1,18 +1,18 @@
1
- import PropTypes from 'prop-types';
2
1
  import React, { useContext } from 'react';
3
2
  import {
4
- I18nManager,
5
- StyleSheet,
6
- TouchableOpacity,
7
3
  View,
4
+ StyleSheet,
8
5
  ViewPropTypes,
6
+ TouchableOpacity,
7
+ I18nManager,
9
8
  } from 'react-native';
10
9
  import Icon from 'react-native-vector-icons/AntDesign';
11
- import { COMP_GENERAL_CONSTANTS } from '../../constants/component-constants/general-constants/constants';
10
+ import PropTypes from 'prop-types';
12
11
  import { AppTheme } from '../../utils/context';
12
+ import { COMP_GENERAL_CONSTANTS } from '../../constants/component-constants/general-constants/constants';
13
13
 
14
- import { Text } from '../Text';
15
14
  import { backNavigatorStyles } from './styles';
15
+ import { Text } from '../Text';
16
16
 
17
17
  export const BackNavigator = (props) => {
18
18
  const { theme } = useContext(AppTheme);
@@ -6,10 +6,10 @@ import {
6
6
  View,
7
7
  ViewPropTypes,
8
8
  } from "react-native";
9
- import { COMP_GENERAL_CONSTANTS } from "../../constants/component-constants/general-constants/constants";
10
9
  import { AppTheme } from "../../utils";
11
10
  import { Text } from "../Text";
12
11
  import { styles } from "./styles";
12
+ import { COMP_GENERAL_CONSTANTS } from "../../constants/component-constants/general-constants/constants";
13
13
 
14
14
  export const Button = (props) => {
15
15
  const { icon, text, onPress } = props;
@@ -1,22 +1,20 @@
1
1
  import get from 'lodash/get';
2
2
  import isEmpty from 'lodash/isEmpty';
3
3
  import PropTypes from 'prop-types';
4
- import React, { memo } from 'react';
4
+ import React from 'react';
5
5
  import { getScreenPercentageWidth } from '../../utils/index';
6
6
  import {
7
7
  CollectionTitle,
8
8
  PrimaryStoryCard,
9
9
  SecondaryStoryCard,
10
- ShareButton,
11
10
  } from '../index';
12
11
 
13
- const CollectionCardBase = ({
12
+ export const CollectionCard = ({
14
13
  cdn,
15
14
  collectionName,
16
15
  stories,
17
16
  onCollectionPress,
18
17
  onStoryPress,
19
- collectionTestID,
20
18
  offset,
21
19
  horizontalPadding,
22
20
  initialOffset, /* Number of items to load on first load */
@@ -24,10 +22,10 @@ const CollectionCardBase = ({
24
22
  }) => {
25
23
  const sliceLimit = offset || initialOffset || 5;
26
24
  const primaryStory = !isEmpty(stories) && get(stories, [0, 'story'], stories[0]);
27
-
28
25
  return (
29
26
  <>
30
- {!hideCollectionTitle && (
27
+ {!hideCollectionTitle
28
+ && (
31
29
  <CollectionTitle
32
30
  title={collectionName}
33
31
  onPress={onCollectionPress}
@@ -35,13 +33,11 @@ const CollectionCardBase = ({
35
33
  />
36
34
  )}
37
35
  <PrimaryStoryCard
38
- collectionTestID={collectionTestID}
39
36
  onPress={() => {
40
37
  !isEmpty(stories) && onStoryPress(primaryStory);
41
38
  }}
42
39
  cdn={cdn}
43
40
  story={!isEmpty(stories) ? primaryStory : {}}
44
- iconComponent={<ShareButton story={primaryStory} inListingStoryCard />}
45
41
  imageWidth={getScreenPercentageWidth(100) - 2 * horizontalPadding}
46
42
  horizontalPadding={horizontalPadding}
47
43
  />
@@ -49,13 +45,11 @@ const CollectionCardBase = ({
49
45
  const secondaryStory = get(currentStory, ['story'], currentStory);
50
46
  return (
51
47
  <SecondaryStoryCard
52
- collectionTestID={collectionTestID}
53
48
  onPress={() => onStoryPress(secondaryStory)}
54
- key={secondaryStory?.id}
49
+ key={`${secondaryStory?.id}`}
55
50
  cdn={cdn}
56
51
  story={secondaryStory}
57
- iconComponent={<ShareButton story={secondaryStory} inListingStoryCard />}
58
- imageWidth={getScreenPercentageWidth(28)}
52
+ imageWidth={getScreenPercentageWidth(40)}
59
53
  horizontalPadding={horizontalPadding}
60
54
  />
61
55
  );
@@ -63,22 +57,18 @@ const CollectionCardBase = ({
63
57
  </>
64
58
  );
65
59
  };
66
-
67
- CollectionCardBase.propTypes = {
68
- offset: PropTypes.number,
60
+ CollectionCard.propTypes = {
69
61
  initialOffset: PropTypes.number,
70
62
  cdn: PropTypes.string.isRequired,
71
- collectionName: PropTypes.string,
63
+ collectionName: PropTypes.string.isRequired,
72
64
  stories: PropTypes.array.isRequired,
73
65
  onCollectionPress: PropTypes.func,
74
66
  onStoryPress: PropTypes.func,
75
- collectionTestID: PropTypes.string,
67
+ offset: PropTypes.number,
76
68
  horizontalPadding: PropTypes.number,
77
69
  hideCollectionTitle: PropTypes.bool,
78
70
  };
79
71
 
80
- CollectionCardBase.defaultProps = {
72
+ CollectionCard.defaultProps = {
81
73
  horizontalPadding: 12,
82
74
  };
83
-
84
- export const CollectionCard = memo(CollectionCardBase);
@@ -0,0 +1,84 @@
1
+ import get from 'lodash/get';
2
+ import isEmpty from 'lodash/isEmpty';
3
+ import PropTypes from 'prop-types';
4
+ import React, { memo } from 'react';
5
+ import { getScreenPercentageWidth } from '../../utils/index';
6
+ import {
7
+ CollectionTitleNew,
8
+ PrimaryStoryCardNew,
9
+ SecondaryStoryCardNew,
10
+ ShareButton,
11
+ } from '../index';
12
+
13
+ const CollectionCardNewBase = ({
14
+ cdn,
15
+ collectionName,
16
+ stories,
17
+ onCollectionPress,
18
+ onStoryPress,
19
+ collectionTestID,
20
+ offset,
21
+ horizontalPadding,
22
+ initialOffset, /* Number of items to load on first load */
23
+ hideCollectionTitle,
24
+ }) => {
25
+ const sliceLimit = offset || initialOffset || 5;
26
+ const primaryStory = !isEmpty(stories) && get(stories, [0, 'story'], stories[0]);
27
+
28
+ return (
29
+ <>
30
+ {!hideCollectionTitle && (
31
+ <CollectionTitleNew
32
+ title={collectionName}
33
+ onPress={onCollectionPress}
34
+ horizontalPadding={horizontalPadding}
35
+ />
36
+ )}
37
+ <PrimaryStoryCardNew
38
+ collectionTestID={collectionTestID}
39
+ onPress={() => {
40
+ !isEmpty(stories) && onStoryPress(primaryStory);
41
+ }}
42
+ cdn={cdn}
43
+ story={!isEmpty(stories) ? primaryStory : {}}
44
+ iconComponent={<ShareButton story={primaryStory} inListingStoryCard />}
45
+ imageWidth={getScreenPercentageWidth(100) - 2 * horizontalPadding}
46
+ horizontalPadding={horizontalPadding}
47
+ />
48
+ {stories.slice(1, sliceLimit).map((currentStory) => {
49
+ const secondaryStory = get(currentStory, ['story'], currentStory);
50
+ return (
51
+ <SecondaryStoryCardNew
52
+ collectionTestID={collectionTestID}
53
+ onPress={() => onStoryPress(secondaryStory)}
54
+ key={secondaryStory?.id}
55
+ cdn={cdn}
56
+ story={secondaryStory}
57
+ iconComponent={<ShareButton story={secondaryStory} inListingStoryCard />}
58
+ imageWidth={getScreenPercentageWidth(28)}
59
+ horizontalPadding={horizontalPadding}
60
+ />
61
+ );
62
+ })}
63
+ </>
64
+ );
65
+ };
66
+
67
+ CollectionCardNewBase.propTypes = {
68
+ offset: PropTypes.number,
69
+ initialOffset: PropTypes.number,
70
+ cdn: PropTypes.string.isRequired,
71
+ collectionName: PropTypes.string,
72
+ stories: PropTypes.array.isRequired,
73
+ onCollectionPress: PropTypes.func,
74
+ onStoryPress: PropTypes.func,
75
+ collectionTestID: PropTypes.string,
76
+ horizontalPadding: PropTypes.number,
77
+ hideCollectionTitle: PropTypes.bool,
78
+ };
79
+
80
+ CollectionCardNewBase.defaultProps = {
81
+ horizontalPadding: 12,
82
+ };
83
+
84
+ export const CollectionCardNew = memo(CollectionCardNewBase);
@@ -0,0 +1,12 @@
1
+ import 'react-native';
2
+ import React from 'react';
3
+ import renderer from 'react-test-renderer';
4
+
5
+ import { CollectionTitle } from './index';
6
+ import { mockContext } from '../../utils';
7
+
8
+ test('renders correctly', () => {
9
+ const component = mockContext(<CollectionTitle />);
10
+ const tree = renderer.create(component).toJSON();
11
+ expect(tree).toMatchSnapshot();
12
+ });
@@ -0,0 +1,3 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`renders correctly 1`] = `null`;
@@ -1,42 +1,61 @@
1
1
  import PropTypes from 'prop-types';
2
- import React, { memo, useContext } from 'react';
2
+ import React, { useContext } from 'react';
3
3
  import {
4
+ TextStyle,
5
+ TouchableOpacity,
6
+ TouchableOpacityProps,
7
+ View,
8
+ ViewStyle,
4
9
  StyleSheet,
5
- TouchableOpacity
6
10
  } from 'react-native';
7
- import { AppTheme } from '../../utils';
11
+
8
12
  import { Text } from '../index';
9
- import { collectionTitleStyles } from './styles';
10
13
 
11
- const CollectionTitleBase = (props) => {
14
+ import { collectionStyles } from './styles';
15
+ import { AppTheme } from '../../utils';
16
+ import { COMP_GENERAL_CONSTANTS } from '../../constants/component-constants/general-constants/constants';
17
+
18
+ export const CollectionTitle = (props) => {
12
19
  const { theme } = useContext(AppTheme);
13
- const styles = collectionTitleStyles(theme);
20
+ const styles = collectionStyles(theme);
14
21
  const containerStyle = StyleSheet.flatten([
15
- styles.container,
22
+ styles.titleContainer,
16
23
  { paddingHorizontal: props.horizontalPadding },
17
24
  ]);
18
- const titleStyle = StyleSheet.flatten([styles.title, props.titleStyle]);
25
+ const titleStyle = StyleSheet.flatten([styles.titleStyle, props.titleStyle]);
26
+ const indicatorStyle = StyleSheet.flatten([
27
+ styles.indicatorStyle,
28
+ props.indicatorStyle,
29
+ ]);
19
30
 
20
31
  if (!props.title) {
21
32
  return null;
22
33
  }
23
34
 
24
35
  return (
25
- <TouchableOpacity style={containerStyle} onPress={props.onPress}>
26
- <Text style={titleStyle}>{props.title}</Text>
36
+ <TouchableOpacity
37
+ style={containerStyle}
38
+ onPress={props.onPress}
39
+ testID={COMP_GENERAL_CONSTANTS.collectionTitleTouch}
40
+ >
41
+ <Text
42
+ style={titleStyle}
43
+ testID={COMP_GENERAL_CONSTANTS.collectionTitleText}
44
+ >
45
+ {props.title}
46
+ </Text>
47
+ <View style={indicatorStyle} />
27
48
  </TouchableOpacity>
28
49
  );
29
50
  };
30
51
 
31
- CollectionTitleBase.propTypes = TouchableOpacityProps
32
- && {
33
- title: PropTypes.string,
34
- titleStyle: TextStyle,
35
- horizontalPadding: PropTypes.number,
36
- };
52
+ CollectionTitle.propTypes = TouchableOpacityProps && {
53
+ title: PropTypes.string,
54
+ titleStyle: TextStyle,
55
+ indicatorStyle: ViewStyle,
56
+ horizontalPadding: PropTypes.number,
57
+ };
37
58
 
38
- CollectionTitleBase.defaultProps = {
59
+ CollectionTitle.defaultProps = {
39
60
  horizontalPadding: 12,
40
61
  };
41
-
42
- export const CollectionTitle = memo(CollectionTitleBase);
@@ -1,20 +1,22 @@
1
1
  import { StyleSheet } from 'react-native';
2
2
 
3
- export const collectionTitleStyles = (appThemeContext) => {
4
- const { COLORS, FONT_SIZE, FONT_FAMILY } = appThemeContext;
5
-
3
+ export const collectionStyles = (appThemeContext) => {
4
+ const { COLORS, FONT_SIZE } = appThemeContext;
6
5
  return StyleSheet.create({
7
- container: {
8
- justifyContent: 'center',
6
+ titleContainer: {
9
7
  backgroundColor: COLORS.BRAND_WHITE,
10
- paddingHorizontal: 12,
11
- paddingVertical: 8,
12
- marginTop: 8,
8
+ paddingVertical: 12,
9
+ justifyContent: 'center',
13
10
  },
14
- title: {
15
- fontSize: FONT_SIZE.h3,
16
- fontFamily: FONT_FAMILY.secondaryBold,
11
+ titleStyle: {
12
+ fontSize: FONT_SIZE.h1,
17
13
  color: COLORS.BRAND_5,
18
14
  },
15
+ indicatorStyle: {
16
+ marginTop: 8,
17
+ width: 30,
18
+ height: 3,
19
+ backgroundColor: COLORS.BRAND_1,
20
+ },
19
21
  });
20
22
  };
@@ -0,0 +1,44 @@
1
+ import PropTypes from 'prop-types';
2
+ import React, { useContext, memo } from 'react';
3
+ import {
4
+ TextStyle,
5
+ TouchableOpacity,
6
+ TouchableOpacityProps,
7
+ StyleSheet,
8
+ } from 'react-native';
9
+ import { Text } from '../index';
10
+ import { collectionTitleStyles } from './styles';
11
+ import { AppTheme } from '../../utils';
12
+
13
+ const CollectionTitleNewBase = (props) => {
14
+ const { theme } = useContext(AppTheme);
15
+ const styles = collectionTitleStyles(theme);
16
+ const containerStyle = StyleSheet.flatten([
17
+ styles.container,
18
+ { paddingHorizontal: props.horizontalPadding },
19
+ ]);
20
+ const titleStyle = StyleSheet.flatten([styles.title, props.titleStyle]);
21
+
22
+ if (!props.title) {
23
+ return null;
24
+ }
25
+
26
+ return (
27
+ <TouchableOpacity style={containerStyle} onPress={props.onPress}>
28
+ <Text style={titleStyle}>{props.title}</Text>
29
+ </TouchableOpacity>
30
+ );
31
+ };
32
+
33
+ CollectionTitleNewBase.propTypes = TouchableOpacityProps
34
+ && {
35
+ title: PropTypes.string,
36
+ titleStyle: TextStyle,
37
+ horizontalPadding: PropTypes.number,
38
+ };
39
+
40
+ CollectionTitleNewBase.defaultProps = {
41
+ horizontalPadding: 12,
42
+ };
43
+
44
+ export const CollectionTitleNew = memo(CollectionTitleNewBase);
@@ -0,0 +1,20 @@
1
+ import { StyleSheet } from 'react-native';
2
+
3
+ export const collectionTitleStyles = (appThemeContext) => {
4
+ const { COLORS, FONT_SIZE, FONT_FAMILY } = appThemeContext;
5
+
6
+ return StyleSheet.create({
7
+ container: {
8
+ justifyContent: 'center',
9
+ backgroundColor: COLORS.BRAND_WHITE,
10
+ paddingHorizontal: 12,
11
+ paddingVertical: 8,
12
+ marginTop: 8,
13
+ },
14
+ title: {
15
+ fontSize: FONT_SIZE.h3,
16
+ fontFamily: FONT_FAMILY.secondaryBold,
17
+ color: COLORS.BRAND_5,
18
+ },
19
+ });
20
+ };
@@ -1,11 +1,11 @@
1
- import PropTypes from "prop-types";
2
- import React, { useContext } from "react";
1
+ import React, { useContext, useState } from "react";
3
2
  import { Switch, View } from "react-native";
3
+ import PropTypes from "prop-types";
4
4
  import Icon from "react-native-vector-icons/FontAwesome";
5
- import { COMP_GENERAL_CONSTANTS } from "../../constants/component-constants/general-constants/constants";
6
- import { AppTheme } from "../../utils";
7
5
  import { Text } from "../Text";
6
+ import { AppTheme } from "../../utils";
8
7
  import { customSwitchStyles } from "./styles";
8
+ import { COMP_GENERAL_CONSTANTS } from "../../constants/component-constants/general-constants/constants";
9
9
 
10
10
  export const CustomSwitch = ({
11
11
  label = "",
@@ -1,6 +1,6 @@
1
- import get from 'lodash/get';
2
- import PropTypes from 'prop-types';
3
1
  import React, { useRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import get from 'lodash/get';
4
4
  import { WebView } from 'react-native-webview';
5
5
  import { dailyMotionStyles } from './styles';
6
6
 
@@ -7,9 +7,9 @@ import {
7
7
  ViewPropTypes,
8
8
  } from "react-native";
9
9
 
10
- import { COMP_GENERAL_CONSTANTS } from "../../constants/component-constants";
11
- import { AppTheme } from "../../utils";
12
10
  import { headerStyles } from "./styles";
11
+ import { AppTheme } from "../../utils";
12
+ import { COMP_GENERAL_CONSTANTS } from "../../constants/component-constants";
13
13
 
14
14
  export const Header = (props) => {
15
15
  const { theme } = useContext(AppTheme);
@@ -1,8 +1,8 @@
1
- import { Text } from "@quintype/native-components/src/components/Text";
2
- import isHTML from "is-html";
3
- import React from "react";
4
- import { I18nManager, Linking, StyleSheet } from "react-native";
1
+ import { TouchableOpacity, View, I18nManager, StyleSheet, Linking } from "react-native";
5
2
  import HTML from "react-native-render-html";
3
+ import React from "react";
4
+ import isHTML from "is-html";
5
+ import { Text } from "@quintype/native-components/src/components/Text";
6
6
 
7
7
  const CustomHtmlParser = ({ text, textStyle={}, containerStyle={} }) => {
8
8
  const textStyles = StyleSheet.flatten([
@@ -1,15 +1,15 @@
1
- import PropTypes from "prop-types";
2
1
  import React from "react";
3
2
  import {
4
- StyleSheet,
5
- TouchableOpacity,
6
3
  View,
4
+ TouchableOpacity,
5
+ StyleSheet,
7
6
  ViewPropTypes,
8
7
  } from "react-native";
9
8
  import Icon from "react-native-vector-icons/FontAwesome";
10
- import { COMP_GENERAL_CONSTANTS } from "../../constants/component-constants/general-constants/constants";
9
+ import PropTypes from "prop-types";
11
10
  import { Text } from "../Text";
12
11
  import { iconTextStyles } from "./iconText_styles";
12
+ import { COMP_GENERAL_CONSTANTS } from "../../constants/component-constants/general-constants/constants";
13
13
 
14
14
  const IconText = ({
15
15
  onPress,
@@ -1,9 +1,9 @@
1
+ import { WebView } from 'react-native-webview';
2
+ import React, { useState, useRef, useEffect } from 'react';
1
3
  import { decode as atob } from 'base-64';
2
- import get from 'lodash/get';
3
4
  import PropTypes from 'prop-types';
4
- import React, { useEffect, useRef, useState } from 'react';
5
5
  import { Dimensions, View } from 'react-native';
6
- import { WebView } from 'react-native-webview';
6
+ import get from 'lodash/get';
7
7
  import { STORY_ELEMENT_SUBTYPES } from '../../constants/cardConstants';
8
8
 
9
9
  const escapeRegExp = (string) => string.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&');
@@ -1,9 +1,9 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React, { useState } from 'react';
3
3
  import { TouchableOpacity } from 'react-native';
4
- import { getImageHeight } from '../../utils';
5
- import { LightBox } from '../LightBox';
6
4
  import { ResponsiveImage } from '../ResponsiveImage';
5
+ import { LightBox } from '../LightBox';
6
+ import { getImageHeight } from '../../utils';
7
7
 
8
8
  export const LightBoxImage = ({
9
9
  data, hero, currentLayout, additionalStyles, elementType, onClickHandler = () => {}, index,
@@ -1,20 +1,21 @@
1
1
  import PropTypes from 'prop-types';
2
- import React, { useContext, useState } from 'react';
2
+ import React, { useState, useContext } from 'react';
3
3
  import {
4
+ View,
4
5
  Modal,
5
- Platform,
6
+ TouchableOpacity,
6
7
  SafeAreaView,
7
8
  StyleSheet,
8
- TouchableOpacity,
9
- View
9
+ Platform
10
10
  } from 'react-native';
11
- import Pdf from 'react-native-pdf';
12
11
  import IonIcon from 'react-native-vector-icons/Ionicons';
13
12
  import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
13
+ import Pdf from 'react-native-pdf';
14
14
 
15
- import { AppTheme } from '../../utils';
16
- import { ShareButton, Text } from '../index';
15
+ import { Text } from '../index';
17
16
  import { pdfStyles } from './styles';
17
+ import { ShareButton } from '../index';
18
+ import { AppTheme } from '../../utils';
18
19
 
19
20
  export const PDFReader = ({ card, story }) => {
20
21
  const [modalVisible, setModalVisible] = useState(false);
@@ -0,0 +1,43 @@
1
+ import { cleanup, render, fireEvent } from '@testing-library/react-native';
2
+ import React from 'react';
3
+ import 'react-native';
4
+ import { mockContext } from '../../utils';
5
+ import { PrimaryStoryCard } from './index';
6
+ import { data } from '../../constants/test-data/story.json';
7
+ import { COMP_GENERAL_CONSTANTS } from '../../constants/component-constants/general-constants/constants';
8
+
9
+ const storyData = data.story;
10
+ const onPress = jest.fn();
11
+
12
+ describe('Test Primary Story Card :', () => {
13
+ afterEach(cleanup);
14
+ test('renders author name properly', () => {
15
+ const { getByTestId } = render(
16
+ mockContext(<PrimaryStoryCard story={storyData} />),
17
+ );
18
+ const element = getByTestId(COMP_GENERAL_CONSTANTS.primaryStoryAuthor);
19
+ expect(element.props.children).toBe('By Raghavendra Vaidya | ');
20
+ });
21
+ test('renders story headline properly', () => {
22
+ const { getByTestId } = render(
23
+ mockContext(<PrimaryStoryCard story={storyData} />),
24
+ );
25
+ const element = getByTestId(COMP_GENERAL_CONSTANTS.primaryStoryHeadline);
26
+ expect(element.props.children).toBe('Jack and jill');
27
+ });
28
+ test('renders story publish date properly', () => {
29
+ const { getByTestId } = render(
30
+ mockContext(<PrimaryStoryCard story={storyData} />),
31
+ );
32
+ const element = getByTestId(COMP_GENERAL_CONSTANTS.primaryStoryPubishedAt);
33
+ expect(element.props.children).toBe('1 Feb, 2021');
34
+ });
35
+ test('OnPress handler called properly', () => {
36
+ const { getByTestId } = render(
37
+ mockContext(<PrimaryStoryCard story={storyData} onPress={onPress} />),
38
+ );
39
+ const element = getByTestId(COMP_GENERAL_CONSTANTS.primaryStoryCard);
40
+ fireEvent(element, 'press');
41
+ expect(onPress).toHaveBeenCalled();
42
+ });
43
+ });