forked from deriv-com/deriv-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test case for notify-item (deriv-com#11003)
* test: add test case for notify-item * test: add test case scenarios for notify-item
- Loading branch information
1 parent
29d3c01
commit 02af38b
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
packages/bot-web-ui/src/components/notify-item/__tests__/notify-item.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import { messageWithButton, messageWithImage, getIcon } from '../notify-item'; | ||
import userEvent from '@testing-library/user-event'; | ||
|
||
const messageWithButtonMockProps = { | ||
unique_id: '123', | ||
type: 'error', | ||
message: 'sample text', | ||
btn_text: 'ok', | ||
onClick: jest.fn(), | ||
}; | ||
|
||
describe('messageWithButtonMockProps', () => { | ||
it('should render messageWithButton', () => { | ||
const { container } = render(messageWithButton({ ...messageWithButtonMockProps })); | ||
expect(container).toBeInTheDocument(); | ||
expect(screen.getByText('sample text')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should call function of the button on click of the button', () => { | ||
render(messageWithButton({ ...messageWithButtonMockProps })); | ||
userEvent.click(screen.getByRole('button')); | ||
expect(messageWithButtonMockProps.onClick).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should get appropriate icon when getIcon is called', () => { | ||
expect(getIcon('warn')).toEqual('IcAlertWarning'); | ||
expect(getIcon('info')).toEqual('IcAlertInfo'); | ||
expect(getIcon('error')).toEqual('IcAlertDanger'); | ||
expect(getIcon('')).toEqual('IcAlertWarning'); | ||
}); | ||
|
||
it('should render messageWithImage', () => { | ||
const { container } = render(messageWithImage('sample text', '')); | ||
expect(container).toBeInTheDocument(); | ||
expect(screen.getByText('sample text')).toBeInTheDocument(); | ||
expect(screen.getByRole('img')).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters