Skip to content

Add tests for search results components

Administrator requested to merge fa/searchresults-tests into master

Created by: attfarhan

This PR adds tests (not comprehensive) for components related to search results (SearchResults, SearchResultsList, FileMatch, CodeExcerpt).

It includes some small refactors and changes to make the components testable:

  • Add data-testid attributes
  • Move eventLogger and isSourcegraphDotCom to LayoutProps so that we pass both of these as props into components that need them. These both required access to the window global object, which we don't have when testing.
  • Add searchRequest to LayoutProps so the search request is passed in to SearchResults as a prop so that we can mock/spy the function.
  • Be explicit in only requiring the services field when extending ExtensionsControllerProps in SearchResultProps.

There are more tests I want to add that require more refactoring, so this is just the first few that were easy to add.

Total coverage progress:

Merge request reports

Loading