@@ -278,7 +278,7 @@ describe('autocomplete-js', () => {
278
278
} ) ;
279
279
} ) ;
280
280
281
- test ( "doesn't render noResults template on no query when openOnFocus is false" , async ( ) => {
281
+ test ( "doesn't render noResults template on empty query when openOnFocus is false" , async ( ) => {
282
282
const container = document . createElement ( 'div' ) ;
283
283
const panelContainer = document . createElement ( 'div' ) ;
284
284
@@ -309,7 +309,7 @@ describe('autocomplete-js', () => {
309
309
310
310
const input = container . querySelector < HTMLInputElement > ( '.aa-Input' ) ;
311
311
312
- fireEvent . input ( input , { target : { value : '' } } ) ;
312
+ fireEvent . focus ( input ) ;
313
313
314
314
await waitFor ( ( ) => {
315
315
expect (
@@ -318,7 +318,47 @@ describe('autocomplete-js', () => {
318
318
} ) ;
319
319
} ) ;
320
320
321
- test ( 'render noResults template on query when openOnFocus is false' , async ( ) => {
321
+ test ( 'renders noResults template on empty query when openOnFocus is true' , async ( ) => {
322
+ const container = document . createElement ( 'div' ) ;
323
+ const panelContainer = document . createElement ( 'div' ) ;
324
+
325
+ document . body . appendChild ( panelContainer ) ;
326
+ autocomplete < { label : string } > ( {
327
+ container,
328
+ panelContainer,
329
+ openOnFocus : true ,
330
+ getSources ( ) {
331
+ return [
332
+ {
333
+ sourceId : 'testSource' ,
334
+ getItems ( ) {
335
+ return [ ] ;
336
+ } ,
337
+ templates : {
338
+ item ( { item } ) {
339
+ return item . label ;
340
+ } ,
341
+ noResults ( ) {
342
+ return 'No results template' ;
343
+ } ,
344
+ } ,
345
+ } ,
346
+ ] ;
347
+ } ,
348
+ } ) ;
349
+
350
+ const input = container . querySelector < HTMLInputElement > ( '.aa-Input' ) ;
351
+
352
+ fireEvent . focus ( input ) ;
353
+
354
+ await waitFor ( ( ) => {
355
+ expect (
356
+ panelContainer . querySelector < HTMLElement > ( '.aa-Panel' )
357
+ ) . toHaveTextContent ( 'No results template' ) ;
358
+ } ) ;
359
+ } ) ;
360
+
361
+ test ( 'renders noResults template on query when openOnFocus is false' , async ( ) => {
322
362
const container = document . createElement ( 'div' ) ;
323
363
const panelContainer = document . createElement ( 'div' ) ;
324
364
0 commit comments