UNPKG

@wordpress/block-library

Version:
41 lines (35 loc) 1.13 kB
/** * External dependencies */ import { getEditorHtml, initializeEditor, setupCoreBlocks, transformBlock, getBlockTransformOptions, } from 'test/helpers'; const block = 'Search'; const initialHtml = ` <!-- wp:search {"label":"Search","buttonText":"Search"} /-->`; const transformsWithInnerBlocks = [ 'Columns', 'Group' ]; const blockTransforms = [ ...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( 'matches expected transformation options', async () => { const screen = await initializeEditor( { initialHtml } ); const transformOptions = await getBlockTransformOptions( screen, block ); expect( transformOptions ).toHaveLength( blockTransforms.length ); } ); } );