Skip to content

Commit

Permalink
Add example with special characters
Browse files Browse the repository at this point in the history
  • Loading branch information
ciampo committed Aug 23, 2022
1 parent 1fff738 commit 9435de3
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions packages/components/src/form-token-field/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,41 @@ describe( 'FormTokenField', () => {
screen.queryByPlaceholderText( 'Test placeholder' )
).not.toBeInTheDocument();
} );

it( 'should handle accents and special characters in tokens and input value', async () => {
const user = userEvent.setup( {
advanceTimers: jest.advanceTimersByTime,
} );

const onChangeSpy = jest.fn();

render(
<FormTokenFieldWithState
onChange={ onChangeSpy }
initialValue={ [ 'français', 'español', '日本', 'עברית' ] }
/>
);

const input = screen.getByRole( 'combobox' );

// Add 'عربى' token by typing it and pressing enter to tokenize it.
await user.type( input, 'عربى[Enter]' );
expect( onChangeSpy ).toHaveBeenCalledTimes( 1 );
expect( onChangeSpy ).toHaveBeenCalledWith( [
'français',
'español',
'日本',
'עברית',
'عربى',
] );
expectTokensToBeInTheDocument( [
'français',
'español',
'日本',
'עברית',
'عربى',
] );
} );
} );

describe( 'suggestions', () => {
Expand Down

0 comments on commit 9435de3

Please sign in to comment.