1
0
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:
Jaanus Sellin 2024-05-06 13:24:52 +03:00 committed by GitHub
parent 233b882c7b
commit d698eccb4a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 1 deletions

View 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();
});

View File

@ -113,7 +113,11 @@ export const Badge: FC<IBadgeProps> = forwardRef(
show={BadgeIcon(color, icon!)}
/>
<ConditionallyRender
condition={Boolean(children)}
condition={
children !== null &&
children !== undefined &&
children !== ''
}
show={<div>{children}</div>}
/>
<ConditionallyRender