Skip to content

Commit 6b3c5b6

Browse files
huqiaolixingyuefeng
authored andcommitted
feat(progress):新增Progress测试
1 parent e051f57 commit 6b3c5b6

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

packages/core/src/Progress/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import { has } from 'lodash';
21
import React, { useRef, useState, useEffect } from 'react';
32
import { Animated, View, StyleSheet, ViewProps, LayoutChangeEvent, Text } from 'react-native';
4-
import { Flex } from 'src';
53
import { run } from './svg';
64
import Icon from '../Icon';
75

@@ -44,7 +42,9 @@ export default (props: ProgressProps) => {
4442
const [wrapWidth, setWrapWidth] = useState<number>(0);
4543

4644
useEffect(() => {
47-
startAnimation();
45+
if (wrapWidth && progress) {
46+
startAnimation();
47+
}
4848
}, [wrapWidth, progress]);
4949

5050
const startAnimation = () => {

test-ci/src/__tests__/progress.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* @format
3+
*/
4+
5+
import 'react-native';
6+
import React from 'react';
7+
import Progress from '../lib/Progress';
8+
// Note: test renderer must be required after react-native.
9+
import renderer from 'react-test-renderer';
10+
import { run } from '../lib/Progress/svg';
11+
12+
it('Progress', () => {
13+
const component = renderer.create(
14+
<Progress
15+
progress={30}
16+
position="fixed"
17+
progressColor="#108ee9"
18+
animation={{ duration: 1000 }}
19+
xml={run}
20+
iconShow={true}
21+
size={25}
22+
progressShow={true}
23+
/>,
24+
);
25+
expect(component.root.props.progress).toBe(30);
26+
expect(component.root.props.position).toBe('fixed');
27+
expect(component.root.props.progressColor).toBe('#108ee9');
28+
expect(component.root.props.animation.duration).toBe(1000);
29+
expect(component.root.props.iconShow).toBeTruthy();
30+
expect(component.root.props.xml).toStrictEqual(run);
31+
expect(component.root.props.size).toBe(25);
32+
expect(component.root.props.progressShow).toBeTruthy();
33+
});

0 commit comments

Comments
 (0)