-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathmatchers.js
57 lines (46 loc) · 1.47 KB
/
matchers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* External dependencies
*/
import { parse } from 'hpq';
/**
* WordPress dependencies
*/
import { renderToString } from '@wordpress/element';
/**
* Internal dependencies
*/
import Editable from '../../editable';
import * as matchers from '../matchers';
describe( 'matchers', () => {
const html = '<blockquote><p>A delicious <b>sundae</b> dessert.</p><p>I want it!</p><footer>The Cook</footer></blockquote>';
describe( 'children()', () => {
it( 'should return a source function', () => {
const source = matchers.children();
expect( typeof source ).toBe( 'function' );
} );
it( 'should return HTML equivalent WPElement of matched element', () => {
// Assumption here is that we can cleanly convert back and forth
// between a string and WPElement representation
const match = parse( html, matchers.children() );
expect(
renderToString( <Editable.Value value={ match } /> )
).toBe( html );
} );
} );
describe( 'node()', () => {
it( 'should return a source function', () => {
const source = matchers.node();
expect( typeof source ).toBe( 'function' );
} );
it( 'should return HTML equivalent WPElement of matched element', () => {
// Assumption here is that we can cleanly convert back and forth
// between a string and WPElement representation
const match = parse( html, matchers.node() );
expect(
renderToString( <Editable.Value value={ [ match ] } /> )
).toBe(
`<body>${ html }</body>`
);
} );
} );
} );