Skip to content

Commit

Permalink
test: Fix List block split and merge tests
Browse files Browse the repository at this point in the history
Changes to the `onChangeAndSelectText` helper means text is appended by
default. To recreate merely placing the cursor in the beginning of the
text, we must re-type the text as the `onChangeAndSelectText` changes
the text in addition to selecting due to the selection logic invoking
change logic within `RichText`.
  • Loading branch information
dcalhoun committed Apr 11, 2023
1 parent 7c64ea8 commit 3f46924
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/block-library/src/list/test/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,10 @@ describe( 'List block', () => {
// backward delete
const listItemField =
within( listItemBlock ).getByLabelText( /Text input. .*Two.*/ );
changeAndSelectTextOfRichText( listItemField, 'Two' );
changeAndSelectTextOfRichText( listItemField, 'Two', {
initialSelectionStart: 0,
initialSelectionEnd: 3,
} );
fireEvent( listItemField, 'onKeyDown', {
nativeEvent: {},
preventDefault() {},
Expand Down Expand Up @@ -395,7 +398,10 @@ describe( 'List block', () => {
// backward delete
const listItemField =
within( listItemBlock ).getByLabelText( /Text input. .*One.*/ );
changeAndSelectTextOfRichText( listItemField, 'One' );
changeAndSelectTextOfRichText( listItemField, 'One', {
initialSelectionStart: 0,
initialSelectionEnd: 3,
} );
fireEvent( listItemField, 'onKeyDown', {
nativeEvent: {},
preventDefault() {},
Expand All @@ -406,11 +412,11 @@ describe( 'List block', () => {
"<!-- wp:paragraph -->
<p>A quick brown fox.</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>One</p>
<!-- /wp:paragraph -->
<!-- wp:list -->
<ul><!-- wp:list-item -->
<li>Two</li>
Expand Down

0 comments on commit 3f46924

Please sign in to comment.