File tree 3 files changed +28
-16
lines changed
3 files changed +28
-16
lines changed Original file line number Diff line number Diff line change @@ -218,10 +218,12 @@ export function getChildNodes(node: HtmlNode | Node): (Node | HtmlNode)[] {
218
218
}
219
219
}
220
220
221
+ /* istanbul ignore next */
221
222
export function perfStart ( label : string ) {
222
223
if ( process . env . LOG_PERF ) console . time ( label ) ;
223
224
}
224
225
226
+ /* istanbul ignore next */
225
227
export function perfStop ( label : string ) {
226
228
if ( process . env . LOG_PERF ) console . timeEnd ( label ) ;
227
229
}
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