Skip to content

Commit

Permalink
fix: skeleton cannot dispaly without children
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertAZ1992 committed Apr 6, 2022
1 parent a67c0d2 commit 0b4a968
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion components/skeleton/Skeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const Skeleton = (props: SkeletonProps) => {
</div>
);
}
return children as React.ReactElement;
return children ? children as React.ReactElement : null;
};

Skeleton.defaultProps = {
Expand Down
5 changes: 5 additions & 0 deletions components/skeleton/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ describe('Skeleton', () => {
expect(wrapperSmall.render()).toMatchSnapshot();
});

it('should display without children', () => {
const wrapper = mount(<Skeleton loading={false}></Skeleton>);
expect(wrapper.render()).toMatchSnapshot();
});

it('should display children', () => {
const wrapper = mount(<Skeleton loading={false}>{[1, 2, 3]}</Skeleton>);
expect(wrapper.text()).toBe('123');
Expand Down

0 comments on commit 0b4a968

Please sign in to comment.