/**
* Internal dependencies
*/
import {
getRegisteredBlocks,
registerCheckoutBlock,
innerBlockAreas,
} from '../index';
describe( 'checkout blocks registry', () => {
const component = () => {
return null;
};
describe( 'registerCheckoutBlock', () => {
const invokeTest = ( blockName, options ) => () => {
return registerCheckoutBlock( blockName, options );
it( 'throws an error when registered block is missing `blockName`', () => {
expect(
invokeTest( {
metadata: {
name: null,
parent: innerBlockAreas.CHECKOUT_FIELDS,
},
component,
} )
).toThrowError( /blockName/ );
name: '',
} );
it( 'throws an error when registered block is missing a valid parent', () => {
name: 'test/block-name',
parent: [],
).toThrowError( /parent/ );
parent: 'invalid-parent',
parent: [
'invalid-parent',
innerBlockAreas.CHECKOUT_FIELDS,
],
).not.toThrowError( /parent/ );
it( 'throws an error when registered block is missing `component`', () => {
).toThrowError( /component/ );
describe( 'getRegisteredBlocks', () => {
it( 'gets an empty array when checkout area has no registered blocks', () => {
getRegisteredBlocks( innerBlockAreas.CONTACT_INFORMATION )
).toEqual( [] );
it( 'gets an empty array when the area is not defined', () => {
expect( getRegisteredBlocks( 'not-defined' ) ).toEqual( [] );