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:
zhangchen 2020-08-26 11:27:07 +08:00 committed by GitHub
parent 507fdc44ae
commit 453eafe68d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -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(
<>

View File

@ -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();