Skip to content

Commit

Permalink
[HTML search] Add preparatory test coverage before anticipated partia…
Browse files Browse the repository at this point in the history
…l-search refactoring.
  • Loading branch information
jayaddison committed Jul 15, 2024
1 parent 1e13565 commit faa6d9b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/js/fixtures/partial/searchindex.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/js/roots/partial/index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sphinx_utils module
===================

Partial (also known as "prefix") matches on document titles should be possible
Partial matches on document titles and document terms should both be possible
using the JavaScript search functionality included when HTML documentation
projects are built.

Expand Down
18 changes: 18 additions & 0 deletions tests/js/searchtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,24 @@ describe('Basic html theme search', function() {
expect(Search.performTermsSearch(searchterms, excluded, terms, titleterms)).toEqual(hits);
});

it('should partially-match within "possible" when in term index', function() {
eval(loadFixture("partial/searchindex.js"));

[_searchQuery, searchterms, excluded, ..._remainingItems] = Search._parseQuery('ossibl');
terms = Search._index.terms;
titleterms = Search._index.titleterms;

hits = [[
"index",
"sphinx_utils module",
"",
null,
2,
"index.rst"
]];
expect(Search.performTermsSearch(searchterms, excluded, terms, titleterms)).toEqual(hits);
});

});

describe('aggregation of search results', function() {
Expand Down

0 comments on commit faa6d9b

Please sign in to comment.