Skip to content

Commit

Permalink
test: Simplify tests with new helpers
Browse files Browse the repository at this point in the history
It is no longer necessary to pass the length of the test strings as the
new helper automatically tracks the string length to place the cursor at
the end of the new value, mimicking a user typing.
  • Loading branch information
dcalhoun committed Apr 14, 2023
1 parent 88d67af commit 291b2fa
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 11 deletions.
3 changes: 1 addition & 2 deletions packages/block-library/src/preformatted/test/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ describe( 'Preformatted', () => {
const preformattedTextInput = await screen.findByPlaceholderText(
'Write preformatted text…'
);
const string = 'A great statement.';
typeInRichText( preformattedTextInput, string );
typeInRichText( preformattedTextInput, 'A great statement.' );
fireEvent( preformattedTextInput, 'onKeyDown', {
nativeEvent: {},
preventDefault() {},
Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/pullquote/test/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ describe( 'Pullquote', () => {
fireEvent.press( pullquoteBlock );
const pullquoteTextInput =
within( pullquoteBlock ).getByPlaceholderText( 'Add quote' );
const string = 'A great statement.';
typeInRichText( pullquoteTextInput, string );
typeInRichText( pullquoteTextInput, 'A great statement.' );
fireEvent( pullquoteTextInput, 'onKeyDown', {
nativeEvent: {},
preventDefault() {},
Expand Down
6 changes: 1 addition & 5 deletions packages/block-library/src/quote/test/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ describe( 'Quote', () => {
// screen.debug();
let quoteTextInput =
within( quoteBlock ).getByPlaceholderText( 'Start writing…' );
const string = 'A great statement.';
typeInRichText( quoteTextInput, string, {
selectionStart: string.length,
selectionEnd: string.length,
} );
typeInRichText( quoteTextInput, 'A great statement.' );
fireEvent( quoteTextInput, 'onKeyDown', {
nativeEvent: {},
preventDefault() {},
Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/verse/test/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ describe( 'Verse block', () => {
const verseTextInput = await screen.findByPlaceholderText(
'Write verse…'
);
const string = 'A great statement.';
typeInRichText( verseTextInput, string );
typeInRichText( verseTextInput, 'A great statement.' );
fireEvent( verseTextInput, 'onKeyDown', {
nativeEvent: {},
preventDefault() {},
Expand Down

0 comments on commit 291b2fa

Please sign in to comment.