From 79ffa3597185bd0c7a02f797b8a7af71042fd70f Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Mon, 12 Sep 2016 20:25:41 +0800 Subject: [PATCH] Added a test for updated filterOptions --- test/Creatable-test.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/Creatable-test.js b/test/Creatable-test.js index 09144d5997..8eb1903aa3 100644 --- a/test/Creatable-test.js +++ b/test/Creatable-test.js @@ -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