mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
fix: badge should render children 0 value (#6981)
When passing 0 in as child, the 0 was not rendred. Fixed the badge component and added tests. ![image](https://github.com/Unleash/unleash/assets/964450/d681b70c-5d55-4818-86ea-7d05fa86c7b3)
This commit is contained in:
parent
233b882c7b
commit
d698eccb4a
17
frontend/src/component/common/Badge/Badge.test.tsx
Normal file
17
frontend/src/component/common/Badge/Badge.test.tsx
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { screen } from '@testing-library/react';
|
||||||
|
import { Badge } from './Badge';
|
||||||
|
import { render } from '../../../utils/testRenderer';
|
||||||
|
|
||||||
|
test('Badge should render text', async () => {
|
||||||
|
render(<Badge color='success'>Predefined</Badge>);
|
||||||
|
|
||||||
|
const result = await screen.findByText('Predefined');
|
||||||
|
expect(result).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Badge should children number 0', async () => {
|
||||||
|
render(<Badge color='success'>{0}</Badge>);
|
||||||
|
|
||||||
|
const result = await screen.findByText('0');
|
||||||
|
expect(result).toBeInTheDocument();
|
||||||
|
});
|
@ -113,7 +113,11 @@ export const Badge: FC<IBadgeProps> = forwardRef(
|
|||||||
show={BadgeIcon(color, icon!)}
|
show={BadgeIcon(color, icon!)}
|
||||||
/>
|
/>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={Boolean(children)}
|
condition={
|
||||||
|
children !== null &&
|
||||||
|
children !== undefined &&
|
||||||
|
children !== ''
|
||||||
|
}
|
||||||
show={<div>{children}</div>}
|
show={<div>{children}</div>}
|
||||||
/>
|
/>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
|
Loading…
Reference in New Issue
Block a user