Skip to content

Commit

Permalink
HTML search: add test coverage on partial-matching
Browse files Browse the repository at this point in the history
  • Loading branch information
jayaddison committed Aug 11, 2024
1 parent c3c8a23 commit 7274236
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.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,24 @@ describe('Basic html theme search', function() {
expect(Search.performTermsSearch(searchterms, excluded)).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 7274236

Please sign in to comment.