diff --git a/gutenberg b/gutenberg index 0773762250..27a6ead99b 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit 0773762250afaec366e58d4e9e19c52efa92519a +Subproject commit 27a6ead99b6ec38106c2b8696c74fe2a6e3d24d2 diff --git a/src/__tests__/paragraph.test.js b/src/__tests__/paragraph.test.js index ad42659b0f..e9dec36222 100644 --- a/src/__tests__/paragraph.test.js +++ b/src/__tests__/paragraph.test.js @@ -11,7 +11,6 @@ import Paragraph from '../../gutenberg/packages/block-library/src/paragraph/edit /** * WordPress dependencies */ -import { createBlock } from '@wordpress/blocks'; jest.mock( '@wordpress/blocks' ); const getTestComponentWithContent = ( content ) => { @@ -25,71 +24,9 @@ const getTestComponentWithContent = ( content ) => { ); }; -const getTestInstanceWithContent = ( content ) => { - return getTestComponentWithContent( content ).instance(); -}; - describe( 'Paragraph block', () => { it( 'renders without crashing', () => { const component = getTestComponentWithContent( '' ); expect( component.exists() ).toBe( true ); } ); - - it( 'splits empty block on Enter', () => { - // Given - const instance = getTestInstanceWithContent( '' ); - - const blocks = [ ]; - const before = ''; - const after = ''; - - // Mock implemenattion of `createBlock` to test against `insertBlocksAfter`. - const newBlock = { content: after }; - createBlock.mockImplementation( () => newBlock ); - - // When - instance.splitBlock( before, after, ...blocks ); - - // Then - - // Should ask for creating a new paragraph block. - expect( createBlock ).toHaveBeenCalledTimes( 1 ); - expect( createBlock ).toHaveBeenCalledWith( 'core/paragraph', { content: after } ); - - // New block is inserted after the current block. - expect( instance.props.insertBlocksAfter ).toHaveBeenCalledTimes( 1 ); - expect( instance.props.insertBlocksAfter ).toHaveBeenCalledWith( [ newBlock ] ); - } ); - - it( 'splits block on Enter with content on the middle', () => { - // Given - const before = 'Some text '; - const after = 'to split'; - const blocks = [ ]; - - const newBlock = { content: after }; - createBlock.mockImplementation( () => newBlock ); - - const instance = getTestInstanceWithContent( before + after ); - - // When - instance.splitBlock( before, after, ...blocks ); - - // Then - - // Do NOT remove current block - expect( instance.props.onReplace ).toHaveBeenCalledTimes( 0 ); - - // Should ask for creating a new paragraph block with the second half of the text. - expect( createBlock ).toHaveBeenCalledTimes( 1 ); - expect( createBlock ).toHaveBeenCalledWith( 'core/paragraph', { content: after } ); - - // Insert new block with the second half of the text - expect( instance.props.insertBlocksAfter ).toHaveBeenCalledTimes( 1 ); - expect( instance.props.insertBlocksAfter ).toHaveBeenCalledWith( [ newBlock ] ); - - // Replace current block content with first half of the text. - expect( instance.props.setAttributes ).toHaveBeenCalledTimes( 1 ); - expect( instance.props.setAttributes ).toHaveBeenCalledWith( { content: before } ); - } ); } ); diff --git a/symlinked-packages/@wordpress/data-controls b/symlinked-packages/@wordpress/data-controls new file mode 120000 index 0000000000..81123e6a18 --- /dev/null +++ b/symlinked-packages/@wordpress/data-controls @@ -0,0 +1 @@ +../../gutenberg/packages/data-controls/src \ No newline at end of file