Skip to content

Commit 8ac503c

Browse files
committed
field test
1 parent f465169 commit 8ac503c

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/field.test.tsx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
})

0 commit comments

Comments
 (0)