Skip to content

Commit f4bc90a

Browse files
hyxingyuefeng
authored andcommitted
fix: 添加Ellipsis和ExpandableSection组件测试用例
1 parent 1c6dd92 commit f4bc90a

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

test-ci/src/__tests__/ellipsis.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Ellipsis from '../lib/Ellipsis';
2+
import renderer from 'react-test-renderer';
3+
4+
it('Ellipsis', () => {
5+
const component = renderer.create(
6+
<Ellipsis maxLen={5} placeholder='...'>用于文本过长,超出长度显示</Ellipsis>
7+
);
8+
expect(component.root.props.maxLen).toBe(5);
9+
expect(component.root.props.placeholder).toBe('...');
10+
expect(component.root.props.children).toBe('用于文本过长,超出长度显示');
11+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* @format
3+
*/
4+
5+
import 'react-native';
6+
import React from 'react';
7+
import ExpandableSection from '../lib/ExpandableSection';
8+
import { View, Text } from 'react-native';
9+
import renderer from 'react-test-renderer';
10+
11+
it('ExpandableSection', () => {
12+
const component = renderer.create(
13+
<ExpandableSection sectionHeader={<h5>我是标题</h5>} expanded={true} top={true}>
14+
<View>
15+
<Text style={{ color: 'red' }}>展开的内容</Text>
16+
</View>
17+
</ExpandableSection>,
18+
);
19+
20+
expect(component.root.props.top).toBeTruthy();
21+
expect(component.root.props.expanded).toBeTruthy();
22+
expect(component.root.props.sectionHeader).toStrictEqual(<h5>我是标题</h5>);
23+
expect(component.root.props.children).toStrictEqual(
24+
<View>
25+
<Text style={{ color: 'red' }}>展开的内容</Text>
26+
</View>
27+
);
28+
});

0 commit comments

Comments
 (0)