mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-29 13:47:02 +08:00
fix: skeleton cannot dispaly without children and loading props : Skeleton(...) return nothing (#34872)
* fix: skeleton cannot dispaly without children
* [CodeFactor] Apply fixes to commit 0b4a968
[ci skip] [skip ci]
* fix: update skeleton
Co-authored-by: codefactor-io <support@codefactor.io>
This commit is contained in:
parent
d49013468a
commit
b3e66762d6
@ -161,7 +161,7 @@ const Skeleton = (props: SkeletonProps) => {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return children as React.ReactElement;
|
||||
return typeof children !== 'undefined' ? (children as React.ReactElement) : null;
|
||||
};
|
||||
|
||||
Skeleton.defaultProps = {
|
||||
|
@ -481,6 +481,8 @@ exports[`Skeleton rtl render component should be rendered correctly in RTL direc
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Skeleton should display without children and falsy loading props 1`] = `null`;
|
||||
|
||||
exports[`Skeleton should round title and paragraph 1`] = `
|
||||
<div
|
||||
class="ant-skeleton ant-skeleton-round"
|
||||
|
@ -34,6 +34,16 @@ describe('Skeleton', () => {
|
||||
expect(wrapperSmall.render()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should display without children and falsy loading props', () => {
|
||||
const wrapper = mount(<Skeleton loading={false} />);
|
||||
expect(wrapper.render()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should display with empty children and falsy loading props', () => {
|
||||
const wrapper = mount(<Skeleton loading={false}>{0}</Skeleton>);
|
||||
expect(wrapper.text()).toBe('0');
|
||||
});
|
||||
|
||||
it('should display children', () => {
|
||||
const wrapper = mount(<Skeleton loading={false}>{[1, 2, 3]}</Skeleton>);
|
||||
expect(wrapper.text()).toBe('123');
|
||||
|
Loading…
Reference in New Issue
Block a user