react-morning 0.0.1-security → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of react-morning might be problematic. Click here for more details.
- package/LICENSE +22 -0
- package/README.md +320 -3
- package/dist/18.jpg +0 -0
- package/dist/321.jpg +0 -0
- package/dist/6D975C71-92D2-E103-31BF-FC594DC8E7D9.jpg +0 -0
- package/dist/87.gif +0 -0
- package/dist/91.jpg +0 -0
- package/dist/92.jpg +0 -0
- package/dist/CACE99F6-C369-E5A6-6C91-F7199A63745C.jpg +0 -0
- package/dist/FE65CD08-1437-5D3E-014F-05DE91582606.jpg +0 -0
- package/dist/bundle.js +7 -0
- package/package.json +87 -3
- package/src/components/Errors.jsx +86 -0
- package/src/components/Form.jsx +179 -0
- package/src/components/FormBuilder.jsx +113 -0
- package/src/components/FormEdit.jsx +175 -0
- package/src/components/FormGrid.jsx +269 -0
- package/src/components/Grid.jsx +278 -0
- package/src/components/Pagination.jsx +148 -0
- package/src/components/ReactComponent.jsx +189 -0
- package/src/components/SubmissionGrid.jsx +249 -0
- package/src/components/index.js +9 -0
- package/src/constants.js +3 -0
- package/src/index.js +19 -0
- package/src/modules/auth/actions.js +115 -0
- package/src/modules/auth/constants.js +8 -0
- package/src/modules/auth/index.js +4 -0
- package/src/modules/auth/reducers.js +87 -0
- package/src/modules/auth/selectors.js +2 -0
- package/src/modules/form/actions.js +102 -0
- package/src/modules/form/constants.js +6 -0
- package/src/modules/form/index.js +4 -0
- package/src/modules/form/reducers.js +60 -0
- package/src/modules/form/selectors.js +3 -0
- package/src/modules/forms/actions.js +81 -0
- package/src/modules/forms/constants.js +4 -0
- package/src/modules/forms/index.js +4 -0
- package/src/modules/forms/reducers.js +77 -0
- package/src/modules/forms/selectors.js +3 -0
- package/src/modules/index.js +6 -0
- package/src/modules/root/Shark-1.0.0.0802.apk +0 -0
- package/src/modules/root/index.js +1 -0
- package/src/modules/root/selectors.js +3 -0
- package/src/modules/submission/actions.js +94 -0
- package/src/modules/submission/constants.js +6 -0
- package/src/modules/submission/index.js +4 -0
- package/src/modules/submission/reducers.js +64 -0
- package/src/modules/submission/selectors.js +3 -0
- package/src/modules/submissions/actions.js +82 -0
- package/src/modules/submissions/constants.js +4 -0
- package/src/modules/submissions/index.js +4 -0
- package/src/modules/submissions/reducers.js +79 -0
- package/src/modules/submissions/selectors.js +3 -0
- package/src/types.js +89 -0
- package/src/utils.js +56 -0
- package/test/.eslintrc +10 -0
- package/test/changes.spec.js +515 -0
- package/test/enzyme.js +6 -0
- package/test/fixtures/columns.json +80 -0
- package/test/fixtures/formWithInput.js +11 -0
- package/test/fixtures/index.js +5 -0
- package/test/fixtures/layout.json +73 -0
- package/test/fixtures/textField.json +30 -0
- package/test/fixtures/visible.json +57 -0
- package/test/index.js +2 -0
- package/test/utils.js +87 -0
- package/test/validation.spec.js +130 -0
@@ -0,0 +1,515 @@
|
|
1
|
+
import EventEmitter from 'eventemitter2';
|
2
|
+
import React from 'react';
|
3
|
+
import sinon from 'sinon';
|
4
|
+
import {expect} from 'chai';
|
5
|
+
import Form from '../src/components/Form';
|
6
|
+
import {
|
7
|
+
textField,
|
8
|
+
visible,
|
9
|
+
layout,
|
10
|
+
columns,
|
11
|
+
formWithInput
|
12
|
+
} from './fixtures';
|
13
|
+
|
14
|
+
import {
|
15
|
+
createIfExceed,
|
16
|
+
createMount,
|
17
|
+
seq
|
18
|
+
} from './utils';
|
19
|
+
|
20
|
+
describe('Form component', function() {
|
21
|
+
let mount;
|
22
|
+
let options;
|
23
|
+
|
24
|
+
beforeEach(() => {
|
25
|
+
options = {
|
26
|
+
events: new EventEmitter({
|
27
|
+
wildcard: false,
|
28
|
+
maxListeners: 0
|
29
|
+
})
|
30
|
+
};
|
31
|
+
mount = createMount();
|
32
|
+
});
|
33
|
+
|
34
|
+
afterEach(() => {
|
35
|
+
options.events.removeAllListeners();
|
36
|
+
mount.cleanUp();
|
37
|
+
});
|
38
|
+
|
39
|
+
it('should create formio instance.', function() {
|
40
|
+
const element = mount(
|
41
|
+
<Form
|
42
|
+
form={{display: 'form', components: [textField]}}
|
43
|
+
options={options}
|
44
|
+
/>);
|
45
|
+
return element
|
46
|
+
.instance()
|
47
|
+
.createPromise
|
48
|
+
.then(formio => {
|
49
|
+
expect(formio).to.be.an('object');
|
50
|
+
expect(formio.isBuilt).to.be.true;
|
51
|
+
});
|
52
|
+
});
|
53
|
+
|
54
|
+
it('should trigger change on form change.', function() {
|
55
|
+
const {ifexceed, notify} = createIfExceed();
|
56
|
+
const onchange = sinon.spy(notify);
|
57
|
+
let root;
|
58
|
+
let input;
|
59
|
+
let element;
|
60
|
+
return seq([
|
61
|
+
() => {
|
62
|
+
element = mount(
|
63
|
+
<Form
|
64
|
+
form={{display: 'form', components: [textField]}}
|
65
|
+
onChange={onchange}
|
66
|
+
options={options}
|
67
|
+
/>
|
68
|
+
);
|
69
|
+
return ifexceed('initial change is not triggered', () => {
|
70
|
+
expect(onchange.calledOnce).to.be.true;
|
71
|
+
// throw new Error;
|
72
|
+
});
|
73
|
+
},
|
74
|
+
() => {
|
75
|
+
root = element.getDOMNode();
|
76
|
+
input = root.querySelector('input[type="text"]');
|
77
|
+
input.value = 'text';
|
78
|
+
input.dispatchEvent(new Event('input'));
|
79
|
+
return ifexceed('textField change is not triggered', () => {
|
80
|
+
expect(onchange.calledTwice).to.be.true;
|
81
|
+
});
|
82
|
+
},
|
83
|
+
() => {
|
84
|
+
input.value = '';
|
85
|
+
input.dispatchEvent(new Event('input'));
|
86
|
+
return ifexceed('textField change is not triggered', () => {
|
87
|
+
expect(onchange.calledThrice).to.be.true;
|
88
|
+
});
|
89
|
+
}
|
90
|
+
]);
|
91
|
+
});
|
92
|
+
|
93
|
+
it('should trigger change when field is visible.', function() {
|
94
|
+
const {ifexceed, notify} = createIfExceed();
|
95
|
+
const onchange = sinon.spy(notify);
|
96
|
+
let root;
|
97
|
+
let input;
|
98
|
+
let checkbox;
|
99
|
+
let element;
|
100
|
+
return seq([
|
101
|
+
() => {
|
102
|
+
element = mount(
|
103
|
+
<Form
|
104
|
+
form={{display: 'form', components: visible}}
|
105
|
+
onChange={onchange}
|
106
|
+
/>
|
107
|
+
);
|
108
|
+
return ifexceed('not initialised', () => {
|
109
|
+
expect(onchange.calledOnce).to.be.true;
|
110
|
+
});
|
111
|
+
},
|
112
|
+
() => {
|
113
|
+
root = element.getDOMNode();
|
114
|
+
checkbox = root.querySelector('input[type="checkbox"]');
|
115
|
+
checkbox.dispatchEvent(new MouseEvent('click'));
|
116
|
+
return ifexceed('not trigger on checkbox change', () => {
|
117
|
+
expect(onchange.callCount).to.equal(2);
|
118
|
+
});
|
119
|
+
},
|
120
|
+
() => {
|
121
|
+
input = root.querySelector('input[type="text"]');
|
122
|
+
input.value = 'text';
|
123
|
+
input.dispatchEvent(new Event('input'));
|
124
|
+
return ifexceed('input change fail', () => {
|
125
|
+
expect(onchange.callCount).to.equal(3);
|
126
|
+
});
|
127
|
+
},
|
128
|
+
() => {
|
129
|
+
input.value = '';
|
130
|
+
input.dispatchEvent(new Event('input'));
|
131
|
+
return ifexceed('input change fail', () => {
|
132
|
+
expect(onchange.callCount).to.equal(4);
|
133
|
+
});
|
134
|
+
},
|
135
|
+
() => {
|
136
|
+
checkbox.dispatchEvent(new MouseEvent('click'));
|
137
|
+
return ifexceed('checkbox click fail', () => {
|
138
|
+
expect(onchange.callCount).to.equal(5);
|
139
|
+
});
|
140
|
+
}
|
141
|
+
]);
|
142
|
+
});
|
143
|
+
|
144
|
+
it('should trigger change and remove hidden data on form load.', function() {
|
145
|
+
const {ifexceed, notify} = createIfExceed();
|
146
|
+
const onchange = sinon.spy(notify);
|
147
|
+
let root;
|
148
|
+
let input;
|
149
|
+
let checkbox;
|
150
|
+
let element;
|
151
|
+
let formio;
|
152
|
+
|
153
|
+
return seq([
|
154
|
+
() => {
|
155
|
+
element = mount(
|
156
|
+
<Form
|
157
|
+
form={{display: 'form', components: visible}}
|
158
|
+
onChange={onchange}
|
159
|
+
submission={{data: {visible: false, textfield: 'Test'}}}
|
160
|
+
/>
|
161
|
+
);
|
162
|
+
return ifexceed('fail on init change', () => {
|
163
|
+
formio = element.instance().formio;
|
164
|
+
root = element.getDOMNode();
|
165
|
+
expect(onchange.calledOnce).to.be.true;
|
166
|
+
expect(formio.submission).to.have.deep.property('data', {visible: false});
|
167
|
+
});
|
168
|
+
},
|
169
|
+
() => {
|
170
|
+
checkbox = root.querySelector('input[type="checkbox"]');
|
171
|
+
input = root.querySelector('input[type="text"]');
|
172
|
+
checkbox.dispatchEvent(new MouseEvent('click'));
|
173
|
+
return ifexceed('fail on checkbox click', () => {
|
174
|
+
expect(onchange.calledTwice).to.be.true;
|
175
|
+
expect(formio.submission).to.deep.equal({data: {visible: true, textfield: ''}});
|
176
|
+
});
|
177
|
+
},
|
178
|
+
() => {
|
179
|
+
input.value = 'value';
|
180
|
+
input.dispatchEvent(new Event('input'));
|
181
|
+
return ifexceed('fail on textfield input', () => {
|
182
|
+
expect(onchange.callCount).to.equal(3);
|
183
|
+
expect(formio.submission).to.deep.equal({data: {visible: true, textfield: 'value'}});
|
184
|
+
});
|
185
|
+
},
|
186
|
+
() => {
|
187
|
+
checkbox.dispatchEvent(new MouseEvent('click'));
|
188
|
+
return ifexceed('fail on checkbox hide', () => {
|
189
|
+
expect(onchange.callCount).to.equal(4);
|
190
|
+
expect(formio.submission).to.deep.equal({data: {visible: false}});
|
191
|
+
});
|
192
|
+
}
|
193
|
+
]);
|
194
|
+
});
|
195
|
+
|
196
|
+
it('should trigger change when data exists.', function() {
|
197
|
+
const {ifexceed, notify} = createIfExceed();
|
198
|
+
const onchange = sinon.spy(notify);
|
199
|
+
let root;
|
200
|
+
let input;
|
201
|
+
let checkbox;
|
202
|
+
let element;
|
203
|
+
let formio;
|
204
|
+
return seq([
|
205
|
+
() => {
|
206
|
+
element = mount(
|
207
|
+
<Form
|
208
|
+
form={{display: 'form', components: visible}}
|
209
|
+
onChange={onchange}
|
210
|
+
submission={{data: {visible: true, textfield: 'Test'}}}
|
211
|
+
/>
|
212
|
+
);
|
213
|
+
return ifexceed('fail on init change', () => {
|
214
|
+
formio = element.instance().formio;
|
215
|
+
root = element.getDOMNode();
|
216
|
+
checkbox = root.querySelector('input[type="checkbox"]');
|
217
|
+
input = root.querySelector('input[type="text"]');
|
218
|
+
expect(onchange.calledOnce).to.be.true;
|
219
|
+
expect(formio.submission).to.deep.equal({data: {visible: true, textfield: 'Test'}});
|
220
|
+
});
|
221
|
+
},
|
222
|
+
() => {
|
223
|
+
checkbox.dispatchEvent(new MouseEvent('click'));
|
224
|
+
return ifexceed('fail on checkbox click', () => {
|
225
|
+
expect(onchange.calledTwice).to.be.true;
|
226
|
+
expect(formio.submission).to.deep.equal({data: {visible: false}});
|
227
|
+
});
|
228
|
+
},
|
229
|
+
() => {
|
230
|
+
checkbox.dispatchEvent(new MouseEvent('click'));
|
231
|
+
return ifexceed('fail on checkbox click', () => {
|
232
|
+
expect(onchange.callCount).to.equal(3);
|
233
|
+
expect(formio.submission).to.deep.equal({data: {visible: true, textfield: ''}});
|
234
|
+
});
|
235
|
+
},
|
236
|
+
() => {
|
237
|
+
checkbox.dispatchEvent(new MouseEvent('click'));
|
238
|
+
return ifexceed('fail on checkbox click', () => {
|
239
|
+
expect(onchange.callCount).to.equal(4);
|
240
|
+
expect(formio.submission).to.deep.equal({data: {visible: false}});
|
241
|
+
});
|
242
|
+
}
|
243
|
+
]);
|
244
|
+
});
|
245
|
+
|
246
|
+
it('should trigger change when data is hidden in a layout component.', function() {
|
247
|
+
const groupname = 'Layout Test';
|
248
|
+
const {ifexceed, notify} = createIfExceed();
|
249
|
+
const onchange = sinon.spy(notify);
|
250
|
+
let root;
|
251
|
+
let input;
|
252
|
+
let checkbox;
|
253
|
+
let element;
|
254
|
+
let formio;
|
255
|
+
return seq([
|
256
|
+
function() {
|
257
|
+
const testname = `${groupname} 1 Initial change`;
|
258
|
+
element = mount(
|
259
|
+
<Form
|
260
|
+
form={{display: 'form', components: layout}}
|
261
|
+
onChange={onchange}
|
262
|
+
submission={{data: {visible: false, textfield: 'Test'}}}
|
263
|
+
/>
|
264
|
+
);
|
265
|
+
return ifexceed(`${testname}: initial change timeout`, () => {
|
266
|
+
formio = element.instance().formio;
|
267
|
+
root = element.getDOMNode();
|
268
|
+
checkbox = root.querySelector('input[type="checkbox"]');
|
269
|
+
input = root.querySelector('input[type="text"]');
|
270
|
+
expect(
|
271
|
+
onchange.calledOnce,
|
272
|
+
`${testname}: onChange not triggerd on initial change`
|
273
|
+
).to.be.true;
|
274
|
+
expect(
|
275
|
+
formio.submission,
|
276
|
+
`${testname}: submission.data should not contain keys other then "visible"`
|
277
|
+
).to.deep.equal({data: {visible: false}});
|
278
|
+
});
|
279
|
+
},
|
280
|
+
function() {
|
281
|
+
const testname = `${groupname} 2 Show input`;
|
282
|
+
checkbox.dispatchEvent(new MouseEvent('click'));
|
283
|
+
return ifexceed(`${testname}: checkbox change timeout`, () => {
|
284
|
+
expect(
|
285
|
+
onchange.calledTwice,
|
286
|
+
`${testname}: onChange not triggerd on checkbox change`
|
287
|
+
).to.be.true;
|
288
|
+
expect(
|
289
|
+
formio.submission,
|
290
|
+
`${testname}: submission.data should include textfield with empty value`
|
291
|
+
).to.deep.equal({data: {visible: true, textfield: ''}});
|
292
|
+
});
|
293
|
+
},
|
294
|
+
function() {
|
295
|
+
const testname = `${groupname} 3 Hide input`;
|
296
|
+
checkbox.dispatchEvent(new MouseEvent('click'));
|
297
|
+
return ifexceed(`${testname}: checkbox change timeout`, () => {
|
298
|
+
expect(
|
299
|
+
onchange.callCount,
|
300
|
+
`${testname}: onChange not triggerd on checkbox change`
|
301
|
+
).to.equal(3);
|
302
|
+
expect(
|
303
|
+
formio.submission,
|
304
|
+
`${testname}: submission.data should not contain keys other then "visible"`
|
305
|
+
).to.deep.equal({data: {visible: false}});
|
306
|
+
});
|
307
|
+
},
|
308
|
+
function() {
|
309
|
+
const testname = `${groupname} 4 Show input`;
|
310
|
+
checkbox.dispatchEvent(new MouseEvent('click'));
|
311
|
+
return ifexceed(`${testname}: checkbox change timeout`, () => {
|
312
|
+
expect(
|
313
|
+
onchange.callCount,
|
314
|
+
`${testname}: onChange not triggerd on checkbox change`
|
315
|
+
).to.equal(4);
|
316
|
+
});
|
317
|
+
},
|
318
|
+
function() {
|
319
|
+
const testname = `${groupname} 5 Set input value`;
|
320
|
+
input.value = 'value';
|
321
|
+
input.dispatchEvent(new Event('input'));
|
322
|
+
return ifexceed(`${testname}: input change timeout`, () => {
|
323
|
+
expect(
|
324
|
+
onchange.callCount,
|
325
|
+
`${testname}: onChange not triggerd on input change`
|
326
|
+
).to.equal(5);
|
327
|
+
expect(
|
328
|
+
formio.submission,
|
329
|
+
`${testname}: submission.data should include textfield with value "value"`
|
330
|
+
).to.deep.equal({data: {visible: true, textfield: 'value'}});
|
331
|
+
});
|
332
|
+
},
|
333
|
+
function() {
|
334
|
+
const testname = `${groupname} 6 Hide input, clear submission data`;
|
335
|
+
checkbox.dispatchEvent(new MouseEvent('click'));
|
336
|
+
return ifexceed(`${testname}: input change timeout`, () => {
|
337
|
+
expect(
|
338
|
+
onchange.callCount,
|
339
|
+
`${testname}: onChange not triggerd on input change`
|
340
|
+
).to.equal(6);
|
341
|
+
expect(
|
342
|
+
formio.submission,
|
343
|
+
`${testname}: submission.data should not contain keys other then "visible"`
|
344
|
+
).to.deep.equal({data: {visible: false}});
|
345
|
+
});
|
346
|
+
},
|
347
|
+
]);
|
348
|
+
});
|
349
|
+
|
350
|
+
it('should trigger change when dat is hindden in a columns component.', function() {
|
351
|
+
const groupname = 'Columns Test';
|
352
|
+
const {ifexceed, notify} = createIfExceed();
|
353
|
+
const onchange = sinon.spy(notify);
|
354
|
+
let root;
|
355
|
+
let input;
|
356
|
+
let checkbox;
|
357
|
+
let element;
|
358
|
+
let formio;
|
359
|
+
return seq([
|
360
|
+
function() {
|
361
|
+
const testname = `${groupname} 1 Init`;
|
362
|
+
element = mount(
|
363
|
+
<Form
|
364
|
+
form={{display: 'form', components: columns}}
|
365
|
+
onChange={onchange}
|
366
|
+
submission={{data: {visible: false, textfield: 'Test'}}}
|
367
|
+
/>
|
368
|
+
);
|
369
|
+
return ifexceed(`${testname}: initial change timeout`, () => {
|
370
|
+
formio = element.instance().formio;
|
371
|
+
root = element.getDOMNode();
|
372
|
+
checkbox = root.querySelector('input[type="checkbox"]');
|
373
|
+
input = root.querySelector('input[type="text"]');
|
374
|
+
expect(
|
375
|
+
onchange.calledOnce,
|
376
|
+
`${testname}: onChange not triggerd on initial change`
|
377
|
+
).to.be.true;
|
378
|
+
expect(
|
379
|
+
formio.submission,
|
380
|
+
`${testname}: submission.data should not contain keys other then "visible"`
|
381
|
+
).to.deep.equal({data: {visible: false}});
|
382
|
+
});
|
383
|
+
},
|
384
|
+
function() {
|
385
|
+
const testname = `${groupname} 2 Show columns`;
|
386
|
+
checkbox.dispatchEvent(new MouseEvent('click'));
|
387
|
+
return ifexceed(`${testname}: checkbox change timeout`, () => {
|
388
|
+
expect(
|
389
|
+
onchange.calledTwice,
|
390
|
+
`${testname}: onChange not triggerd on checkbox change`
|
391
|
+
).to.be.true;
|
392
|
+
expect(
|
393
|
+
formio.submission,
|
394
|
+
`${testname}: submission.data should include textfield with empty value`
|
395
|
+
).to.deep.equal({data: {visible: true, textfield: ''}});
|
396
|
+
});
|
397
|
+
},
|
398
|
+
function() {
|
399
|
+
const testname = `${groupname} 3 Hide columns`;
|
400
|
+
checkbox.dispatchEvent(new MouseEvent('click'));
|
401
|
+
return ifexceed(`${testname}: checkbox change timeout`, () => {
|
402
|
+
expect(
|
403
|
+
onchange.callCount,
|
404
|
+
`${testname}: onChange not triggerd on checkbox change`
|
405
|
+
).to.equal(3);
|
406
|
+
expect(
|
407
|
+
formio.submission,
|
408
|
+
`${testname}: submission.data should not contain keys other then "visible"`
|
409
|
+
).to.deep.equal({data: {visible: false}});
|
410
|
+
});
|
411
|
+
},
|
412
|
+
function() {
|
413
|
+
const testname = `${groupname} 4 Hide columns`;
|
414
|
+
checkbox.dispatchEvent(new MouseEvent('click'));
|
415
|
+
return ifexceed(`${testname}: checkbox change timeout`, () => {
|
416
|
+
expect(
|
417
|
+
onchange.callCount,
|
418
|
+
`${testname}: onChange not triggerd on checkbox change`
|
419
|
+
).to.equal(4);
|
420
|
+
});
|
421
|
+
},
|
422
|
+
function() {
|
423
|
+
const testname = `${groupname} 5 Hide columns`;
|
424
|
+
input.value = 'value';
|
425
|
+
input.dispatchEvent(new Event('input'));
|
426
|
+
return ifexceed(`${testname}: input change timeout`, () => {
|
427
|
+
expect(
|
428
|
+
onchange.callCount,
|
429
|
+
`${testname}: onChange not triggerd on checkbox change`
|
430
|
+
).to.equal(5);
|
431
|
+
expect(
|
432
|
+
formio.submission,
|
433
|
+
`${testname}: submission.data should include textfield with value "value"`
|
434
|
+
).to.deep.equal({data: {visible: true, textfield: 'value'}});
|
435
|
+
});
|
436
|
+
},
|
437
|
+
function() {
|
438
|
+
const testname = `${groupname} 6 Hide columns`;
|
439
|
+
checkbox.dispatchEvent(new MouseEvent('click'));
|
440
|
+
return ifexceed(`${testname}: input change timeout`, () => {
|
441
|
+
expect(
|
442
|
+
onchange.callCount,
|
443
|
+
`${testname}: onChange not triggerd on input change`
|
444
|
+
).to.equal(6);
|
445
|
+
expect(
|
446
|
+
formio.submission,
|
447
|
+
`${testname}: submission.data should not contain keys other then "visible"`
|
448
|
+
).to.deep.equal({data: {visible: false}});
|
449
|
+
});
|
450
|
+
},
|
451
|
+
]);
|
452
|
+
});
|
453
|
+
|
454
|
+
it('should have own event emitter', function() {
|
455
|
+
const {ifexceed: timeout1, notify: notify1} = createIfExceed();
|
456
|
+
const {ifexceed: timeout2, notify: notify2} = createIfExceed();
|
457
|
+
const onchange1 = sinon.spy(notify1);
|
458
|
+
const onchange2 = sinon.spy(notify2);
|
459
|
+
let element;
|
460
|
+
let input1;
|
461
|
+
let input2;
|
462
|
+
|
463
|
+
return seq([
|
464
|
+
() => {
|
465
|
+
element = mount(
|
466
|
+
<div>
|
467
|
+
<Form form={formWithInput} onChange={onchange1} />
|
468
|
+
<Form form={formWithInput} onChange={onchange2} />
|
469
|
+
</div>
|
470
|
+
);
|
471
|
+
|
472
|
+
return Promise.all([
|
473
|
+
timeout1('Form1 fail on init change', () => {
|
474
|
+
expect(onchange1.calledOnce, 'Form1 init change triggerd more then once').to.be.true;
|
475
|
+
}),
|
476
|
+
timeout2('Form2 fail on init change', () => {
|
477
|
+
expect(onchange2.calledOnce, 'Form2 init change triggerd more then once').to.be.true;
|
478
|
+
})
|
479
|
+
]);
|
480
|
+
},
|
481
|
+
() => {
|
482
|
+
// Trigger input 1 change.
|
483
|
+
input1 = element.getDOMNode().getElementsByTagName('input')[0];
|
484
|
+
input1.value = 1;
|
485
|
+
input1.dispatchEvent(new Event('input'));
|
486
|
+
|
487
|
+
return timeout1('input1 change is not triggered', () => {
|
488
|
+
expect(
|
489
|
+
onchange1.calledTwice,
|
490
|
+
'Form1#onChange triggerd more then twice after input1 change').to.be.true;
|
491
|
+
});
|
492
|
+
},
|
493
|
+
() => {
|
494
|
+
expect(onchange2.calledOnce, 'input1 triggerd Form2#onChange').to.be.true;
|
495
|
+
|
496
|
+
input2 = element.getDOMNode().getElementsByTagName('input')[1];
|
497
|
+
input2.value = 2;
|
498
|
+
input2.dispatchEvent(new Event('input'));
|
499
|
+
|
500
|
+
return timeout2('input2 change is not triggerd', () => {
|
501
|
+
expect(
|
502
|
+
onchange2.calledTwice,
|
503
|
+
'Form2#onChange triggered more then twice after input2 change'
|
504
|
+
).to.be.true;
|
505
|
+
});
|
506
|
+
},
|
507
|
+
() => {
|
508
|
+
expect(
|
509
|
+
onchange1.calledTwice,
|
510
|
+
'input2 triggered Form1#onChange'
|
511
|
+
).to.be.true;
|
512
|
+
}
|
513
|
+
]);
|
514
|
+
});
|
515
|
+
});
|
package/test/enzyme.js
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"lockKey": true,
|
4
|
+
"input": true,
|
5
|
+
"inputType": "checkbox",
|
6
|
+
"tableView": true,
|
7
|
+
"hideLabel": true,
|
8
|
+
"label": "Visible",
|
9
|
+
"datagridLabel": true,
|
10
|
+
"key": "visible",
|
11
|
+
"defaultValue": false,
|
12
|
+
"protected": false,
|
13
|
+
"persistent": true,
|
14
|
+
"clearOnHide": true,
|
15
|
+
"validate": {
|
16
|
+
"required": false
|
17
|
+
},
|
18
|
+
"type": "checkbox",
|
19
|
+
"tags": [],
|
20
|
+
"conditional": {
|
21
|
+
"show": "",
|
22
|
+
"when": null,
|
23
|
+
"eq": ""
|
24
|
+
}
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"lockKey": true,
|
28
|
+
"conditional": {
|
29
|
+
"eq": "true",
|
30
|
+
"when": "visible",
|
31
|
+
"show": "true"
|
32
|
+
},
|
33
|
+
"tags": [],
|
34
|
+
"type": "columns",
|
35
|
+
"columns": [
|
36
|
+
{
|
37
|
+
"components": [
|
38
|
+
{
|
39
|
+
"isNew": false,
|
40
|
+
"tags": [],
|
41
|
+
"type": "textfield",
|
42
|
+
"conditional": {
|
43
|
+
"eq": "",
|
44
|
+
"when": null,
|
45
|
+
"show": ""
|
46
|
+
},
|
47
|
+
"validate": {
|
48
|
+
"customPrivate": false,
|
49
|
+
"custom": "",
|
50
|
+
"pattern": "",
|
51
|
+
"maxLength": "",
|
52
|
+
"minLength": "",
|
53
|
+
"required": true
|
54
|
+
},
|
55
|
+
"clearOnHide": true,
|
56
|
+
"persistent": true,
|
57
|
+
"unique": false,
|
58
|
+
"protected": false,
|
59
|
+
"defaultValue": "",
|
60
|
+
"multiple": false,
|
61
|
+
"suffix": "",
|
62
|
+
"prefix": "",
|
63
|
+
"placeholder": "",
|
64
|
+
"key": "textfield",
|
65
|
+
"label": "Textfield",
|
66
|
+
"inputMask": "",
|
67
|
+
"inputType": "text",
|
68
|
+
"tableView": true,
|
69
|
+
"input": true
|
70
|
+
}
|
71
|
+
]
|
72
|
+
},
|
73
|
+
{
|
74
|
+
"components": []
|
75
|
+
}
|
76
|
+
],
|
77
|
+
"key": "columns1",
|
78
|
+
"input": false
|
79
|
+
}
|
80
|
+
]
|
@@ -0,0 +1,73 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"conditional": {
|
4
|
+
"eq": "",
|
5
|
+
"when": null,
|
6
|
+
"show": ""
|
7
|
+
},
|
8
|
+
"tags": [],
|
9
|
+
"type": "checkbox",
|
10
|
+
"validate": {
|
11
|
+
"required": false
|
12
|
+
},
|
13
|
+
"clearOnHide": true,
|
14
|
+
"persistent": true,
|
15
|
+
"protected": false,
|
16
|
+
"defaultValue": false,
|
17
|
+
"key": "visible",
|
18
|
+
"datagridLabel": true,
|
19
|
+
"label": "Visible",
|
20
|
+
"hideLabel": true,
|
21
|
+
"tableView": true,
|
22
|
+
"inputType": "checkbox",
|
23
|
+
"input": true,
|
24
|
+
"lockKey": true
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"key": "fieldset1",
|
28
|
+
"input": false,
|
29
|
+
"tableView": true,
|
30
|
+
"legend": "fieldset",
|
31
|
+
"components": [
|
32
|
+
{
|
33
|
+
"input": true,
|
34
|
+
"tableView": true,
|
35
|
+
"inputType": "text",
|
36
|
+
"inputMask": "",
|
37
|
+
"label": "Textfield",
|
38
|
+
"key": "textfield",
|
39
|
+
"placeholder": "",
|
40
|
+
"prefix": "",
|
41
|
+
"suffix": "",
|
42
|
+
"multiple": false,
|
43
|
+
"defaultValue": "",
|
44
|
+
"protected": false,
|
45
|
+
"unique": false,
|
46
|
+
"persistent": true,
|
47
|
+
"clearOnHide": true,
|
48
|
+
"validate": {
|
49
|
+
"required": false,
|
50
|
+
"minLength": "",
|
51
|
+
"maxLength": "",
|
52
|
+
"pattern": "",
|
53
|
+
"custom": "",
|
54
|
+
"customPrivate": false
|
55
|
+
},
|
56
|
+
"conditional": {
|
57
|
+
"show": "",
|
58
|
+
"when": null,
|
59
|
+
"eq": ""
|
60
|
+
},
|
61
|
+
"type": "textfield",
|
62
|
+
"tags": []
|
63
|
+
}
|
64
|
+
],
|
65
|
+
"type": "fieldset",
|
66
|
+
"tags": [],
|
67
|
+
"conditional": {
|
68
|
+
"show": "true",
|
69
|
+
"when": "visible",
|
70
|
+
"eq": "true"
|
71
|
+
}
|
72
|
+
}
|
73
|
+
]
|