import { describe, expect, it } from 'vitest'; import { parse } from 'hpq'; import { renderToString } from '@wordpress/element'; import * as sources from '../matchers'; describe( 'matchers', () => { describe( 'children()', () => { it( 'should return a source function', () => { const source = sources.children(); expect( console ).toHaveWarned(); expect( typeof source ).toBe( 'function' ); } ); it( 'should return HTML equivalent React Element of matched element', () => { // Assumption here is that we can cleanly convert back and forth // between a string and React Element representation. const html = '

A delicious sundae dessert

'; const match = parse( html, sources.children() ); expect( console ).toHaveWarned(); expect( renderToString( match as unknown as Parameters< typeof renderToString >[ 0 ] ) ).toBe( html ); } ); } ); describe( 'node()', () => { it( 'should return a source function', () => { const source = sources.node(); expect( console ).toHaveWarned(); expect( typeof source ).toBe( 'function' ); } ); it( 'should return HTML equivalent React Element of matched element', () => { // Assumption here is that we can cleanly convert back and forth // between a string and React Element representation. const html = '

A delicious sundae dessert

'; const match = parse( html, sources.node() ); expect( console ).toHaveWarned(); expect( renderToString( match as unknown as Parameters< typeof renderToString >[ 0 ] ) ).toBe( `${ html }` ); } ); } ); } );