File tree Expand file tree Collapse file tree 2 files changed +24
-16
lines changed Expand file tree Collapse file tree 2 files changed +24
-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+ } ) ;
14+ test ( 'should parse HTML in node when preferNativeParser is true' , ( ) => { // This test fails
15+ const html = '<div>test</div>' ;
16+ const parsedHtml = parseHTML ( html , { ...defaultOptions , preferNativeParser : true } ) ;
17+ expect ( parsedHtml ) . toBeDefined ( ) ;
18+ } ) ;
19+ test ( 'should parse HTML in node when preferNativeParser is false' , ( ) => {
20+ const html = '<div>test</div>' ;
21+ const parsedHtml = parseHTML ( html , defaultOptions ) ;
22+ expect ( parsedHtml ) . toBeDefined ( ) ;
23+ } ) ;
24+ } ) ;
You can’t perform that action at this time.
0 commit comments