@@ -216,6 +216,47 @@ describe('AutocompletePrompt', () => {
216216 expect ( result ) . to . equal ( 'apple' ) ;
217217 } ) ;
218218
219+ test ( 'options as function skips default filter' , ( ) => {
220+ const dynamicOptions = [
221+ { value : 'apple' , label : 'Apple' } ,
222+ { value : 'banana' , label : 'Banana' } ,
223+ ] ;
224+ const instance = new AutocompletePrompt ( {
225+ input,
226+ output,
227+ render : ( ) => 'foo' ,
228+ options : ( ) => dynamicOptions ,
229+ } ) ;
230+
231+ instance . prompt ( ) ;
232+
233+ input . emit ( 'keypress' , 'z' , { name : 'z' } ) ;
234+
235+ expect ( instance . filteredOptions ) . toEqual ( dynamicOptions ) ;
236+ } ) ;
237+
238+ test ( 'options as function applies user-provided filter' , ( ) => {
239+ const dynamicOptions = [
240+ { value : 'apple' , label : 'Apple' } ,
241+ { value : 'banana' , label : 'Banana' } ,
242+ { value : 'cherry' , label : 'Cherry' } ,
243+ ] ;
244+ const instance = new AutocompletePrompt ( {
245+ input,
246+ output,
247+ render : ( ) => 'foo' ,
248+ options : ( ) => dynamicOptions ,
249+ filter : ( search , opt ) => ( opt . label ?? '' ) . toLowerCase ( ) . endsWith ( search . toLowerCase ( ) ) ,
250+ } ) ;
251+
252+ instance . prompt ( ) ;
253+
254+ input . emit ( 'keypress' , 'a' , { name : 'a' } ) ;
255+
256+ // 'endsWith' matches Banana but not Apple or Cherry
257+ expect ( instance . filteredOptions ) . toEqual ( [ { value : 'banana' , label : 'Banana' } ] ) ;
258+ } ) ;
259+
219260 test ( 'Tab with non-matching placeholder does not fill input' , async ( ) => {
220261 const instance = new AutocompletePrompt ( {
221262 input,
0 commit comments