-
Notifications
You must be signed in to change notification settings - Fork 4.4k
/
Copy pathtransforms.native.js
69 lines (60 loc) · 2.13 KB
/
transforms.native.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
58
59
60
61
62
63
64
65
66
67
68
69
/**
* External dependencies
*/
import {
getEditorHtml,
initializeEditor,
setupCoreBlocks,
transformBlock,
getBlock,
openBlockActionsMenu,
fireEvent,
getBlockTransformOptions,
} from 'test/helpers';
const block = 'Quote';
const initialHtml = `
<!-- wp:quote {"align":"left","className":"is-style-large"} -->
<blockquote class="wp-block-quote has-text-align-left is-style-large"><!-- wp:paragraph -->
<p>"This will make running your own blog a viable alternative again."</p>
<!-- /wp:paragraph --><cite>— <a href="https://twitter.com/azumbrunnen_/status/1019347243084800005">Adrian Zumbrunnen</a></cite></blockquote>
<!-- /wp:quote -->`;
const transformsWithInnerBlocks = [ 'Columns', 'Group' ];
const blockTransforms = [
'Pullquote',
'Paragraph',
...transformsWithInnerBlocks,
];
setupCoreBlocks();
describe( `${ block } block transforms`, () => {
test.each( blockTransforms )( 'to %s block', async ( blockTransform ) => {
const screen = await initializeEditor( { initialHtml } );
const newBlock = await transformBlock( screen, block, blockTransform, {
hasInnerBlocks:
transformsWithInnerBlocks.includes( blockTransform ),
} );
expect( newBlock ).toBeVisible();
expect( getEditorHtml() ).toMatchSnapshot();
} );
it( 'ungroups block', async () => {
const screen = await initializeEditor( { initialHtml } );
const { getByText } = screen;
fireEvent.press( getBlock( screen, block ) );
await openBlockActionsMenu( screen );
fireEvent.press( getByText( 'Ungroup' ) );
// The first block created is the content of the Paragraph block.
const paragraph = getBlock( screen, 'Paragraph', 0 );
expect( paragraph ).toBeVisible();
// The second block created is the content of the citation element.
const citation = getBlock( screen, 'Paragraph', 1 );
expect( citation ).toBeVisible();
expect( getEditorHtml() ).toMatchSnapshot();
} );
it( 'matches expected transformation options', async () => {
const screen = await initializeEditor( { initialHtml } );
const transformOptions = await getBlockTransformOptions(
screen,
block
);
expect( transformOptions ).toHaveLength( blockTransforms.length );
} );
} );