File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -218,10 +218,12 @@ export function getChildNodes(node: HtmlNode | Node): (Node | HtmlNode)[] {
218218 }
219219}
220220
221+ /* istanbul ignore next */
221222export function perfStart ( label : string ) {
222223 if ( process . env . LOG_PERF ) console . time ( label ) ;
223224}
224225
226+ /* istanbul ignore next */
225227export function perfStop ( label : string ) {
226228 if ( process . env . LOG_PERF ) console . timeEnd ( label ) ;
227229}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import { parseHTML } from '../src/utilities' ;
2+ import { defaultOptions } from '../src/config' ;
3+ import { DOMParser } from 'linkedom' ;
4+
5+
6+ describe ( 'parseHTML' , ( ) => {
7+ test ( 'should parse HTML with native parser in browser' , ( ) => {
8+ __IS_BROWSER__ = true ;
9+ globalThis . DOMParser = < typeof globalThis . DOMParser > DOMParser ;
10+ const html = '<div>test</div>' ;
11+ const parsedHtml = parseHTML ( html , { ...defaultOptions , preferNativeParser : true } ) ;
12+ expect ( parsedHtml ) . toBeDefined ( ) ;
13+ __IS_BROWSER__ = false ;
14+ globalThis . DOMParser = < typeof globalThis . DOMParser > < unknown > undefined ;
15+ } ) ;
16+ test ( 'should parse HTML in node when preferNativeParser is true' , ( ) => { // This test fails
17+ const html = '<div>test</div>' ;
18+ const parsedHtml = parseHTML ( html , { ...defaultOptions , preferNativeParser : true } ) ;
19+ expect ( parsedHtml ) . toBeDefined ( ) ;
20+ } ) ;
21+ test ( 'should parse HTML in node when preferNativeParser is false' , ( ) => {
22+ const html = '<div>test</div>' ;
23+ const parsedHtml = parseHTML ( html , defaultOptions ) ;
24+ expect ( parsedHtml ) . toBeDefined ( ) ;
25+ } ) ;
26+ } ) ;
You can’t perform that action at this time.
0 commit comments