forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Autocomplete] Use getOptionLabel over stringify (mui#19974)
- Loading branch information
1 parent
a6d129a
commit 048ca04
Showing
6 changed files
with
44 additions
and
29 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
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
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
26 changes: 26 additions & 0 deletions
26
packages/material-ui-lab/src/useAutocomplete/useAutocomplete.test.js
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,26 @@ | ||
import { expect } from 'chai'; | ||
import { createFilterOptions } from './useAutocomplete'; | ||
|
||
describe('createFilterOptions', () => { | ||
it('defaults to getOptionLabel for text filtering', () => { | ||
const filterOptions = createFilterOptions(); | ||
|
||
const getOptionLabel = option => option.name; | ||
const options = [ | ||
{ | ||
id: '1234', | ||
name: 'cat', | ||
}, | ||
{ | ||
id: '5678', | ||
name: 'dog', | ||
}, | ||
{ | ||
id: '9abc', | ||
name: 'emu', | ||
}, | ||
]; | ||
|
||
expect(filterOptions(options, { inputValue: 'a', getOptionLabel })).to.deep.equal([options[0]]); | ||
}); | ||
}); |