Skip to content

Commit

Permalink
test: Paragraph should not remove whitespace when formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
dcalhoun committed Mar 27, 2023
1 parent a26b31f commit f8d228b
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions packages/block-library/src/paragraph/test/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,4 +385,34 @@ describe( 'Paragraph block', () => {

Clipboard.getString.mockReset();
} );

it( 'should not remove leading or trailing whitespace when formatting', async () => {
// Arrange
const screen = await initializeEditor();
await addBlock( screen, 'Paragraph' );
const [ paragraphBlock ] = screen.getAllByLabelText(
/Paragraph Block\. Row 1/
);

// Act
fireEvent.press( paragraphBlock );
const paragraphTextInput =
within( paragraphBlock ).getByPlaceholderText( 'Start writing…' );
changeAndSelectTextOfRichText(
paragraphTextInput,
' some text ',
{
selectionStart: 5,
selectionEnd: 14,
}
);
fireEvent.press( screen.getByLabelText( 'Italic' ) );

// Assert
expect( getEditorHtml() ).toMatchInlineSnapshot( `
"<!-- wp:paragraph -->
<p> <em>some text</em> </p>
<!-- /wp:paragraph -->"
` );
} );
} );

0 comments on commit f8d228b

Please sign in to comment.