Skip to content

Commit 2a40a11

Browse files
author
rulishu
committed
test(swiper):添加swiper测试用例
1 parent 856a515 commit 2a40a11

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test-ci/src/__tests__/swiper.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* @format
3+
*/
4+
5+
import 'react-native';
6+
import React from 'react';
7+
import Swiper, { dataSourceType } from '../lib/Swiper';
8+
import renderer from 'react-test-renderer';
9+
10+
it('Swiper', () => {
11+
const datas: dataSourceType[] = [
12+
{
13+
url: 'https://p1.itc.cn/images01/20210530/7a071b3cdc0643c197f143cfa4edc827.jpeg',
14+
onClick: () => {
15+
console.log('你好!刘亦菲');
16+
},
17+
},
18+
{
19+
url: 'https://inews.gtimg.com/newsapp_bt/0/14745270054/641',
20+
onClick: () => {
21+
console.log('你好!王楚然');
22+
},
23+
},
24+
];
25+
const component = renderer.create(
26+
<Swiper width={200} dataSource={datas} height={150} borderRadius={24} time={10} autoplay dotStyle="dot" loading />,
27+
);
28+
expect(component.root.props.width).toBe(200);
29+
expect(component.root.props.height).toBe(150);
30+
expect(component.root.props.borderRadius).toBe(24);
31+
expect(component.root.props.time).toBe(10);
32+
expect(component.root.props.dotStyle).toBe('dot');
33+
expect(component.root.props.dataSource).toMatchObject(datas);
34+
expect(component.root.props.autoplay).toBeTruthy();
35+
expect(component.root.props.loading).toBeTruthy();
36+
});

0 commit comments

Comments
 (0)