From 6006c52c20e6c3c07405c808c8d81fa78425e794 Mon Sep 17 00:00:00 2001 From: taoqf Date: Thu, 17 Aug 2023 18:25:20 +0800 Subject: [PATCH] fix: #203 --- test/tests/issues/203.js | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 test/tests/issues/203.js 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 +

+
+ `,); + const description = root.querySelector('.description-wrapper'); + description.toString().should.not.eql(null); + }); +});