Skip to content

Commit e6e004e

Browse files
authored
Merge pull request #476 from huqiaoli/dev
feat(rating):新增Rating测试用例
2 parents ada861f + 61745fd commit e6e004e

File tree

2 files changed

+45
-24
lines changed

2 files changed

+45
-24
lines changed

packages/core/src/Empty/README.md

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -132,27 +132,11 @@ class Demo extends Component {
132132

133133
### Props
134134

135-
```ts
136-
export interface EmptyProps extends FlexProps {
137-
/**
138-
* 设置提示文本
139-
*/
140-
label?: string;
141-
/**
142-
* 设置提示音样式
143-
*/
144-
labelStyle?: TextProps['style'];
145-
/**
146-
* 设置 图标尺寸
147-
*/
148-
size?: number;
149-
/**
150-
* 传递 SVG xml 字符串,自定义图标,设为 `null` 将不展示图标。
151-
*/
152-
xml?: string;
153-
/**
154-
* 不光提示文本,还有更多内容,`label` 将不起作用
155-
*/
156-
children?: React.ReactNode;
157-
}
158-
```
135+
| 属性 | 说明 | 类型 | 默认值 |
136+
| --- | --- | --- | --- |
137+
| label | 设置提示文本 | `string` | - |
138+
| labelStyle | 设置提示音样式 | `TextProps['style']` | - |
139+
| size | 设置图标尺寸 | `number` | - |
140+
| xml | 传递 SVG xml 字符串,自定义图标,设为 `null` 将不展示图标 | `string` | - |
141+
| children | 不光提示文本,还有更多内容,`label` 将不起作用 | `React.ReactNode` | - |
142+

test-ci/src/__tests__/Rating.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* @format
3+
*/
4+
5+
import 'react-native';
6+
import React from 'react';
7+
import Rating from '../lib/Rating';
8+
import Icon from '../lib/Icon';
9+
// Note: test renderer must be required after react-native.
10+
import renderer from 'react-test-renderer';
11+
12+
it('Rating', () => {
13+
const desc = ['0星', '1星', '2星', '3星', '4星', '5星'];
14+
const component = renderer.create(
15+
<Rating
16+
defaultRating={3}
17+
resultRating={10}
18+
size={24}
19+
color="green"
20+
tooltips={desc}
21+
tooltipsStyle={{ fontSize: 25, color: 'blue' }}
22+
icon={{
23+
unactived: <Icon name="smile-o" fill="red" />,
24+
actived: <Icon name="smile" fill="red" />,
25+
}}
26+
disabled
27+
/>,
28+
);
29+
expect(component.root.props.defaultRating).toBe(3);
30+
expect(component.root.props.resultRating).toBe(10);
31+
expect(component.root.props.size).toBe(24);
32+
expect(component.root.props.color).toBe('green');
33+
expect(component.root.props.disabled).toBeTruthy();
34+
expect(component.root.props.tooltipsStyle).toMatchObject({ fontSize: 25, color: 'blue' });
35+
expect(component.root.props.icon.unactived).toStrictEqual(<Icon name="smile-o" fill="red" />);
36+
expect(component.root.props.icon.actived).toStrictEqual(<Icon name="smile" fill="red" />);
37+
});

0 commit comments

Comments
 (0)