Skip to content

Commit

Permalink
[Mobile] - Update Heading block E2E test (WordPress#46220)
Browse files Browse the repository at this point in the history
* Mobile - Add Heading block integration test with snapshot

* Mobile - Update Heading block empty snapshot

* Update HTML test content of reusable block

Co-authored-by: Carlos Garcia <fluiddot@gmail.com>
  • Loading branch information
2 people authored and mpkelly committed Dec 7, 2022
1 parent e004710 commit 78d00b6
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/block-library/src/block/test/edit.native.js
Expand Up @@ -23,7 +23,7 @@ const getMockedReusableBlock = ( id ) => ( {
content: {
raw: `
<!-- wp:heading -->
<h2>First Reusable block</h2>
<h2 class="wp-block-heading">First Reusable block</h2>
<!-- /wp:heading -->
<!-- wp:paragraph -->
Expand Down
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Heading block inserts block 1`] = `
"<!-- wp:heading -->
<h2 class=\\"wp-block-heading\\"></h2>
<!-- /wp:heading -->"
`;
44 changes: 44 additions & 0 deletions packages/block-library/src/heading/test/index.native.js
@@ -0,0 +1,44 @@
/**
* External dependencies
*/
import {
fireEvent,
getEditorHtml,
initializeEditor,
addBlock,
getBlock,
} from 'test/helpers';

/**
* WordPress dependencies
*/
import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
import { registerCoreBlocks } from '@wordpress/block-library';

beforeAll( () => {
// Register all core blocks
registerCoreBlocks();
} );

afterAll( () => {
// Clean up registered blocks
getBlockTypes().forEach( ( block ) => {
unregisterBlockType( block.name );
} );
} );

describe( 'Heading block', () => {
it( 'inserts block', async () => {
const screen = await initializeEditor();

// Add block
await addBlock( screen, 'Heading' );

// Get block
const headingBlock = await getBlock( screen, 'Heading' );
fireEvent.press( headingBlock );
expect( headingBlock ).toBeVisible();

expect( getEditorHtml() ).toMatchSnapshot();
} );
} );
Expand Up @@ -143,7 +143,7 @@ exports.audioBlockPlaceholder = `<!-- wp:audio {"id":5} -->
<!-- /wp:audio -->`;

exports.headerBlockEmpty = `<!-- wp:heading -->
<h2></h2>
<h2 class="wp-block-heading"></h2>
<!-- /wp:heading -->`;

exports.separatorBlockEmpty = `<!-- wp:separator -->
Expand Down

0 comments on commit 78d00b6

Please sign in to comment.