@ukhomeoffice/cop-react-form-renderer 5.27.0 → 5.27.2
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.
- package/dist/components/FormComponent/Collection.js +3 -1
- package/dist/components/FormRenderer/FormRenderer.test.js +38 -63
- package/dist/utils/Component/elevateNestedComponents.js +14 -9
- package/dist/utils/Component/elevateNestedComponents.test.js +144 -0
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +37 -37
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +1 -1
- package/package.json +2 -2
|
@@ -193,7 +193,9 @@ var Collection = function Collection(_ref) {
|
|
|
193
193
|
onChange: onCollectionChange,
|
|
194
194
|
onTopLevelChange: onTopLevelChange,
|
|
195
195
|
wrap: wrap
|
|
196
|
-
}), removeStyle === 'end' && /*#__PURE__*/_react.default.createElement(_copReactComponents.ButtonGroup,
|
|
196
|
+
}), removeStyle === 'end' && /*#__PURE__*/_react.default.createElement(_copReactComponents.ButtonGroup, {
|
|
197
|
+
className: "govuk-!-margin-top-1"
|
|
198
|
+
}, /*#__PURE__*/_react.default.createElement(_copReactComponents.Button, {
|
|
197
199
|
onClick: function onClick() {
|
|
198
200
|
return onRemoveItem(item);
|
|
199
201
|
},
|
|
@@ -33,6 +33,27 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
|
|
|
33
33
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // Global imports
|
|
34
34
|
// Local imports
|
|
35
35
|
// JSON
|
|
36
|
+
var setDate = function setDate(element, date) {
|
|
37
|
+
var items = element.children;
|
|
38
|
+
_react.fireEvent.change(items[0].childNodes[0].childNodes[1], {
|
|
39
|
+
target: {
|
|
40
|
+
name: 'date-day',
|
|
41
|
+
value: date[0]
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
_react.fireEvent.change(items[1].childNodes[0].childNodes[1], {
|
|
45
|
+
target: {
|
|
46
|
+
name: 'date-month',
|
|
47
|
+
value: date[1]
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
_react.fireEvent.change(items[2].childNodes[0].childNodes[1], {
|
|
51
|
+
target: {
|
|
52
|
+
name: 'date-year',
|
|
53
|
+
value: date[2]
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
};
|
|
36
57
|
describe('components', function () {
|
|
37
58
|
describe('FormRenderer', function () {
|
|
38
59
|
var mockAxios = new _axiosMockAdapter.default(_axios.default);
|
|
@@ -414,7 +435,7 @@ describe('components', function () {
|
|
|
414
435
|
}
|
|
415
436
|
}, _callee14);
|
|
416
437
|
})));
|
|
417
|
-
it('should render a
|
|
438
|
+
it('should render a task list', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
418
439
|
var taskList;
|
|
419
440
|
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
420
441
|
while (1) switch (_context16.prev = _context16.next) {
|
|
@@ -466,7 +487,7 @@ describe('components', function () {
|
|
|
466
487
|
}
|
|
467
488
|
}, _callee18);
|
|
468
489
|
})));
|
|
469
|
-
it('should load
|
|
490
|
+
it('should load task list with notes', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
470
491
|
var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, TASK_LIST_WITH_NOTES, taskList;
|
|
471
492
|
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
472
493
|
while (1) switch (_context20.prev = _context20.next) {
|
|
@@ -514,7 +535,7 @@ describe('components', function () {
|
|
|
514
535
|
}
|
|
515
536
|
}, _callee20);
|
|
516
537
|
})));
|
|
517
|
-
it('should not load
|
|
538
|
+
it('should not load task list with notes', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
518
539
|
var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, TASK_LIST_WITH_NOTES, taskList;
|
|
519
540
|
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
520
541
|
while (1) switch (_context22.prev = _context22.next) {
|
|
@@ -567,7 +588,7 @@ describe('components', function () {
|
|
|
567
588
|
}, _callee22);
|
|
568
589
|
})));
|
|
569
590
|
it('should handle navigating between task list pages', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
570
|
-
var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, taskList, firstTaskStatus, secondTaskStatus, firstTask, newPage, continueButton, seaButton, cyaPageChange, modeChangeLink, changePage, airButton, cyaPage, finalSubmit;
|
|
591
|
+
var ON_SUBMIT_CALLS, ON_SUBMIT, HOOKS, taskList, firstTaskStatus, secondTaskStatus, firstTask, newPage, fieldset, continueButton, seaButton, cyaPageChange, modeChangeLink, changePage, airButton, cyaPage, finalSubmit;
|
|
571
592
|
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
572
593
|
while (1) switch (_context24.prev = _context24.next) {
|
|
573
594
|
case 0:
|
|
@@ -608,24 +629,8 @@ describe('components', function () {
|
|
|
608
629
|
// Fill first page and navigate
|
|
609
630
|
newPage = container.childNodes[0].childNodes[0];
|
|
610
631
|
expect(newPage.childNodes[0].textContent).toEqual('Event Date');
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
name: 'date-day',
|
|
614
|
-
value: '7'
|
|
615
|
-
}
|
|
616
|
-
});
|
|
617
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[1].childNodes[1], {
|
|
618
|
-
target: {
|
|
619
|
-
name: 'date-month',
|
|
620
|
-
value: '7'
|
|
621
|
-
}
|
|
622
|
-
});
|
|
623
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[2].childNodes[1], {
|
|
624
|
-
target: {
|
|
625
|
-
name: 'date-year',
|
|
626
|
-
value: '2022'
|
|
627
|
-
}
|
|
628
|
-
});
|
|
632
|
+
fieldset = newPage.childNodes[1].childNodes[0]; // child nodes of fieldset are legend and date
|
|
633
|
+
setDate(fieldset.children[1], ['7', '7', '2022']);
|
|
629
634
|
continueButton = newPage.childNodes[2].childNodes[0];
|
|
630
635
|
_react.fireEvent.click(continueButton, {});
|
|
631
636
|
|
|
@@ -676,14 +681,14 @@ describe('components', function () {
|
|
|
676
681
|
expect(finalSubmit.date).toEqual('7-7-2022');
|
|
677
682
|
expect(finalSubmit.mode).toEqual('air');
|
|
678
683
|
expect(finalSubmit.formStatus.tasks['Date, location and mode details'].complete).toEqual(true);
|
|
679
|
-
case
|
|
684
|
+
case 53:
|
|
680
685
|
case "end":
|
|
681
686
|
return _context24.stop();
|
|
682
687
|
}
|
|
683
688
|
}, _callee24);
|
|
684
689
|
})));
|
|
685
690
|
it('should go straight to CYA page if a complete task is selected', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
686
|
-
var ON_SUBMIT, HOOKS, taskList, newPage;
|
|
691
|
+
var ON_SUBMIT, HOOKS, taskList, newPage, fieldset;
|
|
687
692
|
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
688
693
|
while (1) switch (_context26.prev = _context26.next) {
|
|
689
694
|
case 0:
|
|
@@ -713,24 +718,10 @@ describe('components', function () {
|
|
|
713
718
|
|
|
714
719
|
// Fill first page and navigate
|
|
715
720
|
newPage = container.childNodes[0].childNodes[0];
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
}
|
|
721
|
-
});
|
|
722
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[1].childNodes[1], {
|
|
723
|
-
target: {
|
|
724
|
-
name: 'date-month',
|
|
725
|
-
value: '7'
|
|
726
|
-
}
|
|
727
|
-
});
|
|
728
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[2].childNodes[1], {
|
|
729
|
-
target: {
|
|
730
|
-
name: 'date-year',
|
|
731
|
-
value: '2022'
|
|
732
|
-
}
|
|
733
|
-
});
|
|
721
|
+
fieldset = newPage.childNodes[1].childNodes[0];
|
|
722
|
+
setDate(fieldset.children[1], ['7', '7', '2022']);
|
|
723
|
+
// child nodes of fieldset are legend and date
|
|
724
|
+
|
|
734
725
|
_react.fireEvent.click(newPage.childNodes[2].childNodes[0], {});
|
|
735
726
|
|
|
736
727
|
// Fill second page and navigate
|
|
@@ -746,7 +737,7 @@ describe('components', function () {
|
|
|
746
737
|
|
|
747
738
|
// Should be at CYA page
|
|
748
739
|
expect(container.childNodes[0].childNodes[0].childNodes[0].textContent).toEqual('Check your answers');
|
|
749
|
-
case
|
|
740
|
+
case 16:
|
|
750
741
|
case "end":
|
|
751
742
|
return _context26.stop();
|
|
752
743
|
}
|
|
@@ -803,7 +794,7 @@ describe('components', function () {
|
|
|
803
794
|
}, _callee28);
|
|
804
795
|
})));
|
|
805
796
|
it('should go to the first page of a complete task if noTaskCYAs specified', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
806
|
-
var ON_SUBMIT, HOOKS, TASK_LIST_WITH_NO_TASK_CYAS, taskList, newPage;
|
|
797
|
+
var ON_SUBMIT, HOOKS, TASK_LIST_WITH_NO_TASK_CYAS, taskList, newPage, fieldset;
|
|
807
798
|
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
808
799
|
while (1) switch (_context30.prev = _context30.next) {
|
|
809
800
|
case 0:
|
|
@@ -839,24 +830,8 @@ describe('components', function () {
|
|
|
839
830
|
|
|
840
831
|
// Fill first page and navigate
|
|
841
832
|
newPage = container.childNodes[0].childNodes[0];
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
name: 'date-day',
|
|
845
|
-
value: '7'
|
|
846
|
-
}
|
|
847
|
-
});
|
|
848
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[1].childNodes[1], {
|
|
849
|
-
target: {
|
|
850
|
-
name: 'date-month',
|
|
851
|
-
value: '7'
|
|
852
|
-
}
|
|
853
|
-
});
|
|
854
|
-
_react.fireEvent.change(newPage.childNodes[1].childNodes[0].childNodes[2].childNodes[2].childNodes[1], {
|
|
855
|
-
target: {
|
|
856
|
-
name: 'date-year',
|
|
857
|
-
value: '2022'
|
|
858
|
-
}
|
|
859
|
-
});
|
|
833
|
+
fieldset = newPage.childNodes[1].childNodes[0];
|
|
834
|
+
setDate(fieldset.children[1], ['7', '7', '2022']);
|
|
860
835
|
_react.fireEvent.click(newPage.childNodes[2].childNodes[0], {});
|
|
861
836
|
|
|
862
837
|
// Fill second page
|
|
@@ -870,7 +845,7 @@ describe('components', function () {
|
|
|
870
845
|
|
|
871
846
|
// Should be on the first page
|
|
872
847
|
expect(container.childNodes[0].childNodes[0].childNodes[0].textContent).toEqual('Event Date');
|
|
873
|
-
case
|
|
848
|
+
case 18:
|
|
874
849
|
case "end":
|
|
875
850
|
return _context30.stop();
|
|
876
851
|
}
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _Data = _interopRequireDefault(require("../Data"));
|
|
8
|
+
var _showComponent = _interopRequireDefault(require("./showComponent"));
|
|
8
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
10
|
/**
|
|
10
11
|
* Iterates over an array of components and brings any nested
|
|
@@ -35,16 +36,20 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
35
36
|
var elevateNestedComponents = function elevateNestedComponents(components, data) {
|
|
36
37
|
var allComponents = [];
|
|
37
38
|
components === null || components === void 0 ? void 0 : components.forEach(function (component) {
|
|
38
|
-
var _component$data;
|
|
39
39
|
allComponents.push(component);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
// If the component wasn't shown we shouldn't elevate anything nested under it
|
|
41
|
+
if ((0, _showComponent.default)(component, data)) {
|
|
42
|
+
var _component$data;
|
|
43
|
+
(_component$data = component.data) === null || _component$data === void 0 || (_component$data = _component$data.options) === null || _component$data === void 0 ? void 0 : _component$data.forEach(function (option) {
|
|
44
|
+
// If this option has nested components and is
|
|
45
|
+
// selected, then add its nested components to the array.
|
|
46
|
+
var sourceData = (data === null || data === void 0 ? void 0 : data[component.id]) || _Data.default.getSource(data, component.full_path);
|
|
47
|
+
// If the specific option wasn't shown we shouldn't elevate anything nested under it
|
|
48
|
+
if (Array.isArray(option.nested) && sourceData === option.value && (0, _showComponent.default)(option, data)) {
|
|
49
|
+
allComponents = allComponents.concat(option.nested);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
48
53
|
});
|
|
49
54
|
return allComponents;
|
|
50
55
|
};
|
|
@@ -119,4 +119,148 @@ describe('utils.Component.elevateNestedComponents', function () {
|
|
|
119
119
|
id: 'nestedTwo'
|
|
120
120
|
}]));
|
|
121
121
|
});
|
|
122
|
+
it('should not elevate nested components under a component which is hidden with a show_when', function () {
|
|
123
|
+
var COMPONENTS = [{
|
|
124
|
+
id: 'textComp'
|
|
125
|
+
}, {
|
|
126
|
+
id: 'radiosComp',
|
|
127
|
+
show_when: {
|
|
128
|
+
field: 'testField',
|
|
129
|
+
op: 'eq',
|
|
130
|
+
value: 'blue'
|
|
131
|
+
},
|
|
132
|
+
data: {
|
|
133
|
+
options: [{
|
|
134
|
+
label: 'Yes',
|
|
135
|
+
value: 'yes',
|
|
136
|
+
nested: [{
|
|
137
|
+
id: 'nestedOne'
|
|
138
|
+
}, {
|
|
139
|
+
id: 'nestedTwo'
|
|
140
|
+
}]
|
|
141
|
+
}, {
|
|
142
|
+
label: 'No',
|
|
143
|
+
value: 'no'
|
|
144
|
+
}]
|
|
145
|
+
}
|
|
146
|
+
}];
|
|
147
|
+
var DATA = {
|
|
148
|
+
radiosComp: 'yes',
|
|
149
|
+
testField: 'red'
|
|
150
|
+
};
|
|
151
|
+
expect((0, _elevateNestedComponents.default)(COMPONENTS, DATA)).toEqual([].concat(COMPONENTS));
|
|
152
|
+
});
|
|
153
|
+
it('should elevate nested components under a component which is shown with a show_When', function () {
|
|
154
|
+
var COMPONENTS = [{
|
|
155
|
+
id: 'textComp'
|
|
156
|
+
}, {
|
|
157
|
+
id: 'radiosComp',
|
|
158
|
+
show_when: {
|
|
159
|
+
field: 'testField',
|
|
160
|
+
op: 'eq',
|
|
161
|
+
value: 'red'
|
|
162
|
+
},
|
|
163
|
+
data: {
|
|
164
|
+
options: [{
|
|
165
|
+
label: 'Yes',
|
|
166
|
+
value: 'yes',
|
|
167
|
+
nested: [{
|
|
168
|
+
id: 'nestedOne'
|
|
169
|
+
}, {
|
|
170
|
+
id: 'nestedTwo'
|
|
171
|
+
}]
|
|
172
|
+
}, {
|
|
173
|
+
label: 'No',
|
|
174
|
+
value: 'no'
|
|
175
|
+
}]
|
|
176
|
+
}
|
|
177
|
+
}];
|
|
178
|
+
var DATA = {
|
|
179
|
+
radiosComp: 'yes',
|
|
180
|
+
testField: 'red'
|
|
181
|
+
};
|
|
182
|
+
expect((0, _elevateNestedComponents.default)(COMPONENTS, DATA)).toEqual([].concat(COMPONENTS, [{
|
|
183
|
+
id: 'nestedOne'
|
|
184
|
+
}, {
|
|
185
|
+
id: 'nestedTwo'
|
|
186
|
+
}]));
|
|
187
|
+
});
|
|
188
|
+
it('should elevate nested components under an option which is shown with a show_When', function () {
|
|
189
|
+
var COMPONENTS = [{
|
|
190
|
+
id: 'textComp'
|
|
191
|
+
}, {
|
|
192
|
+
id: 'radiosComp',
|
|
193
|
+
show_when: {
|
|
194
|
+
field: 'testField',
|
|
195
|
+
op: 'eq',
|
|
196
|
+
value: 'red'
|
|
197
|
+
},
|
|
198
|
+
data: {
|
|
199
|
+
options: [{
|
|
200
|
+
label: 'Yes',
|
|
201
|
+
value: 'yes',
|
|
202
|
+
nested: [{
|
|
203
|
+
id: 'nestedOne'
|
|
204
|
+
}, {
|
|
205
|
+
id: 'nestedTwo'
|
|
206
|
+
}],
|
|
207
|
+
show_when: {
|
|
208
|
+
field: 'testFieldTwo',
|
|
209
|
+
op: 'eq',
|
|
210
|
+
value: 'purple'
|
|
211
|
+
}
|
|
212
|
+
}, {
|
|
213
|
+
label: 'No',
|
|
214
|
+
value: 'no'
|
|
215
|
+
}]
|
|
216
|
+
}
|
|
217
|
+
}];
|
|
218
|
+
var DATA = {
|
|
219
|
+
radiosComp: 'yes',
|
|
220
|
+
testField: 'red',
|
|
221
|
+
testFieldTwo: 'purple'
|
|
222
|
+
};
|
|
223
|
+
expect((0, _elevateNestedComponents.default)(COMPONENTS, DATA)).toEqual([].concat(COMPONENTS, [{
|
|
224
|
+
id: 'nestedOne'
|
|
225
|
+
}, {
|
|
226
|
+
id: 'nestedTwo'
|
|
227
|
+
}]));
|
|
228
|
+
});
|
|
229
|
+
it('should not elevate nested components under an option which is hidden with a show_When', function () {
|
|
230
|
+
var COMPONENTS = [{
|
|
231
|
+
id: 'textComp'
|
|
232
|
+
}, {
|
|
233
|
+
id: 'radiosComp',
|
|
234
|
+
show_when: {
|
|
235
|
+
field: 'testField',
|
|
236
|
+
op: 'eq',
|
|
237
|
+
value: 'red'
|
|
238
|
+
},
|
|
239
|
+
data: {
|
|
240
|
+
options: [{
|
|
241
|
+
label: 'Yes',
|
|
242
|
+
value: 'yes',
|
|
243
|
+
nested: [{
|
|
244
|
+
id: 'nestedOne'
|
|
245
|
+
}, {
|
|
246
|
+
id: 'nestedTwo'
|
|
247
|
+
}],
|
|
248
|
+
show_when: {
|
|
249
|
+
field: 'testFieldTwo',
|
|
250
|
+
op: 'eq',
|
|
251
|
+
value: 'purple'
|
|
252
|
+
}
|
|
253
|
+
}, {
|
|
254
|
+
label: 'No',
|
|
255
|
+
value: 'no'
|
|
256
|
+
}]
|
|
257
|
+
}
|
|
258
|
+
}];
|
|
259
|
+
var DATA = {
|
|
260
|
+
radiosComp: 'yes',
|
|
261
|
+
testField: 'red',
|
|
262
|
+
testFieldTwo: 'orange'
|
|
263
|
+
};
|
|
264
|
+
expect((0, _elevateNestedComponents.default)(COMPONENTS, DATA)).toEqual([].concat(COMPONENTS));
|
|
265
|
+
});
|
|
122
266
|
});
|
|
@@ -28,53 +28,53 @@ describe('utils.Component.get', function () {
|
|
|
28
28
|
onChange: ON_CHANGE,
|
|
29
29
|
'data-testid': ID
|
|
30
30
|
};
|
|
31
|
+
var checkDateField = function checkDateField(node, option) {
|
|
32
|
+
expect(node.tagName).toEqual('DIV');
|
|
33
|
+
expect(node.classList).toContain('govuk-date-input__item');
|
|
34
|
+
var group = node.childNodes[0]; // form group
|
|
35
|
+
var _group$childNodes = _slicedToArray(group.childNodes, 2),
|
|
36
|
+
label = _group$childNodes[0],
|
|
37
|
+
input = _group$childNodes[1];
|
|
38
|
+
expect(label.tagName).toEqual('LABEL');
|
|
39
|
+
expect(label.classList).toContain('govuk-label');
|
|
40
|
+
expect(label.textContent).toEqual(option.label);
|
|
41
|
+
expect(input.tagName).toEqual('INPUT');
|
|
42
|
+
expect(input.id).toEqual(option.id);
|
|
43
|
+
return input;
|
|
44
|
+
};
|
|
31
45
|
var _render = (0, _react.render)((0, _getComponent.default)(COMPONENT)),
|
|
32
46
|
container = _render.container;
|
|
33
47
|
var _getAllByTestId = (0, _react.getAllByTestId)(container, ID),
|
|
34
48
|
_getAllByTestId2 = _slicedToArray(_getAllByTestId, 2),
|
|
35
49
|
formGroup = _getAllByTestId2[0],
|
|
36
|
-
|
|
50
|
+
dateInput = _getAllByTestId2[1];
|
|
37
51
|
expect(formGroup.tagName).toEqual('DIV');
|
|
38
52
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
39
53
|
var label = formGroup.childNodes[0];
|
|
40
54
|
expect(label.innerHTML).toContain(LABEL);
|
|
41
55
|
expect(label.getAttribute('for')).toEqual(ID);
|
|
42
|
-
expect(
|
|
43
|
-
expect(
|
|
44
|
-
expect(
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
expect(monthlabel.textContent).toEqual('Month');
|
|
62
|
-
var monthinput = monthitem.childNodes[1];
|
|
63
|
-
expect(monthinput.tagName).toEqual('INPUT');
|
|
64
|
-
expect(monthinput.id).toEqual("".concat(ID, "-month"));
|
|
65
|
-
var yearitem = dateinput.childNodes[2];
|
|
66
|
-
expect(yearitem.tagName).toEqual('DIV');
|
|
67
|
-
expect(yearitem.classList).toContain('govuk-date-input__item');
|
|
68
|
-
var yearlabel = yearitem.childNodes[0];
|
|
69
|
-
expect(yearlabel.tagName).toEqual('LABEL');
|
|
70
|
-
expect(yearlabel.classList).toContain('govuk-label');
|
|
71
|
-
expect(yearlabel.textContent).toEqual('Year');
|
|
72
|
-
var yearinput = yearitem.childNodes[1];
|
|
73
|
-
expect(yearinput.tagName).toEqual('INPUT');
|
|
74
|
-
expect(yearinput.id).toEqual("".concat(ID, "-year"));
|
|
56
|
+
expect(dateInput.tagName).toEqual('DIV');
|
|
57
|
+
expect(dateInput.classList).toContain('govuk-date-input');
|
|
58
|
+
expect(dateInput.id).toEqual(ID);
|
|
59
|
+
var _dateInput$childNodes = _slicedToArray(dateInput.childNodes, 3),
|
|
60
|
+
dayItem = _dateInput$childNodes[0],
|
|
61
|
+
monthItem = _dateInput$childNodes[1],
|
|
62
|
+
yearItem = _dateInput$childNodes[2];
|
|
63
|
+
var dayInput = checkDateField(dayItem, {
|
|
64
|
+
id: "".concat(ID, "-day"),
|
|
65
|
+
label: 'Day'
|
|
66
|
+
});
|
|
67
|
+
var monthInput = checkDateField(monthItem, {
|
|
68
|
+
id: "".concat(ID, "-month"),
|
|
69
|
+
label: 'Month'
|
|
70
|
+
});
|
|
71
|
+
var yearInput = checkDateField(yearItem, {
|
|
72
|
+
id: "".concat(ID, "-year"),
|
|
73
|
+
label: 'Year'
|
|
74
|
+
});
|
|
75
75
|
|
|
76
76
|
// Add something to the day and make sure it fires.
|
|
77
|
-
_react.fireEvent.change(
|
|
77
|
+
_react.fireEvent.change(dayInput, {
|
|
78
78
|
target: {
|
|
79
79
|
name: "".concat(FIELD_ID, "-day"),
|
|
80
80
|
value: '5'
|
|
@@ -86,7 +86,7 @@ describe('utils.Component.get', function () {
|
|
|
86
86
|
value: '5--'
|
|
87
87
|
});
|
|
88
88
|
// And now the month...
|
|
89
|
-
_react.fireEvent.change(
|
|
89
|
+
_react.fireEvent.change(monthInput, {
|
|
90
90
|
target: {
|
|
91
91
|
name: "".concat(FIELD_ID, "-month"),
|
|
92
92
|
value: '11'
|
|
@@ -98,7 +98,7 @@ describe('utils.Component.get', function () {
|
|
|
98
98
|
value: '5-11-'
|
|
99
99
|
});
|
|
100
100
|
// And finally the year.
|
|
101
|
-
_react.fireEvent.change(
|
|
101
|
+
_react.fireEvent.change(yearInput, {
|
|
102
102
|
target: {
|
|
103
103
|
name: "".concat(FIELD_ID, "-year"),
|
|
104
104
|
value: '2022'
|
|
@@ -63,9 +63,9 @@ describe('utils.Component.get', function () {
|
|
|
63
63
|
expect(input2.tagName).toEqual('DIV');
|
|
64
64
|
expect(input2.classList).toContain('govuk-date-input');
|
|
65
65
|
expect(input2.id).toEqual(ID2);
|
|
66
|
-
expect(input2.childNodes[0].childNodes[1].value).toEqual('1');
|
|
67
|
-
expect(input2.childNodes[1].childNodes[1].value).toEqual('2');
|
|
68
|
-
expect(input2.childNodes[2].childNodes[1].value).toEqual('2022');
|
|
66
|
+
expect(input2.childNodes[0].childNodes[0].childNodes[1].value).toEqual('1');
|
|
67
|
+
expect(input2.childNodes[1].childNodes[0].childNodes[1].value).toEqual('2');
|
|
68
|
+
expect(input2.childNodes[2].childNodes[0].childNodes[1].value).toEqual('2022');
|
|
69
69
|
case 35:
|
|
70
70
|
case "end":
|
|
71
71
|
return _context.stop();
|
|
@@ -61,7 +61,7 @@ describe('utils.Component.get', function () {
|
|
|
61
61
|
}].forEach(function (part) {
|
|
62
62
|
expect(part.item.tagName).toEqual('DIV');
|
|
63
63
|
expect(part.item.classList).toContain('govuk-date-input__item');
|
|
64
|
-
var _part$item$childNodes = _slicedToArray(part.item.childNodes, 2),
|
|
64
|
+
var _part$item$childNodes = _slicedToArray(part.item.childNodes[0].childNodes, 2),
|
|
65
65
|
inputLabel = _part$item$childNodes[0],
|
|
66
66
|
input = _part$item$childNodes[1];
|
|
67
67
|
expect(inputLabel.tagName).toEqual('LABEL');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ukhomeoffice/cop-react-form-renderer",
|
|
3
|
-
"version": "5.27.
|
|
3
|
+
"version": "5.27.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rimraf dist",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"post-compile": "rimraf dist/*.test.* dist/**/*.test.* dist/**/*.stories.* dist/docs dist/assets"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@ukhomeoffice/cop-react-components": "^3.
|
|
19
|
+
"@ukhomeoffice/cop-react-components": "^3.14.2",
|
|
20
20
|
"axios": "^0.23.0",
|
|
21
21
|
"dayjs": "^1.11.0",
|
|
22
22
|
"govuk-frontend": "^4.3.1",
|