Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thisyahlen/chore: add test coverage for empty state #8692

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from 'react';
import EmptyState from '../empty-state';
import { render, screen } from '@testing-library/react';

describe('EmptyState', () => {
it('should render correctly', () => {
const { container } = render(
<EmptyState
icon_name='icon_name'
renderMessage={() => (
<>
<p>Message</p>
<p>Some content</p>
</>
)}
renderTitle={() => <p>Title</p>}
/>
);
expect(container).toBeInTheDocument();
});

it('should render correctly with the correct text', () => {
const { container } = render(
<EmptyState
icon_name='icon_name'
renderMessage={() => (
<>
<p>Message</p>
<p>Some content</p>
</>
)}
renderTitle={() => <p>Title</p>}
/>
);

expect(container).toBeInTheDocument();
expect(screen.getByText('Message')).toBeInTheDocument();
expect(screen.getByText('Some content')).toBeInTheDocument();
expect(screen.getByText('Title')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type TProps = {
renderTitle: () => React.ReactNode;
};

const EmptyState: React.FC<TProps> = ({ icon_name, renderMessage, renderTitle }) => {
const EmptyState = ({ icon_name, renderMessage, renderTitle }: TProps) => {
thisyahlen-deriv marked this conversation as resolved.
Show resolved Hide resolved
return (
<div className='dw-empty-state'>
<Icon className='dw-empty-state__icon' icon={icon_name} size={128} />
Expand Down