UNPKG

@gechiui/block-editor

Version:
69 lines (58 loc) 1.46 kB
/** * External dependencies */ import { noop } from 'lodash'; /** * GeChiUI dependencies */ import { applyFilters } from '@gechiui/hooks'; /** * Internal dependencies */ import '../generated-class-name'; describe( 'generated className', () => { const blockSettings = { name: 'chicken/ribs', save: noop, category: 'text', title: 'block title', }; describe( 'addSaveProps', () => { const addSaveProps = applyFilters.bind( null, 'blocks.getSaveContent.extraProps' ); it( 'should do nothing if the block settings do not define generated className support', () => { const attributes = { className: 'foo' }; const extraProps = addSaveProps( {}, { ...blockSettings, supports: { className: false, }, }, attributes ); expect( extraProps ).not.toHaveProperty( 'className' ); } ); it( 'should inject the generated className', () => { const attributes = { className: 'bar' }; const extraProps = addSaveProps( { className: 'foo' }, blockSettings, attributes ); expect( extraProps.className ).toBe( 'gc-block-chicken-ribs foo' ); } ); it( 'should not inject duplicates into className', () => { const attributes = { className: 'bar' }; const extraProps = addSaveProps( { className: 'foo gc-block-chicken-ribs' }, blockSettings, attributes ); expect( extraProps.className ).toBe( 'gc-block-chicken-ribs foo' ); } ); } ); } );