Skip to content

Commit 6006c52

Browse files
committed
fix: #203
1 parent 6f6c824 commit 6006c52

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

test/tests/issues/203.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
const { parse } = require('@test/test-target');
2+
3+
// https://github.com/taoqf/node-html-parser/issues/203
4+
describe.only('issue 203', function () {
5+
it('code element should not be null', function () {
6+
const root = parse(`<html><body><pre><code class="language-typescript">type Foo = { foo: 'bar' }</code></pre></body></html>`, {
7+
blockTextElements: {
8+
script: true,
9+
noscript: true,
10+
style: true,
11+
}
12+
});
13+
const t = root.firstChild.firstChild.firstChild.firstChild;
14+
t.toString().should.eql(`<code class="language-typescript">type Foo = { foo: 'bar' }</code>`);
15+
16+
const code = root.querySelector("code");
17+
code.toString().should.eql(`<code class="language-typescript">type Foo = { foo: 'bar' }</code>`);
18+
});
19+
it('code element should not be null', function () {
20+
const root = parse(` <div class="clip_details-description description-wrapper iris_desc">
21+
<p class="first">Country music legend, Trish Cotton, has something to say.</p>
22+
<p>
23+
Written by Kyle Kasabian (@kylekasabian) <br />
24+
Directed by Derek Mari (@directorderek)<br />
25+
Director of Photography: Peter Mickelsen<br />
26+
Produced by Derek Mari and Kyle Kasabian<br />
27+
Edited by Derek Mari
28+
</p>
29+
<p>Starring: Alyssa Sabo, Janine Hogan, and Kyle Kasabian</p>
30+
<p>
31+
Assistant Camera: Casey Schoch<br />
32+
Production Sound: David Alvarez<br />
33+
Production Assistant: Keith Ahlstrom
34+
</p>
35+
<p>Music by Morgan Matthews</p>
36+
<p>
37+
Blink &amp; Miss Productions<br />
38+
Bad Cat Films
39+
</p>
40+
</div>
41+
</div>`,);
42+
const description = root.querySelector('.description-wrapper');
43+
description.toString().should.not.eql(null);
44+
});
45+
});

0 commit comments

Comments
 (0)