File tree 3 files changed +7
-6
lines changed
projects/testing-library/src/lib/user-events
3 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ export function createType(fireEvent: FireFunction & FireObject) {
36
36
} ;
37
37
}
38
38
39
- return async function type ( element : HTMLElement , value : string , options ?: TypeOptions ) {
39
+ return async function type ( element : HTMLElement , value : string | number , options ?: TypeOptions ) {
40
40
const { allAtOnce = false , delay = 0 } = options || { } ;
41
41
const initialValue = ( element as HTMLInputElement ) . value ;
42
42
@@ -46,9 +46,10 @@ export function createType(fireEvent: FireFunction & FireObject) {
46
46
return ;
47
47
}
48
48
49
+ const text = value . toString ( ) ;
49
50
let actuallyTyped = '' ;
50
- for ( let index = 0 ; index < value . length ; index ++ ) {
51
- const char = value [ index ] ;
51
+ for ( let index = 0 ; index < text . length ; index ++ ) {
52
+ const char = text [ index ] ;
52
53
const key = char ;
53
54
const keyCode = char . charCodeAt ( 0 ) ;
54
55
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ test('is possible to fill in a form and verify error messages (with the help of
27
27
expect ( component . queryByText ( 'color is required' ) ) . not . toBeInTheDocument ( ) ;
28
28
29
29
expect ( scoreControl ) . toBeInvalid ( ) ;
30
- component . type ( scoreControl , '7' ) ;
30
+ component . type ( scoreControl , 7 ) ;
31
31
expect ( scoreControl ) . toBeValid ( ) ;
32
32
33
33
expect ( errors ) . not . toBeInTheDocument ( ) ;
Original file line number Diff line number Diff line change @@ -19,15 +19,15 @@ test('is possible to fill in a form and verify error messages (with the help of
19
19
expect ( errors ) . toContainElement ( component . queryByText ( 'color is required' ) ) ;
20
20
21
21
component . type ( nameControl , 'Tim' ) ;
22
- component . type ( scoreControl , '12' ) ;
22
+ component . type ( scoreControl , 12 ) ;
23
23
component . selectOptions ( colorControl , 'Green' ) ;
24
24
25
25
expect ( component . queryByText ( 'name is required' ) ) . not . toBeInTheDocument ( ) ;
26
26
expect ( component . queryByText ( 'score must be lesser than 10' ) ) . toBeInTheDocument ( ) ;
27
27
expect ( component . queryByText ( 'color is required' ) ) . not . toBeInTheDocument ( ) ;
28
28
29
29
expect ( scoreControl ) . toBeInvalid ( ) ;
30
- component . type ( scoreControl , '7' ) ;
30
+ component . type ( scoreControl , 7 ) ;
31
31
expect ( scoreControl ) . toBeValid ( ) ;
32
32
33
33
expect ( errors ) . not . toBeInTheDocument ( ) ;
You can’t perform that action at this time.
0 commit comments