@@ -3,6 +3,40 @@ import { describe, it, expect, jest } from '@jest/globals';
3
3
import DynamicJsonForm from '../DynamicJsonForm' ;
4
4
import type { JsonSchemaType } from '../DynamicJsonForm' ;
5
5
6
+ describe ( 'DynamicJsonForm String Fields' , ( ) => {
7
+ const renderForm = ( props = { } ) => {
8
+ const defaultProps = {
9
+ schema : {
10
+ type : "string" as const ,
11
+ description : "Test string field"
12
+ } satisfies JsonSchemaType ,
13
+ value : undefined ,
14
+ onChange : jest . fn ( )
15
+ } ;
16
+ return render ( < DynamicJsonForm { ...defaultProps } { ...props } /> ) ;
17
+ } ;
18
+
19
+ describe ( 'Type Validation' , ( ) => {
20
+ it ( 'should handle numeric input as string type' , ( ) => {
21
+ const onChange = jest . fn ( ) ;
22
+ renderForm ( { onChange } ) ;
23
+
24
+ const input = screen . getByRole ( 'textbox' ) ;
25
+ fireEvent . change ( input , { target : { value : '123321' } } ) ;
26
+
27
+ expect ( onChange ) . toHaveBeenCalledWith ( '123321' ) ;
28
+ // Verify the value is a string, not a number
29
+ expect ( typeof onChange . mock . calls [ 0 ] [ 0 ] ) . toBe ( 'string' ) ;
30
+ } ) ;
31
+
32
+ it ( 'should render as text input, not number input' , ( ) => {
33
+ renderForm ( ) ;
34
+ const input = screen . getByRole ( 'textbox' ) ;
35
+ expect ( input ) . toHaveProperty ( 'type' , 'text' ) ;
36
+ } ) ;
37
+ } ) ;
38
+ } ) ;
39
+
6
40
describe ( 'DynamicJsonForm Integer Fields' , ( ) => {
7
41
const renderForm = ( props = { } ) => {
8
42
const defaultProps = {
0 commit comments