afc163
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
2 additions and
17 deletions
-
components/badge/__tests__/index.test.js
-
components/badge/index.tsx
|
|
@ -155,19 +155,6 @@ describe('Badge', () => { |
|
|
|
|
|
|
|
expect(wrapper.find('.ant-badge')).toHaveLength(2); |
|
|
|
}); |
|
|
|
|
|
|
|
it('Badge should work when status changes', () => { |
|
|
|
const wrapper = mount( |
|
|
|
<Badge status="warning"> |
|
|
|
<button type="button">Click me</button> |
|
|
|
</Badge>, |
|
|
|
); |
|
|
|
wrapper.setProps({ status: undefined }); |
|
|
|
|
|
|
|
expect(wrapper.find('.ant-badge-count')).toHaveLength(0); |
|
|
|
expect(wrapper.find('.ant-badge-dot')).toHaveLength(0); |
|
|
|
expect(wrapper.find('.ant-badge-count-sm')).toHaveLength(0); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
describe('Ribbon', () => { |
|
|
|
|
|
@ -94,8 +94,6 @@ const Badge: CompoundedComponent = ({ |
|
|
|
const isDotRef = useRef(showAsDot); |
|
|
|
if (!isHidden) { |
|
|
|
isDotRef.current = showAsDot; |
|
|
|
} else { |
|
|
|
isDotRef.current = false; |
|
|
|
} |
|
|
|
|
|
|
|
// =============================== Styles ===============================
|
|
|
@ -188,8 +186,8 @@ const Badge: CompoundedComponent = ({ |
|
|
|
|
|
|
|
const scrollNumberCls = classNames({ |
|
|
|
[`${prefixCls}-dot`]: isDot, |
|
|
|
[`${prefixCls}-count`]: !isDot && !isHidden, |
|
|
|
[`${prefixCls}-count-sm`]: !isDot && !isHidden && size === 'small', |
|
|
|
[`${prefixCls}-count`]: !isDot, |
|
|
|
[`${prefixCls}-count-sm`]: size === 'small', |
|
|
|
[`${prefixCls}-multiple-words`]: |
|
|
|
!isDot && displayCount && displayCount.toString().length > 1, |
|
|
|
[`${prefixCls}-status-${status}`]: !!status, |
|
|
|