Skip to content

Commit

Permalink
Test: Add test for registerBlockTypeFromMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Mar 30, 2021
1 parent adf60ab commit 1a6154e
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions packages/blocks/src/api/test/registration.js
Expand Up @@ -17,6 +17,7 @@ import { blockDefault as blockIcon } from '@wordpress/icons';
*/
import {
registerBlockType,
registerBlockTypeFromMetadata,
registerBlockCollection,
unregisterBlockCollection,
unregisterBlockType,
Expand Down Expand Up @@ -802,6 +803,40 @@ describe( 'blocks', () => {
} );
} );

describe( 'registerBlockTypeFromMetadata', () => {
test( 'registers block from metadata', () => {
const Edit = () => 'test';
const block = registerBlockTypeFromMetadata(
{
name: 'test/block-from-metadata',
title: 'Block from metadata',
category: 'text',
icon: 'palmtree',
},
{
edit: Edit,
save: noop,
}
);
expect( block ).toEqual( {
name: 'test/block-from-metadata',
title: 'Block from metadata',
category: 'text',
icon: {
src: 'palmtree',
},
keywords: [],
attributes: {},
providesContext: {},
usesContext: [],
supports: {},
styles: [],
edit: Edit,
save: noop,
} );
} );
} );

describe( 'registerBlockCollection()', () => {
it( 'creates a new block collection', () => {
registerBlockCollection( 'core', { title: 'Core' } );
Expand Down

0 comments on commit 1a6154e

Please sign in to comment.