-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[tests] JavaScript: extract searchindex.js-format test fixtures. #12102
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
Changes from 5 commits
cf53a7c
311c4f0
e0bee37
4340bbe
40fc985
7e22d78
8f753a8
dd1fde8
695037d
58b5e90
c37bb53
8ac1b6c
e31a7bd
fbaff49
d619a52
b33d331
55b6072
ee4316d
0634502
0bc558a
a74bc15
a037867
68a6504
564de92
64ecd41
34752b1
1addb80
76cc8d5
d66b7a2
01a4509
262dcec
52ee7c4
916e5af
de6f7a0
ef8e4b0
450aafe
94b9fc5
d885288
6987c48
fac7694
a464bdf
5b6a479
fc76aef
e9614b9
4d62b15
38bfc34
51f9a4d
8c6c669
5827576
9773c0c
66328bc
7370d20
2ef85ba
cd1a368
7e4b562
ec4f236
9b709d7
3d108c1
1b59d03
d0125c7
fa64b98
0086771
3a6c784
14f1b98
d7e0e82
08460ca
2297164
9f5df2c
59d497d
cc8ee12
2cc1476
7e92842
9c0f2b2
7acb3cd
de00490
b8ab726
e66af4b
5c23157
ee2fd98
83fe92a
f9d6191
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| from sphinx.search import SearchLanguage, languages | ||
|
|
||
|
|
||
| class NullStemmedLanguage(SearchLanguage): | ||
|
|
||
| def split(self, input: str) -> list[str]: | ||
| return input.split() | ||
|
|
||
| def stem(self, word: str) -> str: | ||
| return word.lower() | ||
|
|
||
|
|
||
| languages["xx"] = NullStemmedLanguage | ||
| html_search_language = "xx" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| This is a sample C++ project used to generate a search engine index fixture. | ||
|
|
||
| .. cpp:class:: public Sphinx | ||
|
|
||
| The description of Sphinx class. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Main Page | ||
| ========= | ||
|
|
||
| Welcome to the... main page! | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,19 @@ | ||
| describe('Basic html theme search', function() { | ||
|
|
||
| function loadFixture(name) { | ||
picnixz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| req = new XMLHttpRequest(); | ||
| req.open("GET", `base/tests/js/fixtures/${name}`, false); | ||
| req.send(null); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm guessing you used Apparently using XMLHttpRequest this way is discouraged and might be deprecated at some point, but they've been saying that since 2014. 😉 It's probably fine.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, that's good to know :) Yep; we don't want the test to proceed until the fixture has definitely loaded -- I'm inclined to use a straightforward (even if seemingly dated) approach here. |
||
| return req.responseText; | ||
| } | ||
|
|
||
| describe('terms search', function() { | ||
|
|
||
| it('should find "C++" when in index', function() { | ||
| index = { | ||
| docnames:["index"], | ||
| filenames:["index.rst"], | ||
| terms:{'c++':0}, | ||
| titles:["<no title>"], | ||
| titleterms:{} | ||
| } | ||
| Search.setIndex(index); | ||
| searchindex = loadFixture("index.cpp.js"); | ||
jayaddison marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| eval(searchindex); | ||
picnixz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| index = Search._index; | ||
|
|
||
| searchterms = ['c++']; | ||
| excluded = []; | ||
| terms = index.terms; | ||
|
|
@@ -28,17 +31,9 @@ describe('Basic html theme search', function() { | |
| }); | ||
|
|
||
| it('should be able to search for multiple terms', function() { | ||
| index = { | ||
| alltitles: { | ||
| 'Main Page': [[0, 'main-page']], | ||
| }, | ||
| docnames:["index"], | ||
| filenames:["index.rst"], | ||
| terms:{main:0, page:0}, | ||
| titles:["Main Page"], | ||
| titleterms:{ main:0, page:0 } | ||
| } | ||
| Search.setIndex(index); | ||
| searchindex = loadFixture("index.multiterm.js"); | ||
| eval(searchindex); | ||
| index = Search._index; | ||
|
|
||
| searchterms = ['main', 'page']; | ||
| excluded = []; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.