Skip to content

Commit

Permalink
Added a test for updated filterOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
bvaughn committed Sep 12, 2016
1 parent 019f660 commit 79ffa35
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/Creatable-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,32 @@ describe('Creatable', () => {
expect(creatableNode.querySelector('.Select-menu-outer').textContent, 'not to equal', Select.Creatable.promptTextCreator('existing'));
});

it('should filter the "create..." prompt using both filtered options and currently-selected options', () => {
let isOptionUniqueParams;
createControl({
filterOptions: () => [
{ value: 'one', label: 'One' }
],
isOptionUnique: (params) => {
isOptionUniqueParams = params;
},
multi: true,
options: [
{ value: 'one', label: 'One' },
{ value: 'two', label: 'Two' }
],
value: [
{ value: 'three', label: 'Three' }
]
});
typeSearchText('test');
const { options } = isOptionUniqueParams;
const values = options.map(option => option.value);
expect(values, 'to have length', 2);
expect(values, 'to contain', 'one');
expect(values, 'to contain', 'three');
});

it('should not show a "create..." prompt if current filter text is not a valid option (as determined by :isValidNewOption prop)', () => {
createControl({
isValidNewOption: () => false
Expand Down

0 comments on commit 79ffa35

Please sign in to comment.