Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Apr 24, 2024
1 parent eb3bc5c commit 348e112
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/blocks/src/api/test/registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { select, dispatch } from '@wordpress/data';
import {
registerBlockType,
registerBlockCollection,
registerBlockVariation,
unregisterBlockCollection,
unregisterBlockType,
setFreeformContentHandlerName,
Expand All @@ -26,6 +27,7 @@ import {
getBlockType,
getBlockTypes,
getBlockSupport,
getBlockVariations,
hasBlockSupport,
isReusableBlock,
unstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase
Expand Down Expand Up @@ -1410,6 +1412,26 @@ describe( 'blocks', () => {
expect( isReusableBlock( block ) ).toBe( false );
} );
} );

describe( 'registerBlockVariation', () => {
it( 'should warn when registering block variation without a name', () => {
registerBlockType( 'core/variation-block', defaultBlockSettings );
registerBlockVariation( 'core/variation-block', {
title: 'Variation Title',
description: 'Variation description',
} );

expect( console ).toHaveWarnedWith(
'Variation names must be unique strings.'
);
expect( getBlockVariations( 'core/variation-block' ) ).toEqual( [
{
title: 'Variation Title',
description: 'Variation description',
},
] );
} );
} );
} );

/* eslint-enable react/forbid-elements */

0 comments on commit 348e112

Please sign in to comment.