@@ -582,42 +582,36 @@ describe( 'Searching for a link', () => {
582
582
expect ( mockFetchSearchSuggestions ) . not . toHaveBeenCalled ( ) ;
583
583
} ) ;
584
584
585
- it . each ( [
586
- [ 'couldbeurlorentitysearchterm' ] ,
587
- [ 'ThisCouldAlsoBeAValidURL' ] ,
588
- ] ) (
589
- 'should display a URL suggestion as a default fallback for the search term "%s" which could potentially be a valid url.' ,
590
- async ( searchTerm ) => {
591
- const user = userEvent . setup ( ) ;
592
- render ( < LinkControl /> ) ;
585
+ it ( 'should not display a URL suggestion when input is not likely to be a URL.' , async ( ) => {
586
+ const searchTerm = 'unlikelytobeaURL' ;
587
+ const user = userEvent . setup ( ) ;
588
+ render ( < LinkControl /> ) ;
593
589
594
- // Search Input UI.
595
- const searchInput = screen . getByRole ( 'combobox' , { name : 'URL' } ) ;
590
+ // Search Input UI.
591
+ const searchInput = screen . getByRole ( 'combobox' , { name : 'URL' } ) ;
596
592
597
- // Simulate searching for a term.
598
- await user . type ( searchInput , searchTerm ) ;
593
+ // Simulate searching for a term.
594
+ await user . type ( searchInput , searchTerm ) ;
599
595
600
- const searchResultElements = within (
601
- await screen . findByRole ( 'listbox' , {
602
- name : / S e a r c h r e s u l t s f o r .* / ,
603
- } )
604
- ) . getAllByRole ( 'option' ) ;
596
+ const searchResultElements = within (
597
+ await screen . findByRole ( 'listbox' , {
598
+ name : / S e a r c h r e s u l t s f o r .* / ,
599
+ } )
600
+ ) . getAllByRole ( 'option' ) ;
605
601
606
- const lastSearchResultItem =
607
- searchResultElements [ searchResultElements . length - 1 ] ;
602
+ const lastSearchResultItem =
603
+ searchResultElements [ searchResultElements . length - 1 ] ;
608
604
609
- // We should see a search result for each of the expect search suggestions.
610
- expect ( searchResultElements ) . toHaveLength (
611
- fauxEntitySuggestions . length
612
- ) ;
605
+ // We should see a search result for each of the expect search suggestions.
606
+ expect ( searchResultElements ) . toHaveLength (
607
+ fauxEntitySuggestions . length
608
+ ) ;
613
609
614
- // The URL search suggestion should not exist.
615
- expect ( lastSearchResultItem ) . not . toHaveTextContent ( searchTerm ) ;
616
- expect ( lastSearchResultItem ) . not . toHaveTextContent (
617
- 'Press ENTER to add this link'
618
- ) ;
619
- }
620
- ) ;
610
+ // The URL search suggestion should not exist.
611
+ expect ( lastSearchResultItem ) . not . toHaveTextContent (
612
+ 'Press ENTER to add this link'
613
+ ) ;
614
+ } ) ;
621
615
622
616
it ( 'should not display a URL suggestion as a default fallback when noURLSuggestion is passed.' , async ( ) => {
623
617
const user = userEvent . setup ( ) ;
0 commit comments