diff --git a/components/slot-fill/test/index.js b/components/slot-fill/test/index.js new file mode 100644 index 0000000000000..041c8337a34b7 --- /dev/null +++ b/components/slot-fill/test/index.js @@ -0,0 +1,28 @@ +/** + * External dependecies + */ +import { shallow } from 'enzyme'; + +/** + * Internal dependencies + */ +import { createSlotFill, Fill, Slot } from '../'; + +describe( 'createSlotFill', () => { + const SLOT_NAME = 'MyFill'; + const MyFill = createSlotFill( SLOT_NAME ); + + test( 'should match snapshot for Fill', () => { + const wrapper = shallow( ); + + expect( wrapper.type() ).toBe( Fill ); + expect( wrapper ).toHaveProp( 'name', SLOT_NAME ); + } ); + + test( 'should match snapshot for Slot', () => { + const wrapper = shallow( ); + + expect( wrapper.type() ).toBe( Slot ); + expect( wrapper ).toHaveProp( 'name', SLOT_NAME ); + } ); +} ); diff --git a/components/slot-fill/test/slot.js b/components/slot-fill/test/slot.js index 0fe7112f22bf9..3d84e9d5f0289 100644 --- a/components/slot-fill/test/slot.js +++ b/components/slot-fill/test/slot.js @@ -2,6 +2,7 @@ * External dependencies */ import { mount } from 'enzyme'; +import { isEmpty } from 'lodash'; /** * Internal dependencies @@ -103,6 +104,42 @@ describe( 'Slot', () => { expect( onClose ).toHaveBeenCalledTimes( 1 ); } ); + it( 'should render empty Fills without HTML wrapper when render props used', () => { + const element = mount( + + + { ( fills ) => ( ! isEmpty( fills ) && ( +
+ { fills } +
+ ) ) } +
+ +
+ ); + + expect( element.find( 'Slot > div' ).html() ).toBe( '
' ); + } ); + + it( 'should render a string Fill with HTML wrapper when render props used', () => { + const element = mount( + + + { ( fills ) => ( fills && ( +
+ { fills } +
+ ) ) } +
+ + content + +
+ ); + + expect( element.find( 'Slot > div' ).html() ).toBe( '
content
' ); + } ); + it( 'should re-render Slot when not bubbling virtually', () => { const element = mount( diff --git a/editor/components/block-inspector/index.js b/editor/components/block-inspector/index.js index 12ef69b4e4f2f..940311a2ee15e 100644 --- a/editor/components/block-inspector/index.js +++ b/editor/components/block-inspector/index.js @@ -1,6 +1,7 @@ /** * External dependencies */ +import { isEmpty } from 'lodash'; import { connect } from 'react-redux'; /** @@ -44,7 +45,7 @@ const BlockInspector = ( { selectedBlock, count } ) => { , , - { ( fills ) => fills.length && ( + { ( fills ) => ! isEmpty( fills ) && (