Skip to content

Commit d64bc0b

Browse files
committed
Update test per review comments
1 parent 2928586 commit d64bc0b

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

tests/js/searchtools.js

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,34 @@ describe('Basic html theme search', function() {
3232
});
3333

3434
describe("htmlToText", function() {
35+
36+
const testHTML = `<html>
37+
<div class="body" role="main">
38+
<section id="getting-started">
39+
<h1>Getting Started</h1>
40+
<p>Some text</p>
41+
</section>
42+
<section id="other-section">
43+
<h1>Other Section</h1>
44+
<p>Other text</p>
45+
</section>
46+
<section id="yet-another-section">
47+
<h1>Yet Another Section</h1>
48+
<p>More text</p>
49+
</section>
50+
</div>
51+
</html>`;
52+
3553
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']);
54+
expect(Search.htmlToText(testHTML).trim().split(/\s+/)).toEqual([
55+
'Getting', 'Started', 'Some', 'text',
56+
'Other', 'Section', 'Other', 'text',
57+
'Yet', 'Another', 'Section', 'More', 'text'
58+
]);
4559
});
4660

4761
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']);
62+
expect(Search.htmlToText(testHTML, '#other-section').trim().split(/\s+/)).toEqual(['Other', 'Section', 'Other', 'text']);
6163
});
6264
});
6365

0 commit comments

Comments
 (0)