Skip to content

Commit 3bec276

Browse files
committed
add test
1 parent 420044b commit 3bec276

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/js/searchtools.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,36 @@ describe('Basic html theme search', function() {
3131

3232
});
3333

34+
describe("htmlToText", function() {
35+
it("basic case", () => {
36+
expect(Search.htmlToText(`
37+
<html>
38+
<div class="body" role="main">
39+
<section id="getting-started">
40+
<h1>Getting Started</h1>
41+
<p>Some text</p>
42+
</section>
43+
</div>
44+
</html>`).trim().split(/\s+/)).toEqual(['Getting', 'Started', 'Some', 'text']);
45+
});
46+
47+
it("will start reading from the anchor", () => {
48+
expect(Search.htmlToText(`
49+
<html>
50+
<div class="body" role="main">
51+
<section id="getting-started">
52+
<h1>Getting Started</h1>
53+
<p>Some text</p>
54+
</section>
55+
<section id="other-section">
56+
<h1>Other Section</h1>
57+
<p>Other text</p>
58+
</section>
59+
</div>
60+
</html>`, '#other-section').trim().split(/\s+/)).toEqual(['Other', 'Section', 'Other', 'text']);
61+
});
62+
});
63+
3464
// This is regression test for https://github.com/sphinx-doc/sphinx/issues/3150
3565
describe('splitQuery regression tests', () => {
3666

0 commit comments

Comments
 (0)