@hero-design/rn 8.9.1 → 8.11.0
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.
- package/.turbo/turbo-build.log +9 -9
- package/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/es/index.js +543 -326
- package/lib/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/lib/index.js +543 -326
- package/package.json +5 -5
- package/src/components/Card/index.tsx +1 -1
- package/src/components/Carousel/CardCarousel.tsx +218 -0
- package/src/components/Carousel/StyledCardCarousel.tsx +40 -0
- package/src/components/Carousel/__tests__/CardCarousel.spec.tsx +105 -0
- package/src/components/Carousel/__tests__/StyledCardCarousel.spec.tsx +38 -0
- package/src/components/Carousel/__tests__/__snapshots__/CardCarousel.spec.tsx.snap +289 -0
- package/src/components/Carousel/__tests__/__snapshots__/StyledCardCarousel.spec.tsx.snap +109 -0
- package/src/components/Carousel/contants.ts +10 -0
- package/src/components/Carousel/index.tsx +4 -1
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +0 -1
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +0 -1
- package/src/components/Icon/HeroIcon/glyphMap.json +1 -1
- package/src/components/Icon/IconList.ts +6 -0
- package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +2 -2
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +1 -6
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +1 -6
- package/src/components/TextInput/StyledTextInput.tsx +1 -2
- package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +5 -6
- package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +6 -20
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +0 -2
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +0 -2
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +24 -4
- package/src/theme/components/cardCarousel.ts +28 -0
- package/src/theme/components/textInput.ts +2 -6
- package/src/theme/getTheme.ts +3 -0
- package/src/types.ts +2 -0
- package/types/components/Card/index.d.ts +1 -1
- package/types/components/Carousel/CardCarousel.d.ts +40 -0
- package/types/components/Carousel/StyledCardCarousel.d.ts +31 -0
- package/types/components/Carousel/contants.d.ts +2 -0
- package/types/components/Carousel/index.d.ts +5 -3
- package/types/components/Icon/IconList.d.ts +1 -1
- package/types/components/Icon/index.d.ts +1 -1
- package/types/components/Icon/utils.d.ts +1 -1
- package/types/theme/components/cardCarousel.d.ts +25 -0
- package/types/theme/components/textInput.d.ts +1 -4
- package/types/theme/getTheme.d.ts +2 -0
- package/types/types.d.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.11.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@emotion/native": "^11.9.3",
|
|
23
23
|
"@emotion/react": "^11.9.3",
|
|
24
|
-
"@hero-design/colors": "8.
|
|
24
|
+
"@hero-design/colors": "8.11.0",
|
|
25
25
|
"date-fns": "^2.16.1",
|
|
26
26
|
"events": "^3.2.0",
|
|
27
27
|
"hero-editor": "^1.9.21"
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@babel/preset-typescript": "^7.17.12",
|
|
45
45
|
"@babel/runtime": "^7.18.9",
|
|
46
46
|
"@emotion/jest": "^11.9.3",
|
|
47
|
-
"@hero-design/eslint-plugin": "8.
|
|
47
|
+
"@hero-design/eslint-plugin": "8.11.0",
|
|
48
48
|
"@react-native-community/datetimepicker": "^3.5.2",
|
|
49
49
|
"@react-native-community/slider": "4.1.12",
|
|
50
50
|
"@rollup/plugin-babel": "^5.3.1",
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"@types/react-native": "^0.67.7",
|
|
61
61
|
"@types/react-native-vector-icons": "^6.4.10",
|
|
62
62
|
"babel-plugin-inline-import": "^3.0.0",
|
|
63
|
-
"eslint-config-hd": "8.
|
|
63
|
+
"eslint-config-hd": "8.11.0",
|
|
64
64
|
"jest": "^27.3.1",
|
|
65
|
-
"prettier-config-hd": "8.
|
|
65
|
+
"prettier-config-hd": "8.11.0",
|
|
66
66
|
"react": "18.0.0",
|
|
67
67
|
"react-native": "0.69.7",
|
|
68
68
|
"react-native-gesture-handler": "~2.1.0",
|
|
@@ -4,7 +4,7 @@ import type { StyleProp, ViewProps, ViewStyle } from 'react-native';
|
|
|
4
4
|
import DataCard from './DataCard';
|
|
5
5
|
import { StyledCard } from './StyledCard';
|
|
6
6
|
|
|
7
|
-
interface CardProps extends ViewProps {
|
|
7
|
+
export interface CardProps extends ViewProps {
|
|
8
8
|
/**
|
|
9
9
|
* Card's content.
|
|
10
10
|
*/
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useCallback,
|
|
4
|
+
useEffect,
|
|
5
|
+
useRef,
|
|
6
|
+
useState,
|
|
7
|
+
} from 'react';
|
|
8
|
+
import { FlatList, StyleProp, ViewStyle } from 'react-native';
|
|
9
|
+
import { useTheme } from '../../theme';
|
|
10
|
+
import { ITEM_WIDTH_RATE, VIEW_POSITION_CENTER } from './contants';
|
|
11
|
+
import {
|
|
12
|
+
StyledCard,
|
|
13
|
+
StyledItemWrapper,
|
|
14
|
+
StyledPageControl,
|
|
15
|
+
StyledShadow,
|
|
16
|
+
StyledWrapper,
|
|
17
|
+
} from './StyledCardCarousel';
|
|
18
|
+
|
|
19
|
+
export type CardCarouselHandles = {
|
|
20
|
+
snapToIndex: (index: number) => void;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export interface CardCarouselProps {
|
|
24
|
+
/**
|
|
25
|
+
* Whether to scroll automatically.
|
|
26
|
+
*/
|
|
27
|
+
autoPlay?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Set interval of each slide.
|
|
30
|
+
*/
|
|
31
|
+
autoPlayInterval?: number;
|
|
32
|
+
/**
|
|
33
|
+
* onItemIndexChange event handler receiving index of selected Item.
|
|
34
|
+
*/
|
|
35
|
+
onItemIndexChange?: (index: number) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Carousel data.
|
|
38
|
+
*/
|
|
39
|
+
items: any[];
|
|
40
|
+
/**
|
|
41
|
+
* Indicates hide or show page control.
|
|
42
|
+
*/
|
|
43
|
+
hidePageControl?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Additional styles
|
|
46
|
+
*/
|
|
47
|
+
style?: StyleProp<ViewStyle>;
|
|
48
|
+
/**
|
|
49
|
+
* Testing id of the component.
|
|
50
|
+
*/
|
|
51
|
+
testID?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Component ref.
|
|
54
|
+
*/
|
|
55
|
+
ref?: React.Ref<CardCarouselHandles>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const CardCarousel = forwardRef<CardCarouselHandles, CardCarouselProps>(
|
|
59
|
+
(
|
|
60
|
+
{
|
|
61
|
+
onItemIndexChange,
|
|
62
|
+
items,
|
|
63
|
+
hidePageControl = false,
|
|
64
|
+
style,
|
|
65
|
+
testID,
|
|
66
|
+
autoPlay = false,
|
|
67
|
+
autoPlayInterval = 3000,
|
|
68
|
+
}: CardCarouselProps,
|
|
69
|
+
ref?: React.Ref<CardCarouselHandles>
|
|
70
|
+
) => {
|
|
71
|
+
const [currentIndex, setCurrentIndex] = useState(0);
|
|
72
|
+
|
|
73
|
+
const theme = useTheme();
|
|
74
|
+
const [flatListWidth, setFlatListWidth] = useState(0);
|
|
75
|
+
const itemWidth = flatListWidth * ITEM_WIDTH_RATE;
|
|
76
|
+
const carouselRef = useRef<FlatList>(null);
|
|
77
|
+
|
|
78
|
+
const snapToIndex = useCallback(
|
|
79
|
+
(index) => {
|
|
80
|
+
let validIndex = 0;
|
|
81
|
+
if (index < 0) {
|
|
82
|
+
validIndex = 0;
|
|
83
|
+
} else if (index >= items.length) {
|
|
84
|
+
validIndex = items.length - 1;
|
|
85
|
+
} else {
|
|
86
|
+
validIndex = index;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
carouselRef.current?.scrollToIndex({
|
|
90
|
+
index: validIndex,
|
|
91
|
+
animated: true,
|
|
92
|
+
viewPosition: VIEW_POSITION_CENTER,
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
[carouselRef, itemWidth]
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
/*
|
|
99
|
+
* snap to the next index. If the curent index is the last one, snap to the first one.
|
|
100
|
+
*/
|
|
101
|
+
const snapToNext = useCallback(() => {
|
|
102
|
+
let nextIndex = currentIndex + 1;
|
|
103
|
+
if (nextIndex >= items.length) {
|
|
104
|
+
nextIndex = 0;
|
|
105
|
+
}
|
|
106
|
+
carouselRef.current?.scrollToIndex({
|
|
107
|
+
index: nextIndex,
|
|
108
|
+
animated: true,
|
|
109
|
+
viewPosition: VIEW_POSITION_CENTER,
|
|
110
|
+
});
|
|
111
|
+
}, [carouselRef, currentIndex, itemWidth, items.length]);
|
|
112
|
+
|
|
113
|
+
React.useImperativeHandle(
|
|
114
|
+
ref,
|
|
115
|
+
() => ({
|
|
116
|
+
snapToIndex: (index: number) => {
|
|
117
|
+
snapToIndex(index);
|
|
118
|
+
},
|
|
119
|
+
// we don't expose this method, it's for testing https://medium.com/developer-rants/how-to-test-useref-without-mocking-useref-699165f4994e
|
|
120
|
+
getFlatListRef: () => carouselRef.current,
|
|
121
|
+
}),
|
|
122
|
+
[snapToIndex]
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
let timer: number;
|
|
127
|
+
if (autoPlay) {
|
|
128
|
+
timer = setInterval(() => {
|
|
129
|
+
snapToNext();
|
|
130
|
+
}, autoPlayInterval);
|
|
131
|
+
}
|
|
132
|
+
return () => {
|
|
133
|
+
clearInterval(timer);
|
|
134
|
+
};
|
|
135
|
+
}, [autoPlay, snapToNext, currentIndex, autoPlayInterval]);
|
|
136
|
+
|
|
137
|
+
const visibleSlideChanged = useCallback(
|
|
138
|
+
({ viewableItems }) => {
|
|
139
|
+
if (!viewableItems || (viewableItems && !viewableItems.length)) return;
|
|
140
|
+
const { index } = viewableItems[0];
|
|
141
|
+
setCurrentIndex(index);
|
|
142
|
+
if (onItemIndexChange) {
|
|
143
|
+
onItemIndexChange(index);
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
[onItemIndexChange]
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
const getItemLayout = useCallback(
|
|
150
|
+
(_: React.ReactNode, index: number) => ({
|
|
151
|
+
length: itemWidth,
|
|
152
|
+
offset: itemWidth * index,
|
|
153
|
+
index,
|
|
154
|
+
}),
|
|
155
|
+
[itemWidth]
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
const onLayout = useCallback(
|
|
159
|
+
(e) => {
|
|
160
|
+
setFlatListWidth(e.nativeEvent.layout.width);
|
|
161
|
+
},
|
|
162
|
+
[setFlatListWidth]
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
const renderItem = useCallback(
|
|
166
|
+
({ item }) => {
|
|
167
|
+
return (
|
|
168
|
+
<StyledItemWrapper style={{ width: itemWidth }}>
|
|
169
|
+
{/* using StyledShadow to fix border not shown on Android */}
|
|
170
|
+
<StyledShadow>
|
|
171
|
+
<StyledCard>{item}</StyledCard>
|
|
172
|
+
</StyledShadow>
|
|
173
|
+
</StyledItemWrapper>
|
|
174
|
+
);
|
|
175
|
+
},
|
|
176
|
+
[itemWidth]
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
return (
|
|
180
|
+
<StyledWrapper style={style} testID={testID}>
|
|
181
|
+
<FlatList
|
|
182
|
+
contentContainerStyle={{
|
|
183
|
+
paddingHorizontal:
|
|
184
|
+
theme.__hd__.cardCarousel.space.contentContainerPaddingHorizontal,
|
|
185
|
+
}}
|
|
186
|
+
onLayout={onLayout}
|
|
187
|
+
data={items}
|
|
188
|
+
horizontal
|
|
189
|
+
showsHorizontalScrollIndicator={false}
|
|
190
|
+
pagingEnabled
|
|
191
|
+
bounces={false}
|
|
192
|
+
scrollEventThrottle={32}
|
|
193
|
+
snapToAlignment="center"
|
|
194
|
+
getItemLayout={getItemLayout}
|
|
195
|
+
ref={carouselRef}
|
|
196
|
+
renderItem={renderItem}
|
|
197
|
+
keyExtractor={(_, index) => `${index}`}
|
|
198
|
+
decelerationRate="fast"
|
|
199
|
+
renderToHardwareTextureAndroid
|
|
200
|
+
snapToInterval={
|
|
201
|
+
itemWidth + theme.__hd__.cardCarousel.space.carouselItemSpacing
|
|
202
|
+
}
|
|
203
|
+
onViewableItemsChanged={visibleSlideChanged}
|
|
204
|
+
viewabilityConfig={{
|
|
205
|
+
itemVisiblePercentThreshold: 80,
|
|
206
|
+
}}
|
|
207
|
+
/>
|
|
208
|
+
{!hidePageControl && (
|
|
209
|
+
<StyledPageControl
|
|
210
|
+
testID="pageControl"
|
|
211
|
+
currentPage={currentIndex}
|
|
212
|
+
numberOfPages={items.length}
|
|
213
|
+
/>
|
|
214
|
+
)}
|
|
215
|
+
</StyledWrapper>
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import styled from '@emotion/native';
|
|
2
|
+
import { View, ViewProps } from 'react-native';
|
|
3
|
+
import Card, { CardProps } from '../Card';
|
|
4
|
+
import PageControl, { PageControlProps } from '../PageControl';
|
|
5
|
+
|
|
6
|
+
const StyledPageControl = styled(PageControl)<PageControlProps>(
|
|
7
|
+
({ theme }) => ({
|
|
8
|
+
alignSelf: 'center',
|
|
9
|
+
marginTop: theme.__hd__.cardCarousel.space.pageControlMarginTop,
|
|
10
|
+
})
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
const StyledWrapper = styled(View)<ViewProps>({});
|
|
14
|
+
|
|
15
|
+
const StyledCard = styled(Card)<CardProps>(({ theme }) => ({
|
|
16
|
+
borderRadius: theme.__hd__.cardCarousel.radii.card,
|
|
17
|
+
overflow: 'hidden',
|
|
18
|
+
flex: 1,
|
|
19
|
+
}));
|
|
20
|
+
const StyledShadow = styled(View)<ViewProps>(({ theme }) => ({
|
|
21
|
+
borderRadius: theme.__hd__.cardCarousel.radii.card,
|
|
22
|
+
shadowColor: theme.__hd__.cardCarousel.colors.shadow,
|
|
23
|
+
shadowOffset: theme.__hd__.cardCarousel.shadows.offset,
|
|
24
|
+
shadowRadius: theme.__hd__.cardCarousel.shadows.radius,
|
|
25
|
+
shadowOpacity: theme.__hd__.cardCarousel.shadows.opacity,
|
|
26
|
+
elevation: theme.__hd__.cardCarousel.shadows.elevation,
|
|
27
|
+
flex: 1,
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
const StyledItemWrapper = styled(View)<ViewProps>(({ theme }) => ({
|
|
31
|
+
padding: theme.__hd__.cardCarousel.space.carouselItemSpacing,
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
StyledCard,
|
|
36
|
+
StyledShadow,
|
|
37
|
+
StyledItemWrapper,
|
|
38
|
+
StyledWrapper,
|
|
39
|
+
StyledPageControl,
|
|
40
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { waitFor } from '@testing-library/react-native';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { FlatList } from 'react-native';
|
|
4
|
+
import { CardCarousel, CardCarouselHandles } from '../CardCarousel';
|
|
5
|
+
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
6
|
+
import Typography from '../../Typography';
|
|
7
|
+
|
|
8
|
+
describe('CardCarousel', () => {
|
|
9
|
+
it('should render correctly', () => {
|
|
10
|
+
const wrapper = renderWithTheme(
|
|
11
|
+
<CardCarousel
|
|
12
|
+
testID="cardCarousel"
|
|
13
|
+
style={{ width: 100, height: 100 }}
|
|
14
|
+
items={[
|
|
15
|
+
<Typography.Text> screen 1</Typography.Text>,
|
|
16
|
+
<Typography.Text> screen 2</Typography.Text>,
|
|
17
|
+
]}
|
|
18
|
+
/>
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
22
|
+
expect(wrapper.queryAllByText('screen 1')).toHaveLength(1);
|
|
23
|
+
expect(wrapper.queryAllByText('screen 2')).toHaveLength(1);
|
|
24
|
+
expect(wrapper.queryAllByTestId('pageControl')).toHaveLength(1);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe('autoPlay', () => {
|
|
28
|
+
it('should call scrollToIndex 1', () => {
|
|
29
|
+
jest.useFakeTimers();
|
|
30
|
+
const carouselRef = React.createRef<
|
|
31
|
+
CardCarouselHandles & {
|
|
32
|
+
getFlatListRef: () => FlatList;
|
|
33
|
+
}
|
|
34
|
+
>();
|
|
35
|
+
|
|
36
|
+
renderWithTheme(
|
|
37
|
+
<CardCarousel
|
|
38
|
+
ref={carouselRef}
|
|
39
|
+
autoPlay
|
|
40
|
+
autoPlayInterval={3000}
|
|
41
|
+
items={[
|
|
42
|
+
<Typography.Text> screen 1</Typography.Text>,
|
|
43
|
+
<Typography.Text> screen 2</Typography.Text>,
|
|
44
|
+
]}
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
const flatListRef = carouselRef.current!.getFlatListRef()!;
|
|
48
|
+
const snapToIndexSpy = jest.spyOn(flatListRef, 'scrollToIndex');
|
|
49
|
+
jest.advanceTimersByTime(3000);
|
|
50
|
+
expect(snapToIndexSpy).toHaveBeenCalledWith({
|
|
51
|
+
animated: true,
|
|
52
|
+
index: 1,
|
|
53
|
+
viewPosition: 0.5,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
jest.useRealTimers();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe('hidePageControl', () => {
|
|
61
|
+
const wrapper = renderWithTheme(
|
|
62
|
+
<CardCarousel
|
|
63
|
+
style={{ width: 100, height: 100 }}
|
|
64
|
+
hidePageControl
|
|
65
|
+
items={[
|
|
66
|
+
<Typography.Text> screen 1</Typography.Text>,
|
|
67
|
+
<Typography.Text> screen 2</Typography.Text>,
|
|
68
|
+
]}
|
|
69
|
+
/>
|
|
70
|
+
);
|
|
71
|
+
expect(wrapper.queryAllByTestId('pageControl')).toHaveLength(0);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe('snapToIndex', () => {
|
|
75
|
+
it('should render correctly', () => {
|
|
76
|
+
const carouselRef = React.createRef<
|
|
77
|
+
CardCarouselHandles & {
|
|
78
|
+
getFlatListRef: () => FlatList;
|
|
79
|
+
}
|
|
80
|
+
>();
|
|
81
|
+
|
|
82
|
+
renderWithTheme(
|
|
83
|
+
<CardCarousel
|
|
84
|
+
ref={carouselRef}
|
|
85
|
+
items={[
|
|
86
|
+
<Typography.Text> screen 1</Typography.Text>,
|
|
87
|
+
<Typography.Text> screen 2</Typography.Text>,
|
|
88
|
+
<Typography.Text> screen 3</Typography.Text>,
|
|
89
|
+
]}
|
|
90
|
+
/>
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const flatListRef = carouselRef.current!.getFlatListRef()!;
|
|
94
|
+
const snapToIndexSpy = jest.spyOn(flatListRef, 'scrollToIndex');
|
|
95
|
+
carouselRef.current?.snapToIndex(2);
|
|
96
|
+
waitFor(() => expect(snapToIndexSpy).toHaveBeenCalled());
|
|
97
|
+
|
|
98
|
+
expect(snapToIndexSpy).toHaveBeenCalledWith({
|
|
99
|
+
animated: true,
|
|
100
|
+
index: 2,
|
|
101
|
+
viewPosition: 0.5,
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
3
|
+
import {
|
|
4
|
+
StyledCard,
|
|
5
|
+
StyledItemWrapper,
|
|
6
|
+
StyledPageControl,
|
|
7
|
+
StyledWrapper,
|
|
8
|
+
} from '../StyledCardCarousel';
|
|
9
|
+
|
|
10
|
+
describe('StyledPageControl', () => {
|
|
11
|
+
it('should render correctly', () => {
|
|
12
|
+
const { toJSON } = renderWithTheme(
|
|
13
|
+
<StyledPageControl numberOfPages={3} currentPage={1} />
|
|
14
|
+
);
|
|
15
|
+
expect(toJSON()).toMatchSnapshot();
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
describe('StyledWrapper', () => {
|
|
20
|
+
it('should render correctly', () => {
|
|
21
|
+
const { toJSON } = renderWithTheme(<StyledWrapper />);
|
|
22
|
+
expect(toJSON()).toMatchSnapshot();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe('StyledCard', () => {
|
|
27
|
+
it('should render correctly', () => {
|
|
28
|
+
const { toJSON } = renderWithTheme(<StyledCard />);
|
|
29
|
+
expect(toJSON()).toMatchSnapshot();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe('StyledItemWrapper', () => {
|
|
34
|
+
it('should render correctly', () => {
|
|
35
|
+
const { toJSON } = renderWithTheme(<StyledItemWrapper />);
|
|
36
|
+
expect(toJSON()).toMatchSnapshot();
|
|
37
|
+
});
|
|
38
|
+
});
|