diff --git a/test/tests/issues/203.js b/test/tests/issues/203.js new file mode 100644 index 0000000..54b96b8 --- /dev/null +++ b/test/tests/issues/203.js @@ -0,0 +1,45 @@ +const { parse } = require('@test/test-target'); + +// https://github.com/taoqf/node-html-parser/issues/203 +describe.only('issue 203', function () { + it('code element should not be null', function () { + const root = parse(`
type Foo = { foo: 'bar' }
`, {
+ blockTextElements: {
+ script: true,
+ noscript: true,
+ style: true,
+ }
+ });
+ const t = root.firstChild.firstChild.firstChild.firstChild;
+ t.toString().should.eql(`type Foo = { foo: 'bar' }
`);
+
+ const code = root.querySelector("code");
+ code.toString().should.eql(`type Foo = { foo: 'bar' }
`);
+ });
+ it('code element should not be null', function () {
+ const root = parse(` Country music legend, Trish Cotton, has something to say.
+
+ Written by Kyle Kasabian (@kylekasabian)
+ Directed by Derek Mari (@directorderek)
+ Director of Photography: Peter Mickelsen
+ Produced by Derek Mari and Kyle Kasabian
+ Edited by Derek Mari
+
Starring: Alyssa Sabo, Janine Hogan, and Kyle Kasabian
+
+ Assistant Camera: Casey Schoch
+ Production Sound: David Alvarez
+ Production Assistant: Keith Ahlstrom
+
Music by Morgan Matthews
+
+ Blink & Miss Productions
+ Bad Cat Films
+