File tree Expand file tree Collapse file tree 2 files changed +26
-16
lines changed Expand file tree Collapse file tree 2 files changed +26
-16
lines changed 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