Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HTML search] Add test coverage to prepare for anticipated partial-match refactoring. #12592

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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