Skip to content

Commit 8df22e9

Browse files
committed
Fix multi-progress bars
1 parent eaca9ad commit 8df22e9

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/components/Progress.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const Progress = props => {
2121
bar_style,
2222
color,
2323
style,
24+
bar,
2425
...otherProps
2526
} = props;
2627
const isBootstrapColor = bootstrapColors.has(color);
@@ -35,8 +36,9 @@ const Progress = props => {
3536
barStyle={
3637
!isBootstrapColor ? {backgroundColor: color, ...bar_style} : bar_style
3738
}
38-
outer_style={style}
39-
tag={CustomProgressTag}
39+
outer_style={bar ? undefined : style}
40+
bar={bar}
41+
tag={bar ? 'div' : CustomProgressTag}
4042
>
4143
{children}
4244
</RSProgress>

src/components/__tests__/Progress.test.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,19 @@ describe('Progress', () => {
5353
const {
5454
container: {firstChild: progress}
5555
} = render(
56-
<Progress>
56+
<Progress multi>
5757
<Progress value={25} color="success" bar />
5858
<Progress value={25} color="warning" bar />
5959
<Progress value={25} color="danger" bar />
6060
</Progress>
6161
);
6262

63-
expect(progress.firstChild.children[0]).toHaveClass(
64-
'progress-bar bg-success'
65-
);
66-
expect(progress.firstChild.children[1]).toHaveClass(
67-
'progress-bar bg-warning'
68-
);
69-
expect(progress.firstChild.children[2]).toHaveClass(
70-
'progress-bar bg-danger'
71-
);
63+
expect(progress.children[0]).toHaveClass('progress-bar bg-success');
64+
expect(progress.children[0]).toHaveStyle({width: '25%'});
65+
expect(progress.children[1]).toHaveClass('progress-bar bg-warning');
66+
expect(progress.children[1]).toHaveStyle({width: '25%'});
67+
expect(progress.children[2]).toHaveClass('progress-bar bg-danger');
68+
expect(progress.children[2]).toHaveStyle({width: '25%'});
7269
});
7370

7471
test('applies additional CSS classes when props are set', () => {

0 commit comments

Comments
 (0)