@quintype/native-components 2.22.7 → 2.28.1

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 (46) hide show
  1. package/package.json +1 -1
  2. package/src/components/AlsoRead/index.js +4 -4
  3. package/src/components/AuthorRow/index.js +3 -3
  4. package/src/components/BackNavigator/index.js +6 -6
  5. package/src/components/Button/index.js +1 -1
  6. package/src/components/CollectionCard/index.js +20 -10
  7. package/src/components/CollectionTitle/index.js +20 -38
  8. package/src/components/CollectionTitle/styles.js +11 -13
  9. package/src/components/CustomSwitch/index.js +4 -4
  10. package/src/components/DailyMotionPlayer/index.js +2 -2
  11. package/src/components/Header/index.js +2 -2
  12. package/src/components/Html/index.js +4 -4
  13. package/src/components/IconText/index.js +4 -4
  14. package/src/components/JSEmbedElement/index.js +3 -3
  15. package/src/components/LightBoxImage/index.js +2 -2
  16. package/src/components/PDFReader/index.js +7 -8
  17. package/src/components/PrimaryStoryCard/index.js +47 -92
  18. package/src/components/PrimaryStoryCard/styles.js +30 -49
  19. package/src/components/RadioButton/index.js +3 -3
  20. package/src/components/Rating/index.js +1 -1
  21. package/src/components/RelatedStoriesCard/index.js +2 -12
  22. package/src/components/SecondaryStoryCard/index.js +59 -108
  23. package/src/components/SecondaryStoryCard/styles.js +35 -55
  24. package/src/components/Story/index.js +12 -13
  25. package/src/components/StoryHeader/index.js +8 -8
  26. package/src/components/StoryTemplateIcon/index.js +58 -0
  27. package/src/components/StoryTemplateIcon/styles.js +23 -0
  28. package/src/components/StoryText/index.js +5 -2
  29. package/src/components/TextA/index.js +4 -4
  30. package/src/components/TextBigFact/index.js +4 -4
  31. package/src/components/TextBlockQuote/index.js +5 -5
  32. package/src/components/TextBlurb/index.js +3 -3
  33. package/src/components/TextQandA/index.js +2 -3
  34. package/src/components/index.js +1 -4
  35. package/src/utils/story-types.js +1 -0
  36. package/src/components/CollectionCardNew/index.js +0 -84
  37. package/src/components/CollectionTitle/CollectionTitle.test.js +0 -12
  38. package/src/components/CollectionTitle/__snapshots__/CollectionTitle.test.js.snap +0 -3
  39. package/src/components/CollectionTitleNew/index.js +0 -44
  40. package/src/components/CollectionTitleNew/styles.js +0 -20
  41. package/src/components/PrimaryStoryCard/PrimaryStoryCard.test.js +0 -43
  42. package/src/components/PrimaryStoryCardNew/index.js +0 -134
  43. package/src/components/PrimaryStoryCardNew/styles.js +0 -70
  44. package/src/components/SecondaryStoryCard/SecondaryStoryCard.test.js +0 -51
  45. package/src/components/SecondaryStoryCardNew/index.js +0 -140
  46. package/src/components/SecondaryStoryCardNew/styles.js +0 -82
@@ -1,9 +1,9 @@
1
- import PropTypes from 'prop-types';
2
- import React, { useContext } from 'react';
3
- import { View, StyleSheet, Linking,I18nManager } from 'react-native';
4
- import { StoryText, Text } from '@quintype/native-components/src/components';
1
+ import { Text } from '@quintype/native-components/src/components';
5
2
  import { textAnswerStyles } from '@quintype/native-components/src/components/TextA/styles';
6
3
  import { AppTheme } from '@quintype/native-components/src/utils/context';
4
+ import PropTypes from 'prop-types';
5
+ import React, { useContext } from 'react';
6
+ import { I18nManager, Linking, StyleSheet, View } from 'react-native';
7
7
  import HTML from 'react-native-render-html';
8
8
  import { customHTMLStyles } from '../../constants/renderHTML';
9
9
 
@@ -1,12 +1,12 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React, { useContext } from 'react';
3
- import { View, Linking, StyleSheet } from 'react-native';
3
+ import { StyleSheet, View } from 'react-native';
4
4
  import HTML from 'react-native-render-html';
5
- import { Text } from '../index';
6
- import { bigTextStyles } from './styles';
7
- import { AppTheme } from '../../utils/context';
8
5
  import { customHTMLStyles } from '../../constants/renderHTML';
9
6
  import { alterQuoteData } from '../../utils';
7
+ import { AppTheme } from '../../utils/context';
8
+ import { Text } from '../index';
9
+ import { bigTextStyles } from './styles';
10
10
 
11
11
  export const TextBigFact = ({ text, attribution, id }) => {
12
12
  const { theme, useDeeplinkHandler } = useContext(AppTheme);
@@ -1,13 +1,13 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React, { useContext } from 'react';
3
- import { View, Linking, StyleSheet } from 'react-native';
4
- import Icon from 'react-native-vector-icons/FontAwesome';
3
+ import { StyleSheet, View } from 'react-native';
5
4
  import HTML from 'react-native-render-html';
6
- import { Text } from '../index';
5
+ import Icon from 'react-native-vector-icons/FontAwesome';
7
6
  import { customHTMLStyles } from '../../constants/renderHTML';
8
- import { blockQuoteTextStyles } from './styles';
9
- import { AppTheme } from '../../utils/context';
10
7
  import { alterQuoteData } from '../../utils';
8
+ import { AppTheme } from '../../utils/context';
9
+ import { Text } from '../index';
10
+ import { blockQuoteTextStyles } from './styles';
11
11
 
12
12
  export const TextBlockQuote = ({ text, attribution }) => {
13
13
  const { theme, useDeeplinkHandler } = useContext(AppTheme);
@@ -1,10 +1,10 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React, { useContext } from 'react';
3
- import { View, Linking, StyleSheet } from 'react-native';
3
+ import { StyleSheet, View } from 'react-native';
4
4
  import HTML from 'react-native-render-html';
5
- import { textBlurbStyles } from './styles';
6
- import { AppTheme } from '../../utils/context';
7
5
  import { customHTMLStyles } from '../../constants/renderHTML';
6
+ import { AppTheme } from '../../utils/context';
7
+ import { textBlurbStyles } from './styles';
8
8
 
9
9
  export const TextBlurb = ({ text }) => {
10
10
  const { theme, useDeeplinkHandler } = useContext(AppTheme);
@@ -1,11 +1,10 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React, { useContext } from 'react';
3
3
  import { View } from 'react-native';
4
- import { Text } from '../index';
5
- import { textQandAStyles } from './styles';
6
4
  import { AppTheme } from '../../utils/context';
7
- import { TextQ } from '../TextQ/index';
8
5
  import { TextA } from '../TextA/index';
6
+ import { TextQ } from '../TextQ/index';
7
+ import { textQandAStyles } from './styles';
9
8
 
10
9
  export const TextQandA = ({ question, answer }) => {
11
10
  const { theme } = useContext(AppTheme);
@@ -3,21 +3,17 @@ export { AuthorRow } from './AuthorRow';
3
3
  export { BackNavigator } from './BackNavigator';
4
4
  export { Button } from './Button';
5
5
  export { CollectionCard } from './CollectionCard';
6
- export { CollectionCardNew } from './CollectionCardNew';
7
6
  export { CollectionTitle } from './CollectionTitle';
8
- export { CollectionTitleNew } from './CollectionTitleNew';
9
7
  export { CustomLoader } from './CustomLoader';
10
8
  export { FBCommentsRow } from './FBCommentsRow';
11
9
  export { Header } from './Header';
12
10
  export { JSEmbedElement } from './JSEmbedElement';
13
11
  export { PDFReader } from './PDFReader';
14
12
  export { PrimaryStoryCard } from './PrimaryStoryCard';
15
- export { PrimaryStoryCardNew } from './PrimaryStoryCardNew';
16
13
  export { RadioButton } from './RadioButton';
17
14
  export { ResponsiveImage } from './ResponsiveImage';
18
15
  export { Search } from './Search';
19
16
  export { SecondaryStoryCard } from './SecondaryStoryCard';
20
- export { SecondaryStoryCardNew } from './SecondaryStoryCardNew';
21
17
  export { ShareButton } from './ShareButton';
22
18
  export { Story } from './Story';
23
19
  export { StoryContent } from './StoryContent';
@@ -47,3 +43,4 @@ export { References } from './References';
47
43
  export { StoryCardDetailsRow } from './StoryCardDetailsRow';
48
44
  export { TextA } from './TextA'
49
45
  export { TextQ } from './TextQ'
46
+ export { StoryTemplateIcon } from './StoryTemplateIcon'
@@ -1,4 +1,5 @@
1
1
  export const STORY_TYPES = {
2
2
  LIVE_BLOG: 'live-blog',
3
3
  VIDEO_STORY: 'video',
4
+ VISUAL_STORY: 'visual-story',
4
5
  };
@@ -1,84 +0,0 @@
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);
@@ -1,12 +0,0 @@
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
- });
@@ -1,3 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`renders correctly 1`] = `null`;
@@ -1,44 +0,0 @@
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);
@@ -1,20 +0,0 @@
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,43 +0,0 @@
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
- });
@@ -1,134 +0,0 @@
1
- import { get, throttle } from 'lodash';
2
- import PropTypes from 'prop-types';
3
- import React, { useContext, memo } from 'react';
4
- import { StyleSheet, TouchableOpacity, View } from 'react-native';
5
- import Icon from 'react-native-vector-icons/FontAwesome';
6
- import {
7
- AppTheme,
8
- getImageMetadata,
9
- getImageSlug,
10
- } from '../../utils';
11
- import { getStoryHeadline } from '../../utils/story';
12
- import { ResponsiveImage, Text, StoryCardDetailsRow } from '../index';
13
- import { storyStyles } from './styles';
14
- import {
15
- COMP_GENERAL_CONSTANTS,
16
- COMP_CONTENT_CONSTANTS,
17
- } from '../../constants/component-constants';
18
- import PremiumIcons from '../../Icons/PremiumIcons/index';
19
-
20
- const PrimaryStoryCardNewBase = (props) => {
21
- const { story = {} } = props;
22
- const { theme } = useContext(AppTheme);
23
- const {
24
- COLORS,
25
- FONT_SIZE,
26
- FONT_FAMILY,
27
- premiumIcon,
28
- lineHeightMultiplier,
29
- storyCardOptions = {},
30
- } = theme || {};
31
-
32
- const styles = storyStyles(theme);
33
- const containerStyle = StyleSheet.flatten([
34
- styles.container,
35
- { paddingHorizontal: props.horizontalPadding },
36
- ]);
37
- const headlineStyle = StyleSheet.flatten([
38
- styles.headline,
39
- props.headlineStyle,
40
- ]);
41
-
42
- const isPremiumStory = story['access'] === 'subscription';
43
-
44
- const throttledOnpress = throttle(props.onPress, 1000);
45
-
46
- const showIcon = (name) => (
47
- <View style={styles.storyType}>
48
- <Icon name={name} size={22} color={COLORS.MONO7} />
49
- </View>
50
- );
51
-
52
- const showLiveBlogIcon = () => (
53
- <View style={styles.storyType}>
54
- <View style={styles.liveBlogIcon} />
55
- <Text style={styles.liveBlogText}>LIVE</Text>
56
- </View>
57
- );
58
- const showStoryType = () => {
59
- switch (story['story-template']) {
60
- case 'text':
61
- return null;
62
- case 'photo':
63
- return showIcon('photo');
64
- case 'video':
65
- return showIcon('play');
66
- case 'live-blog':
67
- return showLiveBlogIcon();
68
- default:
69
- null;
70
- }
71
- };
72
-
73
- return (
74
- <>
75
- <TouchableOpacity
76
- testID={COMP_GENERAL_CONSTANTS.primaryStoryCard}
77
- onPress={throttledOnpress}
78
- activeOpacity={0.8}
79
- style={containerStyle}
80
- >
81
- <ResponsiveImage
82
- metaData={getImageMetadata(story)}
83
- slug={getImageSlug(story)}
84
- cdn={props.cdn}
85
- imageWidth={props.imageWidth}
86
- >
87
- <View style={styles.storyTypeContainer}>{showStoryType()}</View>
88
- </ResponsiveImage>
89
- <View style={styles.contentContainer}>
90
- <View style={styles.headlineAndTimestampContainer}>
91
- {storyCardOptions.enableSectionName && <Text numberOfLines={1} ellipsizeMode="tail" style={styles.sectionName}>{get(story, ['sections', 0, 'display-name'], '')}</Text>}
92
- <View style={{display:'flex', flexDirection:'row'}}>
93
- <Text
94
- primary
95
- numberOfLines={storyCardOptions.numberOfLinesForTitle}
96
- ellipsizeMode="tail"
97
- style={headlineStyle}
98
- testID={COMP_GENERAL_CONSTANTS.primaryStoryHeadline}
99
- >
100
- {isPremiumStory && premiumIcon !=='none' && <PremiumIcons style={styles.premiumIcon} name={premiumIcon} color={COLORS.primary} size={FONT_SIZE.h2} /> }
101
- {isPremiumStory && premiumIcon !=='none' && ' '}
102
- {getStoryHeadline(story)}
103
- </Text>
104
- </View>
105
- <StoryCardDetailsRow
106
- authorName={get(story.authors, [0, 'name'])}
107
- publishedAt={story["published-at"]}
108
- readTime={story['read-time']}
109
- />
110
- </View>
111
- <View style={styles.icon}>{props.iconComponent}</View>
112
- </View>
113
- </TouchableOpacity>
114
- <View style={[styles.separatorLine, {marginHorizontal: props.horizontalPadding}]}/>
115
- </>
116
- );
117
- };
118
-
119
- PrimaryStoryCardNewBase.propTypes = {
120
- cdn: PropTypes.string,
121
- imageWidth: PropTypes.number,
122
- headlineStyle: PropTypes.func,
123
- story: PropTypes.object.isRequired,
124
- onPress: PropTypes.func,
125
- horizontalPadding: PropTypes.number,
126
- iconComponent: PropTypes.element,
127
- };
128
-
129
- PrimaryStoryCardNewBase.defaultProps = {
130
- cdn: '',
131
- horizontalPadding: 12,
132
- };
133
-
134
- export const PrimaryStoryCardNew = memo(PrimaryStoryCardNewBase);
@@ -1,70 +0,0 @@
1
- export const storyStyles = ({COLORS, FONT_SIZE, FONT_FAMILY, lineHeightMultiplier, storyCardOptions = {}}) => ({
2
- container: {
3
- backgroundColor: COLORS.BRAND_WHITE,
4
- paddingVertical: 10,
5
- gap: 10,
6
- },
7
- contentContainer: {
8
- flexDirection: 'row',
9
- justifyContent: 'space-between',
10
- alignItems: 'flex-start',
11
- gap: 10,
12
- },
13
- headlineAndTimestampContainer: {
14
- flexShrink: 1,
15
- gap: 4,
16
- },
17
- icon: {
18
- marginBottom: 4,
19
- marginTop: storyCardOptions.enableSectionName ? FONT_SIZE.h4 * lineHeightMultiplier + 8 : 4,
20
- },
21
- sectionName: {
22
- color: COLORS.BRAND_1,
23
- fontSize: FONT_SIZE.h4,
24
- lineHeight: FONT_SIZE.h4 * lineHeightMultiplier,
25
- },
26
- headline: {
27
- fontFamily: FONT_FAMILY.primaryBold,
28
- fontSize: FONT_SIZE.title,
29
- lineHeight: FONT_SIZE.title * lineHeightMultiplier,
30
- color: COLORS.BRAND_BLACK,
31
- marginBottom: 4,
32
- },
33
- storyTypeContainer: {
34
- position: 'absolute',
35
- bottom: 0,
36
- left: 0,
37
- },
38
- storyType: {
39
- backgroundColor: COLORS.MONO1,
40
- padding: 8,
41
- justifyContent: 'space-between',
42
- alignItems: 'space-between',
43
- flexDirection: 'row',
44
- },
45
- storyTypeText: {
46
- color: COLORS.MONO7,
47
- fontSize: FONT_SIZE.h5,
48
- },
49
- liveBlogText: {
50
- color: COLORS.MONO7,
51
- fontSize: FONT_SIZE.h4,
52
- marginLeft: 10,
53
- fontWeight: 'bold',
54
- },
55
- liveBlogIcon: {
56
- height: 15,
57
- width: 15,
58
- borderRadius: 50,
59
- backgroundColor: COLORS.BRAND_3,
60
- },
61
- premiumIcon: {
62
- marginTop: FONT_SIZE.h3 * 0.92,
63
- marginRight: 5,
64
- },
65
- separatorLine: {
66
- height: 0.8,
67
- opacity: 0.1,
68
- backgroundColor: COLORS.BRAND_BLACK,
69
- },
70
- });
@@ -1,51 +0,0 @@
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 { SecondaryStoryCard } 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 Secondary Story Card :', () => {
13
- afterEach(cleanup);
14
- test('renders author name properly', () => {
15
- const { getByTestId } = render(
16
- mockContext(<SecondaryStoryCard story={storyData} />),
17
- );
18
- const element = getByTestId(COMP_GENERAL_CONSTANTS.secondaryStoryAuthor);
19
- expect(element.props.children).toBe('By Raghavendra Vaidya | ');
20
- });
21
- test('renders story headline properly', () => {
22
- const { getByTestId } = render(
23
- mockContext(<SecondaryStoryCard story={storyData} />),
24
- );
25
- const element = getByTestId(COMP_GENERAL_CONSTANTS.secondaryStoryHeadline);
26
- expect(element.props.children).toBe('Jack and jill');
27
- });
28
- test('renders story date properly', () => {
29
- const { getByTestId } = render(
30
- mockContext(<SecondaryStoryCard story={storyData} />),
31
- );
32
- const element = getByTestId(
33
- COMP_GENERAL_CONSTANTS.secondaryStoryPubishedAt,
34
- );
35
- expect(element.props.children).toBe('1 Feb, 2021');
36
- });
37
- test('OnPress handler called properly', () => {
38
- const { getByTestId } = render(
39
- mockContext(
40
- <SecondaryStoryCard
41
- story={storyData}
42
- onPress={onPress}
43
- collectionTestID="secondaryStoryCardView"
44
- />,
45
- ),
46
- );
47
- const element = getByTestId(COMP_GENERAL_CONSTANTS.secondaryStoryCard);
48
- fireEvent(element, 'press');
49
- expect(onPress).toHaveBeenCalled();
50
- });
51
- });