mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-08 01:53:34 +08:00
fix: skeleton cannot dispaly without children
This commit is contained in:
parent
a67c0d28d3
commit
0b4a9682f9
@ -161,7 +161,7 @@ const Skeleton = (props: SkeletonProps) => {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return children as React.ReactElement;
|
return children ? children as React.ReactElement : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
Skeleton.defaultProps = {
|
Skeleton.defaultProps = {
|
||||||
|
@ -34,6 +34,11 @@ describe('Skeleton', () => {
|
|||||||
expect(wrapperSmall.render()).toMatchSnapshot();
|
expect(wrapperSmall.render()).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should display without children', () => {
|
||||||
|
const wrapper = mount(<Skeleton loading={false}></Skeleton>);
|
||||||
|
expect(wrapper.render()).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
it('should display children', () => {
|
it('should display children', () => {
|
||||||
const wrapper = mount(<Skeleton loading={false}>{[1, 2, 3]}</Skeleton>);
|
const wrapper = mount(<Skeleton loading={false}>{[1, 2, 3]}</Skeleton>);
|
||||||
expect(wrapper.text()).toBe('123');
|
expect(wrapper.text()).toBe('123');
|
||||||
|
Loading…
Reference in New Issue
Block a user