Skip to content

Commit e7a0a9d

Browse files
committed
Update test to make sense in context of #51011
See #51011
1 parent a3fc1b6 commit e7a0a9d

File tree

1 file changed

+24
-30
lines changed

1 file changed

+24
-30
lines changed

packages/block-editor/src/components/link-control/test/index.js

+24-30
Original file line numberDiff line numberDiff line change
@@ -582,42 +582,36 @@ describe( 'Searching for a link', () => {
582582
expect( mockFetchSearchSuggestions ).not.toHaveBeenCalled();
583583
} );
584584

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 /> );
593589

594-
// Search Input UI.
595-
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
590+
// Search Input UI.
591+
const searchInput = screen.getByRole( 'combobox', { name: 'URL' } );
596592

597-
// Simulate searching for a term.
598-
await user.type( searchInput, searchTerm );
593+
// Simulate searching for a term.
594+
await user.type( searchInput, searchTerm );
599595

600-
const searchResultElements = within(
601-
await screen.findByRole( 'listbox', {
602-
name: /Search results for.*/,
603-
} )
604-
).getAllByRole( 'option' );
596+
const searchResultElements = within(
597+
await screen.findByRole( 'listbox', {
598+
name: /Search results for.*/,
599+
} )
600+
).getAllByRole( 'option' );
605601

606-
const lastSearchResultItem =
607-
searchResultElements[ searchResultElements.length - 1 ];
602+
const lastSearchResultItem =
603+
searchResultElements[ searchResultElements.length - 1 ];
608604

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+
);
613609

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+
} );
621615

622616
it( 'should not display a URL suggestion as a default fallback when noURLSuggestion is passed.', async () => {
623617
const user = userEvent.setup();

0 commit comments

Comments
 (0)