11import { getByRole } from '@testing-library/dom'
2+ import { userEvent } from '@testing-library/user-event'
23import { outdent } from 'outdent'
34
45import { CharacterCount , initCharacterCounts } from './character-count.mjs'
56import { examples } from './fixtures.mjs'
67
78import { components } from '#lib'
89
10+ const user = userEvent . setup ( )
11+
912describe ( 'Character count' , ( ) => {
1013 /** @type {HTMLElement } */
1114 let $root
@@ -350,12 +353,13 @@ describe('Character count', () => {
350353 expect ( component . getCountMessage ( ) ) . toBe ( 'You have 98 words remaining' )
351354 } )
352355
353- it ( 'uses current textarea value for `maxlength` limit via back/forward navigation' , ( ) => {
356+ it ( 'uses current textarea value for `maxlength` limit via back/forward navigation' , async ( ) => {
354357 const component = new CharacterCount ( $root , {
355358 maxlength : 100
356359 } )
357360
358- $textarea . value = 'Newly updated value'
361+ $textarea . focus ( )
362+ await user . keyboard ( 'Newly updated value' )
359363
360364 // Trigger back/forward navigation
361365 window . dispatchEvent (
@@ -369,12 +373,13 @@ describe('Character count', () => {
369373 )
370374 } )
371375
372- it ( 'uses current textarea value for `maxwords` limit via back/forward navigation' , ( ) => {
376+ it ( 'uses current textarea value for `maxwords` limit via back/forward navigation' , async ( ) => {
373377 const component = new CharacterCount ( $root , {
374378 maxwords : 100
375379 } )
376380
377- $textarea . value = 'Newly updated value'
381+ $textarea . focus ( )
382+ await user . keyboard ( 'Newly updated value' )
378383
379384 // Trigger back/forward navigation
380385 window . dispatchEvent (
0 commit comments