-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
packages/block-library/src/verse/test/__snapshots__/transforms.native.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Verse block transforms to Columns block 1`] = ` | ||
"<!-- wp:columns --> | ||
<div class="wp-block-columns"><!-- wp:column {"width":"100%"} --> | ||
<div class="wp-block-column" style="flex-basis:100%"><!-- wp:verse {"textAlign":"center"} --> | ||
<pre class="wp-block-verse has-text-align-center">Come<br />Home.</pre> | ||
<!-- /wp:verse --></div> | ||
<!-- /wp:column --></div> | ||
<!-- /wp:columns -->" | ||
`; | ||
|
||
exports[`Verse block transforms to Group block 1`] = ` | ||
"<!-- wp:group {"layout":{"type":"constrained"}} --> | ||
<div class="wp-block-group"><!-- wp:verse {"textAlign":"center"} --> | ||
<pre class="wp-block-verse has-text-align-center">Come<br />Home.</pre> | ||
<!-- /wp:verse --></div> | ||
<!-- /wp:group -->" | ||
`; | ||
|
||
exports[`Verse block transforms to Paragraph block 1`] = ` | ||
"<!-- wp:paragraph --> | ||
<p>Come<br />Home.</p> | ||
<!-- /wp:paragraph -->" | ||
`; |
42 changes: 42 additions & 0 deletions
42
packages/block-library/src/verse/test/transforms.native.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { | ||
getEditorHtml, | ||
initializeEditor, | ||
setupCoreBlocks, | ||
transformBlock, | ||
getBlockTransformOptions, | ||
} from 'test/helpers'; | ||
|
||
const block = 'Verse'; | ||
const initialHtml = ` | ||
<!-- wp:verse {"textAlign":"center"} --> | ||
<pre class="wp-block-verse has-text-align-center">Come<br>Home.</pre> | ||
<!-- /wp:verse -->`; | ||
|
||
const transformsWithInnerBlocks = [ 'Columns', 'Group' ]; | ||
const blockTransforms = [ '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( 'matches expected transformation options', async () => { | ||
const screen = await initializeEditor( { initialHtml } ); | ||
const transformOptions = await getBlockTransformOptions( | ||
screen, | ||
block | ||
); | ||
expect( transformOptions ).toHaveLength( blockTransforms.length ); | ||
} ); | ||
} ); |