@@ -12,13 +12,63 @@ describe('The node collector reducer', () => {
12
12
it ( 'should handle next node with one field' , ( ) => {
13
13
const action = {
14
14
type : 'node/next' ,
15
- payload : [
16
- {
15
+ payload : {
16
+ fields : [
17
+ {
18
+ key : 'username' ,
19
+ type : 'TEXT' ,
20
+ label : 'Username' ,
21
+ } ,
22
+ ] ,
23
+ formData : { } ,
24
+ } ,
25
+ } ;
26
+ expect ( nodeCollectorReducer ( undefined , action ) ) . toEqual ( [
27
+ {
28
+ category : 'SingleValueCollector' ,
29
+ error : null ,
30
+ type : 'TextCollector' ,
31
+ id : 'username-0' ,
32
+ name : 'username' ,
33
+ input : {
17
34
key : 'username' ,
35
+ value : '' ,
18
36
type : 'TEXT' ,
37
+ } ,
38
+ output : {
39
+ key : 'username' ,
19
40
label : 'Username' ,
41
+ type : 'TEXT' ,
42
+ value : '' ,
20
43
} ,
21
- ] ,
44
+ } ,
45
+ ] ) ;
46
+ } ) ;
47
+ it ( 'should NOT populate the formData with input information for password collector' , ( ) => {
48
+ const action = {
49
+ type : 'node/next' ,
50
+ payload : {
51
+ fields : [
52
+ {
53
+ key : 'username' ,
54
+ type : 'TEXT' ,
55
+ label : 'Username' ,
56
+ } ,
57
+ {
58
+ key : 'password' ,
59
+ type : 'PASSWORD' ,
60
+ label : 'Password' ,
61
+ } ,
62
+ {
63
+ key : 'submit' ,
64
+ type : 'SUBMIT_BUTTON' ,
65
+ label : 'Submit' ,
66
+ } ,
67
+ ] ,
68
+ formData : {
69
+ password : 'SUPERSECRETPASSWORD' ,
70
+ } ,
71
+ } ,
22
72
} ;
23
73
expect ( nodeCollectorReducer ( undefined , action ) ) . toEqual ( [
24
74
{
@@ -39,29 +89,136 @@ describe('The node collector reducer', () => {
39
89
value : '' ,
40
90
} ,
41
91
} ,
92
+ {
93
+ category : 'SingleValueCollector' ,
94
+ error : null ,
95
+ type : 'PasswordCollector' ,
96
+ id : 'password-1' ,
97
+ name : 'password' ,
98
+ input : {
99
+ key : 'password' ,
100
+ value : '' ,
101
+ type : 'PASSWORD' ,
102
+ } ,
103
+ output : {
104
+ key : 'password' ,
105
+ label : 'Password' ,
106
+ type : 'PASSWORD' ,
107
+ } ,
108
+ } ,
109
+ {
110
+ category : 'ActionCollector' ,
111
+ error : null ,
112
+ type : 'SubmitCollector' ,
113
+ id : 'submit-2' ,
114
+ name : 'submit' ,
115
+ output : {
116
+ key : 'submit' ,
117
+ label : 'Submit' ,
118
+ type : 'SUBMIT_BUTTON' ,
119
+ } ,
120
+ } ,
42
121
] ) ;
43
122
} ) ;
44
-
45
- it ( 'should handle next node with multiple fields' , ( ) => {
123
+ it ( 'should populate the formData with input information' , ( ) => {
46
124
const action = {
47
125
type : 'node/next' ,
48
- payload : [
49
- {
126
+ payload : {
127
+ fields : [
128
+ {
129
+ key : 'username' ,
130
+ type : 'TEXT' ,
131
+ label : 'Username' ,
132
+ } ,
133
+ {
134
+ key : 'password' ,
135
+ type : 'PASSWORD' ,
136
+ label : 'Password' ,
137
+ } ,
138
+ {
139
+ key : 'submit' ,
140
+ type : 'SUBMIT_BUTTON' ,
141
+ label : 'Submit' ,
142
+ } ,
143
+ ] ,
144
+ formData : {
145
+ username : 'This is the default data' ,
146
+ } ,
147
+ } ,
148
+ } ;
149
+ expect ( nodeCollectorReducer ( undefined , action ) ) . toEqual ( [
150
+ {
151
+ category : 'SingleValueCollector' ,
152
+ error : null ,
153
+ type : 'TextCollector' ,
154
+ id : 'username-0' ,
155
+ name : 'username' ,
156
+ input : {
50
157
key : 'username' ,
158
+ value : '' ,
51
159
type : 'TEXT' ,
160
+ } ,
161
+ output : {
162
+ key : 'username' ,
52
163
label : 'Username' ,
164
+ type : 'TEXT' ,
165
+ value : 'This is the default data' ,
53
166
} ,
54
- {
167
+ } ,
168
+ {
169
+ category : 'SingleValueCollector' ,
170
+ error : null ,
171
+ type : 'PasswordCollector' ,
172
+ id : 'password-1' ,
173
+ name : 'password' ,
174
+ input : {
55
175
key : 'password' ,
176
+ value : '' ,
56
177
type : 'PASSWORD' ,
178
+ } ,
179
+ output : {
180
+ key : 'password' ,
57
181
label : 'Password' ,
182
+ type : 'PASSWORD' ,
58
183
} ,
59
- {
184
+ } ,
185
+ {
186
+ category : 'ActionCollector' ,
187
+ error : null ,
188
+ type : 'SubmitCollector' ,
189
+ id : 'submit-2' ,
190
+ name : 'submit' ,
191
+ output : {
60
192
key : 'submit' ,
61
- type : 'SUBMIT_BUTTON' ,
62
193
label : 'Submit' ,
194
+ type : 'SUBMIT_BUTTON' ,
63
195
} ,
64
- ] ,
196
+ } ,
197
+ ] ) ;
198
+ } ) ;
199
+ it ( 'should handle next node with multiple fields' , ( ) => {
200
+ const action = {
201
+ type : 'node/next' ,
202
+ payload : {
203
+ fields : [
204
+ {
205
+ key : 'username' ,
206
+ type : 'TEXT' ,
207
+ label : 'Username' ,
208
+ } ,
209
+ {
210
+ key : 'password' ,
211
+ type : 'PASSWORD' ,
212
+ label : 'Password' ,
213
+ } ,
214
+ {
215
+ key : 'submit' ,
216
+ type : 'SUBMIT_BUTTON' ,
217
+ label : 'Submit' ,
218
+ } ,
219
+ ] ,
220
+ formData : { } ,
221
+ } ,
65
222
} ;
66
223
expect ( nodeCollectorReducer ( undefined , action ) ) . toEqual ( [
67
224
{
0 commit comments