Skip to content

Commit

Permalink
Add e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Nov 22, 2019
1 parent 5500264 commit 3e423f4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/block-editor/src/store/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export default {
selectedBlock.attributes[ attributeKey ] = toHTMLString( {
value,
multilineTag,
preserveWhiteSpace,
} );
}

Expand Down Expand Up @@ -173,7 +174,11 @@ export default {
} );
const newOffset = convertedValue.text.indexOf( START_OF_SELECTED_AREA );
const newValue = remove( convertedValue, newOffset, newOffset + 1 );
const newHtml = toHTMLString( { value: newValue, multilineTag } );
const newHtml = toHTMLString( {
value: newValue,
multilineTag,
preserveWhiteSpace,
} );

updatedAttributes[ newAttributeKey ] = newHtml;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,11 @@ exports[`Preformatted should preserve character newlines 2`] = `
2</pre>
<!-- /wp:preformatted -->"
`;
exports[`Preformatted should preserve white space when merging 1`] = `
"<!-- wp:preformatted -->
<pre class=\\"wp-block-preformatted\\">1
2
3</pre>
<!-- /wp:preformatted -->"
`;
14 changes: 14 additions & 0 deletions packages/e2e-tests/specs/editor/blocks/preformatted.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,18 @@ describe( 'Preformatted', () => {

expect( await getEditedPostContent() ).toMatchSnapshot();
} );

it( 'should preserve white space when merging', async () => {
await insertBlock( 'Preformatted' );
await page.keyboard.type( '1' );
await page.keyboard.press( 'Enter' );
await page.keyboard.type( '2' );
await page.keyboard.press( 'Enter' );
await page.keyboard.press( 'Tab' );
await page.keyboard.type( '3' );
await page.keyboard.press( 'ArrowLeft' );
await page.keyboard.press( 'Backspace' );

expect( await getEditedPostContent() ).toMatchSnapshot();
} );
} );
2 changes: 2 additions & 0 deletions packages/rich-text/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ _Parameters_
- _$1.range_ `[Range]`: Range to create value from.
- _$1.multilineTag_ `[string]`: Multiline tag if the structure is multiline.
- _$1.multilineWrapperTags_ `[Array]`: Tags where lines can be found if nesting is possible.
- _$1.preserveWhiteSpace_ `[?boolean]`: Whether or not to collapse white space characters.

_Returns_

Expand Down Expand Up @@ -328,6 +329,7 @@ _Parameters_
- _$1_ `Object`: Named argements.
- _$1.value_ `Object`: Rich text value.
- _$1.multilineTag_ `[string]`: Multiline tag.
- _$1.preserveWhiteSpace_ `[?boolean]`: Whether or not to use newline characters for line breaks.

_Returns_

Expand Down

0 comments on commit 3e423f4

Please sign in to comment.