File tree Expand file tree Collapse file tree 1 file changed +64
-2
lines changed Expand file tree Collapse file tree 1 file changed +64
-2
lines changed Original file line number Diff line number Diff line change
1
+ // Library
2
+ import React from 'react' ;
3
+ import { mount } from 'enzyme' ;
4
+
5
+ // Internal
6
+ import Form from '../Form' ;
7
+
1
8
describe ( 'Form' , ( ) => {
2
- it ( 'Test it works well' , ( ) => {
3
- expect ( true ) . toBe ( true ) ;
9
+ it ( 'Mount the form with basic fields' , ( ) => {
10
+ const path = 'name' ;
11
+ const onChange = jest . fn ( ( ) => 'onChangeFunc' ) ;
12
+ const schema = {
13
+ 'type' : 'string' ,
14
+ 'title' : 'First Name' ,
15
+ } ;
16
+
17
+ const uiSchema = {
18
+ } ;
19
+
20
+ const data = 'Bob' ;
21
+
22
+ // act
23
+ const wrapper = mount (
24
+ < Form
25
+ schema = { schema }
26
+ uiSchema = { uiSchema }
27
+ formData = { data }
28
+ prefixId = { 'test' }
29
+ onChange = { ( { formData } ) => jest . fn ( formData ) }
30
+ onSubmit = { ( submittedData ) => jest . fn ( submittedData ) }
31
+ /> ,
32
+ ) ;
33
+
34
+ // check
35
+ expect ( wrapper ) . toHaveLength ( 1 ) ;
36
+ } ) ;
37
+
38
+
39
+ it ( 'Mount the form with basic fields (with error)' , ( ) => {
40
+ const path = 'name' ;
41
+ const onChange = jest . fn ( ( ) => 'onChangeFunc' ) ;
42
+ const schema = {
43
+ 'type' : 'string' ,
44
+ 'title' : 'First Name' ,
45
+ } ;
46
+
47
+ const uiSchema = {
48
+ } ;
49
+
50
+ const data = 1 ;
51
+
52
+ // act
53
+ const wrapper = mount (
54
+ < Form
55
+ schema = { schema }
56
+ uiSchema = { uiSchema }
57
+ formData = { data }
58
+ prefixId = { 'test' }
59
+ onChange = { ( { formData } ) => jest . fn ( formData ) }
60
+ onSubmit = { ( submittedData ) => jest . fn ( submittedData ) }
61
+ /> ,
62
+ ) ;
63
+
64
+ // check
65
+ expect ( wrapper ) . toHaveLength ( 1 ) ;
4
66
} ) ;
5
67
} ) ;
You can’t perform that action at this time.
0 commit comments