-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe240ae
commit accbe28
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
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,54 @@ | ||
import React from 'react'; | ||
import { fireEvent, render } from '../../test'; | ||
|
||
import Tag from './Tag'; | ||
|
||
const handleSelect = jest.fn(); | ||
const handleClear = jest.fn(); | ||
|
||
describe('Tag', () => { | ||
test('that on selectable Tag the onSelect handler is being called', () => { | ||
const { getByTestId } = render( | ||
<Tag onSelect={handleSelect} dataTestPrefixId="test"> | ||
Tag | ||
</Tag> | ||
); | ||
|
||
const tag = getByTestId('test_tag_container'); | ||
expect(tag).toBeInTheDocument(); | ||
|
||
fireEvent.click(tag); | ||
|
||
expect(handleSelect).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
test('that selectable Tag is rendered correctly when selected', () => { | ||
const { getByTestId } = render( | ||
<Tag onSelect={handleSelect} isSelected dataTestPrefixId="test"> | ||
Tag | ||
</Tag> | ||
); | ||
const tag = getByTestId('test_tag_container'); | ||
expect(tag).toBeInTheDocument(); | ||
|
||
const tagCheck = getByTestId('test_tag_prefix'); | ||
expect(tagCheck).toBeInTheDocument(); | ||
}); | ||
|
||
test('that on clearable Tag the onClear handler is being called', () => { | ||
const { getByTestId } = render( | ||
<Tag onClear={handleClear} dataTestPrefixId="test"> | ||
Tag | ||
</Tag> | ||
); | ||
const tag = getByTestId('test_tag_container'); | ||
expect(tag).toBeInTheDocument(); | ||
|
||
const tagClear = getByTestId('test_tag_suffix'); | ||
expect(tagClear).toBeInTheDocument(); | ||
|
||
fireEvent.click(tagClear); | ||
|
||
expect(handleClear).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |