This commit is contained in:
KhaiNguyen
2020-02-13 10:39:37 +07:00
commit 59401cb805
12867 changed files with 4646216 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
/**
* Internal dependencies
*/
import { getRegisteredInnerBlocks, registerInnerBlock } from '../index';
describe( 'blocks registry', () => {
const main = '@woocommerce/all-products';
const blockName = '@woocommerce-extension/price-level';
const component = () => {};
describe( 'registerInnerBlock', () => {
const invokeTest = ( args ) => () => {
return registerInnerBlock( args );
};
it( 'throws an error when registered block is missing `main`', () => {
expect( invokeTest( { main: null } ) ).toThrowError( /main/ );
} );
it( 'throws an error when registered block is missing `blockName`', () => {
expect( invokeTest( { main, blockName: null } ) ).toThrowError(
/blockName/
);
} );
it( 'throws an error when registered block is missing `component`', () => {
expect(
invokeTest( { main, blockName, component: null } )
).toThrowError( /component/ );
} );
} );
describe( 'getRegisteredInnerBlocks', () => {
it( 'gets an empty object when parent has no inner blocks', () => {
expect(
getRegisteredInnerBlocks( '@woocommerce/all-products' )
).toEqual( {} );
} );
it( 'gets a block that was successfully registered', () => {
registerInnerBlock( { main, blockName, component } );
expect(
getRegisteredInnerBlocks( '@woocommerce/all-products' )
).toEqual( { [ blockName ]: component } );
} );
} );
} );