File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { mount } from "enzyme"
2
+ import { Field , Form } from "../src"
3
+
4
+ describe ( "RForm.Field" , ( ) => {
5
+ it ( "work with input" , ( ) => {
6
+ const wrapper = mount ( < Form >
7
+ < Field name = "input" >
8
+ < input type = "text" />
9
+ </ Field >
10
+ </ Form > )
11
+ wrapper . find ( "input" ) . simulate ( "change" , { target :{ value :"joe" } } )
12
+ expect ( wrapper . find ( 'input' ) . props ( ) . value ) . toEqual ( "joe" )
13
+ } )
14
+
15
+ it ( "work with checkbox" , ( ) => {
16
+
17
+ const wrapper = mount ( < Form >
18
+ < Field name = "checkbox" valuePropName = "checked" >
19
+ < input type = "checkbox" />
20
+ </ Field >
21
+ </ Form > )
22
+ wrapper . find ( "input" ) . simulate ( "change" , { target :{ checked :true } } )
23
+
24
+ expect ( wrapper . find ( 'input' ) . props ( ) . checked ) . toEqual ( true )
25
+ } )
26
+
27
+ it ( "work with select" , ( ) => {
28
+ const wrapper = mount ( < Form >
29
+ < Field name = "select" >
30
+ < select >
31
+ < option value = "a" >
32
+ A
33
+ </ option >
34
+ < option value = "b" >
35
+ B
36
+ </ option >
37
+ </ select >
38
+ </ Field >
39
+ </ Form > )
40
+ wrapper . find ( "select" ) . simulate ( "change" , { target :{ value :"a" } } )
41
+ expect ( wrapper . find ( 'select' ) . props ( ) . value ) . toEqual ( "a" )
42
+ } )
43
+ } )
You can’t perform that action at this time.
0 commit comments