-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
HTML Search: Use anchor for search preview #11944
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 all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,38 @@ describe('Basic html theme search', function() { | |
|
|
||
| }); | ||
|
|
||
| describe("htmlToText", function() { | ||
|
|
||
| const testHTML = `<html> | ||
| <div class="body" role="main"> | ||
| <section id="getting-started"> | ||
| <h1>Getting Started</h1> | ||
| <p>Some text</p> | ||
| </section> | ||
| <section id="other-section"> | ||
| <h1>Other Section</h1> | ||
| <p>Other text</p> | ||
| </section> | ||
| <section id="yet-another-section"> | ||
| <h1>Yet Another Section</h1> | ||
| <p>More text</p> | ||
| </section> | ||
| </div> | ||
| </html>`; | ||
|
|
||
| it("basic case", () => { | ||
| expect(Search.htmlToText(testHTML).trim().split(/\s+/)).toEqual([ | ||
|
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 have some ideas about the reason, but just to check they match reality: why are we testing
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. I think it's easier to test the lower-level construct to verify that it doesn't have any bugs. makeSearchSummary has a bunch of magic numbers and heuristics in it which seems much more subject to change. |
||
| 'Getting', 'Started', 'Some', 'text', | ||
| 'Other', 'Section', 'Other', 'text', | ||
| 'Yet', 'Another', 'Section', 'More', 'text' | ||
| ]); | ||
| }); | ||
|
|
||
| it("will start reading from the anchor", () => { | ||
| expect(Search.htmlToText(testHTML, '#other-section').trim().split(/\s+/)).toEqual(['Other', 'Section', 'Other', 'text']); | ||
|
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. Is the If so, an alternative could be to make a less-restrictive assertion; something like
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. That's right, just trying not to test whitespace. I think I prefer to check for all the tokens in the output, feels more comprehensive to me. |
||
| }); | ||
| }); | ||
|
|
||
| // This is regression test for https://github.com/sphinx-doc/sphinx/issues/3150 | ||
| describe('splitQuery regression tests', () => { | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.