-
Notifications
You must be signed in to change notification settings - Fork 39
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
d736d1b
commit c0fcb43
Showing
4 changed files
with
53 additions
and
9 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
37 changes: 37 additions & 0 deletions
37
src/components/multiSearchInput/__tests__/multiSearchInput.test.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,37 @@ | ||
import * as React from 'react' | ||
import { render, fireEvent, cleanup } from '@testing-library/react' | ||
import MulSelectDropdown from '../index'; | ||
|
||
describe('mulSelectDropdown Component test', () => { | ||
afterEach(() => { | ||
cleanup() | ||
}) | ||
it('custom filter rendering', () => { | ||
const { queryByTestId } = render(<MulSelectDropdown filterOptions={['front', 'tail']}/>) | ||
expect(queryByTestId('icon-front')).not.toBeNull() | ||
expect(queryByTestId('icon-tail')).not.toBeNull() | ||
expect(queryByTestId('icon-caseSensitive')).toBeNull() | ||
expect(queryByTestId('icon-precise')).toBeNull() | ||
}) | ||
it('input value change', () => { | ||
const myMockChange = jest.fn((value) => value) | ||
const { queryByTestId } = render(<MulSelectDropdown | ||
searchType='tail' | ||
onChange={myMockChange} | ||
/>) | ||
fireEvent.change(queryByTestId('input'), { target: { value: '1234567891011' } }); | ||
expect(myMockChange).toHaveBeenCalled(); | ||
expect(myMockChange.mock.results[0].value).toBe('1234567891011'); | ||
}) | ||
it('input search', () => { | ||
const myMockSearch = jest.fn((value: any, searchType: any) => { return { value: value, searchType: searchType } }) | ||
const { queryByTestId } = render(<MulSelectDropdown | ||
searchType='tail' | ||
value="this is value" | ||
placeholder="hello" | ||
onSearch={myMockSearch} | ||
/>) | ||
fireEvent.keyPress(queryByTestId('input'), { key: 'Enter', code: 'Enter' }) | ||
expect(myMockSearch).toHaveBeenCalled(); | ||
}) | ||
}) |
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
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