Skip to content

Commit

Permalink
thisyahlen/chore: add test coverage for empty state (#8692)
Browse files Browse the repository at this point in the history
* chore: add test coverage for empty state

* chore: add test coverage for empty state

* fix: remove stores
  • Loading branch information
thisyahlen-deriv committed May 25, 2023
1 parent 1f5d6c2 commit de0a5ca
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
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) => {
return (
<div className='dw-empty-state'>
<Icon className='dw-empty-state__icon' icon={icon_name} size={128} />
Expand Down

0 comments on commit de0a5ca

Please sign in to comment.