Skip to content

Commit bcc18a6

Browse files
hy916hy
authored andcommitted
fix: 添加Badge和Empty组件测试用例 (#402)
Co-authored-by: hy <huyi@163.com>
1 parent 4094e91 commit bcc18a6

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

test-ci/src/__tests__/badge.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @format
3+
*/
4+
5+
import 'react-native';
6+
import React from 'react';
7+
import Badge from '../lib/Badge';
8+
// Note: test renderer must be required after react-native.
9+
import renderer from 'react-test-renderer';
10+
11+
it('Badge', () => {
12+
const component = renderer.create(
13+
<Badge text="标记" color="red" rounded={12} />
14+
);
15+
expect(component.root.props.type).toBeTruthy();
16+
expect(component.root.props.color).toBe('red');
17+
expect(component.root.props.text).toBe('标记');
18+
expect(component.root.props.rounded).toBe(12);
19+
});

test-ci/src/__tests__/empty.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @format
3+
*/
4+
5+
import 'react-native';
6+
import React from 'react';
7+
import Empty from '../lib/Empty';
8+
// Note: test renderer must be required after react-native.
9+
import renderer from 'react-test-renderer';
10+
11+
it('Empty', () => {
12+
const component = renderer.create(
13+
<Empty label="冇得数据咯" size={120} labelStyle={{ color: 'red' }}>冇得数据咯</Empty>
14+
);
15+
expect(component.root.props.label).toBe('冇得数据咯');
16+
expect(component.root.props.size).toBe(120);
17+
expect(component.root.props.labelStyle).toBeTruthy();
18+
expect(component.root.props.xml).toBeTruthy();
19+
expect(component.root.props.children).toBe('冇得数据咯');
20+
21+
});

0 commit comments

Comments
 (0)