diff --git a/src/components/ProgressBar.tsx b/src/components/ProgressBar.tsx index 3c7443e9bc..dcdaf48217 100644 --- a/src/components/ProgressBar.tsx +++ b/src/components/ProgressBar.tsx @@ -38,11 +38,19 @@ export type Props = React.ComponentPropsWithRef & { * Whether to show the ProgressBar (true, the default) or hide it (false). */ visible?: boolean; + /** + * Style of filled part of the ProgresBar. + */ + fillStyle?: Animated.WithAnimatedValue>; style?: StyleProp; /** * @optional */ theme?: ThemeProp; + /** + * testID to be used on tests. + */ + testID?: string; }; const INDETERMINATE_DURATION = 2000; @@ -67,11 +75,13 @@ const { isRTL } = I18nManager; const ProgressBar = ({ color, indeterminate, - style, progress = 0, visible = true, theme: themeOverrides, animatedValue, + style, + fillStyle, + testID = 'progress-bar', ...rest }: Props) => { const isWeb = Platform.OS === 'web'; @@ -196,6 +206,7 @@ const ProgressBar = ({ indeterminate ? {} : { min: 0, max: 100, now: progress * 100 } } style={isWeb && styles.webContainer} + testID={testID} > {width ? ( ) : null} diff --git a/src/components/__tests__/ProgressBar.test.tsx b/src/components/__tests__/ProgressBar.test.tsx index 7e0a06a7df..d995facdb9 100644 --- a/src/components/__tests__/ProgressBar.test.tsx +++ b/src/components/__tests__/ProgressBar.test.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { Animated, Platform } from 'react-native'; +import { Animated, Platform, StyleSheet } from 'react-native'; import { render, waitFor } from '@testing-library/react-native'; @@ -13,6 +13,12 @@ const layoutEvent = { }, }; +const styles = StyleSheet.create({ + fill: { + borderRadius: 4, + }, +}); + const a11yRole = 'progressbar'; class ClassProgressBar extends React.Component { @@ -73,3 +79,14 @@ it('renders progress bar with full height on web', () => { height: '100%', }); }); + +it('renders progress bar with custom style of filled part', async () => { + const tree = render( + + ); + await waitFor(() => tree.getByRole(a11yRole).props.onLayout(layoutEvent)); + + expect(tree.getByTestId('progress-bar-fill')).toHaveStyle({ + borderRadius: 4, + }); +}); diff --git a/src/components/__tests__/__snapshots__/ProgressBar.test.tsx.snap b/src/components/__tests__/__snapshots__/ProgressBar.test.tsx.snap index f2bd97e163..ae5c19ff75 100644 --- a/src/components/__tests__/__snapshots__/ProgressBar.test.tsx.snap +++ b/src/components/__tests__/__snapshots__/ProgressBar.test.tsx.snap @@ -18,6 +18,7 @@ exports[`renders colored progress bar 1`] = ` accessible={true} onLayout={[Function]} style={false} + testID="progress-bar" > @@ -70,6 +72,7 @@ exports[`renders hidden progress bar 1`] = ` accessible={true} onLayout={[Function]} style={false} + testID="progress-bar" > @@ -116,6 +120,7 @@ exports[`renders indeterminate progress bar 1`] = ` accessible={true} onLayout={[Function]} style={false} + testID="progress-bar" > @@ -168,6 +174,7 @@ exports[`renders progress bar with specific progress 1`] = ` accessible={true} onLayout={[Function]} style={false} + testID="progress-bar" >