mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 17:44:35 +08:00
fix: Badge not work when props.color is empty (#26375)
* fix: Badge not work when props.color is empty * update: test
This commit is contained in:
parent
507fdc44ae
commit
453eafe68d
@ -141,6 +141,17 @@ describe('Badge', () => {
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('Badge should work when status/color is empty string', () => {
|
||||
const wrapper = mount(
|
||||
<>
|
||||
<Badge color="" text="text" />
|
||||
<Badge status="" text="text" />
|
||||
</>,
|
||||
);
|
||||
|
||||
expect(wrapper.find('.ant-badge')).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('render Badge size when contains children', () => {
|
||||
const wrapper = render(
|
||||
<>
|
||||
|
@ -62,9 +62,7 @@ const Badge: CompoundedComponent = ({
|
||||
return displayCount as string | number | null;
|
||||
};
|
||||
|
||||
const hasStatus = (): boolean => {
|
||||
return !!status || !!color;
|
||||
};
|
||||
const hasStatus = (): boolean => (status !== null && status !== undefined) || (color !== null && color !== undefined);
|
||||
|
||||
const isZero = () => {
|
||||
const numberedDisplayCount = getNumberedDisplayCount();
|
||||
|
Loading…
Reference in New Issue
Block a user