@@ -3,40 +3,43 @@ import registry from "../../core/registry";
33import utils from "../../core/utils" ;
44
55describe ( "pat-autofocus" , function ( ) {
6- it ( "Focus the first element." , async ( ) => {
6+ it ( "1 - Focus the first element." , async ( ) => {
77 document . body . innerHTML = `
88 <input name="i1" type="text" class="pat-autofocus"/>
99 <input name="i2" type="text" class="pat-autofocus"/>
1010 <input name="i3" type="text" class="pat-autofocus"/>
1111 ` ;
1212 registry . scan ( document . body ) ;
13- await utils . timeout ( 100 ) ;
13+ await utils . timeout ( 1 ) ; // Wait for async pattern initialization.
14+ await utils . timeout ( 100 ) ; // Wait for autofocus timeout.
1415
1516 const should_be_active = document . querySelector ( "input[name=i1]" ) ;
1617 expect ( document . activeElement ) . toBe ( should_be_active ) ;
1718 } ) ;
1819
19- it ( "Focus the first empty element, if available." , async ( ) => {
20+ it ( "2 - Focus the first empty element, if available." , async ( ) => {
2021 document . body . innerHTML = `
2122 <input name="i1" type="text" class="pat-autofocus" value="okay"/>
2223 <input name="i2" type="text" class="pat-autofocus"/>
2324 <input name="i3" type="text" class="pat-autofocus"/>
2425 ` ;
2526 registry . scan ( document . body ) ;
26- await utils . timeout ( 100 ) ;
27+ await utils . timeout ( 1 ) ; // Wait for async pattern initialization.
28+ await utils . timeout ( 100 ) ; // Wait for autofocus timeout.
2729
2830 const should_be_active = document . querySelector ( "input[name=i2]" ) ;
2931 expect ( document . activeElement ) . toBe ( should_be_active ) ;
3032 } ) ;
3133
32- it ( "Don't focus hidden elements." , async ( ) => {
34+ it ( "3 - Don't focus hidden elements." , async ( ) => {
3335 document . body . innerHTML = `
3436 <input name="i1" type="text" class="pat-autofocus" value="okay"/>
3537 <input name="i2" type="text" class="pat-autofocus" hidden/>
3638 <input name="i3" type="text" class="pat-autofocus"/>
3739 ` ;
3840 registry . scan ( document . body ) ;
39- await utils . timeout ( 100 ) ;
41+ await utils . timeout ( 1 ) ; // Wait for async pattern initialization.
42+ await utils . timeout ( 100 ) ; // Wait for autofocus timeout.
4043
4144 const should_be_active = document . querySelector ( "input[name=i3]" ) ;
4245 expect ( document . activeElement ) . toBe ( should_be_active ) ;
0 commit comments