@ukhomeoffice/cop-react-form-renderer 5.81.0 → 5.82.0

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.
@@ -168,7 +168,7 @@ var SummaryCardDetails = function SummaryCardDetails(_ref) {
168
168
  className: classes('section')
169
169
  }, !hideChildSectionTitles && /*#__PURE__*/_react.default.createElement("h3", {
170
170
  className: classes('section-title')
171
- }, section.title), /*#__PURE__*/_react.default.createElement("div", {
171
+ }, _utils.default.FormPage.getConditionalText(section.title, _objectSpread(_objectSpread({}, childPage.formData), entryData))), /*#__PURE__*/_react.default.createElement("div", {
172
172
  className: classes('section-content'),
173
173
  style: {
174
174
  '--dividers': columns.length - 1
@@ -156,16 +156,21 @@ describe('components.CollectionSummary.SummaryCardDetails', function () {
156
156
  expect(section1Content.textContent).toContain('subThreeLabel');
157
157
  expect(section1Content.textContent).toContain('charlie');
158
158
  });
159
- it('should render sections containing collections based on summaryLayout config', function () {
159
+ it('should render sections containing collections with dynamic titles based on summaryLayout config', function () {
160
+ var FORM_DATA = {
161
+ dummyTitleContent: "Kellogg's"
162
+ };
160
163
  var CHILD_PAGES = [{
161
164
  summaryLayout: {
162
165
  sections: [{
163
- title: 'Section 1',
166
+ // eslint-disable-next-line no-template-curly-in-string
167
+ title: 'Section 1 - ${dummyTitleContent}',
164
168
  columns: [{
165
169
  fields: ['collectionComponent']
166
170
  }]
167
171
  }]
168
172
  },
173
+ formData: FORM_DATA,
169
174
  components: [{
170
175
  fieldId: 'collectionComponent',
171
176
  id: 'collectionComponent',
@@ -221,17 +226,13 @@ describe('components.CollectionSummary.SummaryCardDetails', function () {
221
226
  })),
222
227
  container = _renderWithValidation3.container;
223
228
 
224
- // Function to find an element by its text content
225
- function getByTextContent(parent, text) {
226
- return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
227
- return el.textContent === text;
228
- });
229
- }
230
-
231
229
  // Check for section title
232
- var section1Title = getByTextContent(container, 'Section 1');
230
+ var section1Title = container.querySelector(".".concat(classes('section-title')));
233
231
  expect(section1Title).not.toBeUndefined();
234
232
 
233
+ // Check for embedded variables in title
234
+ expect(section1Title.textContent).toEqual("Section 1 - Kellogg's");
235
+
235
236
  // All four subcomponents from the container should have labels and values displayed
236
237
  var section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
237
238
  expect(section1Content.textContent).toContain('North');
@@ -11,6 +11,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
  var _models = require("../../models");
12
12
  var _utils = _interopRequireDefault(require("../../utils"));
13
13
  var _FormComponent = _interopRequireDefault(require("./FormComponent"));
14
+ var _getSourceData = _interopRequireDefault(require("../../utils/Data/getSourceData"));
14
15
  var _excluded = ["container", "value", "formData", "onChange", "wrap", "onTopLevelChange"]; // Global imports
15
16
  // Local imports
16
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -58,7 +59,7 @@ var Container = function Container(_ref) {
58
59
  }
59
60
  return _utils.default.Component.show(_objectSpread(_objectSpread({}, options), {}, {
60
61
  full_path: fullPath
61
- }), formData);
62
+ }), _objectSpread(_objectSpread({}, formData), (0, _getSourceData.default)(formData, container.full_path)));
62
63
  };
63
64
  var classes = _utils.default.classBuilder(DEFAULT_CLASS, [], container.className);
64
65
  var cleanedAttrs = _copReactComponents.Utils.cleanHtmlAttributes(attrs);
@@ -368,4 +368,73 @@ describe('components.FormComponent.Container', function () {
368
368
  }
369
369
  }, _callee7);
370
370
  })));
371
+ it('should render a container component appropriately with show_whens referencing other components in the container', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
372
+ var _ID2;
373
+ var TEXT_COMPONENT_CONDITIONAL, FORM_DATA_CONDITIONAL, CONTAINER, _renderWithValidation8, container, c, formGroup, label, input, formGroup2, label2, input2;
374
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
375
+ while (1) switch (_context8.prev = _context8.next) {
376
+ case 0:
377
+ TEXT_COMPONENT_CONDITIONAL = {
378
+ id: 'textTwo',
379
+ fieldId: 'textTwo',
380
+ type: _models.ComponentTypes.TEXT,
381
+ label: 'Text component 2',
382
+ show_when: {
383
+ field: TEXT_ID,
384
+ op: '=',
385
+ value: 'other'
386
+ }
387
+ };
388
+ FORM_DATA_CONDITIONAL = _defineProperty({}, ID, (_ID2 = {}, _defineProperty(_ID2, TEXT_ID, 'other'), _defineProperty(_ID2, "textTwo", 'blue'), _ID2));
389
+ CONTAINER = {
390
+ id: ID,
391
+ fieldId: ID,
392
+ type: _models.ComponentTypes.CONTAINER,
393
+ components: [TEXT_COMPONENT, TEXT_COMPONENT_CONDITIONAL],
394
+ full_path: ID
395
+ };
396
+ _renderWithValidation8 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_FormComponent.default, {
397
+ component: CONTAINER,
398
+ value: FORM_DATA_CONDITIONAL[ID],
399
+ formData: FORM_DATA_CONDITIONAL
400
+ })), container = _renderWithValidation8.container; // Check the container itself.
401
+ c = container.childNodes[0];
402
+ expect(c.tagName).toEqual('DIV');
403
+ expect(c.classList).toContain(_Container.DEFAULT_CLASS);
404
+
405
+ // And now check the first text component within it.
406
+ formGroup = c.childNodes[0];
407
+ expect(formGroup.tagName).toEqual('DIV');
408
+ expect(formGroup.classList).toContain('govuk-form-group');
409
+ label = formGroup.childNodes[0];
410
+ expect(label.tagName).toEqual('LABEL');
411
+ expect(label.classList).toContain('govuk-label');
412
+ expect(label.textContent).toEqual("".concat(TEXT_COMPONENT.label, " (optional)"));
413
+ expect(label.getAttribute('for')).toEqual("".concat(ID, ".").concat(TEXT_ID));
414
+ input = formGroup.childNodes[2];
415
+ expect(input.tagName).toEqual('INPUT');
416
+ expect(input.classList).toContain('govuk-input');
417
+ expect(input.id).toEqual("".concat(ID, ".").concat(TEXT_ID));
418
+ expect(input.value).toEqual('other');
419
+
420
+ // And now check the second text component within it that should have passed the show_when
421
+ formGroup2 = c.childNodes[1];
422
+ expect(formGroup2.tagName).toEqual('DIV');
423
+ expect(formGroup2.classList).toContain('govuk-form-group');
424
+ label2 = formGroup2.childNodes[0];
425
+ expect(label2.tagName).toEqual('LABEL');
426
+ expect(label2.classList).toContain('govuk-label');
427
+ expect(label2.textContent).toEqual("".concat(TEXT_COMPONENT.label, " 2 (optional)"));
428
+ expect(label2.getAttribute('for')).toEqual("".concat(ID, ".").concat(TEXT_ID, "Two"));
429
+ input2 = formGroup2.childNodes[2];
430
+ expect(input2.tagName).toEqual('INPUT');
431
+ expect(input2.classList).toContain('govuk-input');
432
+ expect(input2.id).toEqual("".concat(ID, ".").concat(TEXT_ID, "Two"));
433
+ expect(input2.value).toEqual('blue');
434
+ case 33:
435
+ case "end":
436
+ return _context8.stop();
437
+ }
438
+ }, _callee8);
439
+ })));
371
440
  });
@@ -352,6 +352,7 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
352
352
  onTaskAction: function onTaskAction(task) {
353
353
  (0, _onTaskAction2.default)(task, pages, setCurrentTask, hubDetails, data, onPageChange);
354
354
  },
355
+ annotations: (hubDetails === null || hubDetails === void 0 ? void 0 : hubDetails.taskListAnnotations) || [],
355
356
  formData: data
356
357
  })), formState.page && !formState.cya && !formState.page.collection && /*#__PURE__*/_react.default.createElement(_FormPage.default, {
357
358
  page: formState.page,
@@ -12,7 +12,7 @@ var _models = require("../../models");
12
12
  var _Task = _interopRequireDefault(require("./Task"));
13
13
  var _showComponent = _interopRequireDefault(require("../../utils/Component/showComponent"));
14
14
  require("./TaskList.scss");
15
- var _excluded = ["id", "refTitle", "refNumber", "notes", "incompleteTitle", "sections", "fieldId", "onTaskAction", "classBlock", "classModifiers", "className", "formData"];
15
+ var _excluded = ["id", "refTitle", "refNumber", "notes", "incompleteTitle", "sections", "fieldId", "onTaskAction", "classBlock", "classModifiers", "className", "formData", "annotations"];
16
16
  /* eslint-disable import/no-duplicates */
17
17
  // Global Imports
18
18
  // Local Imports
@@ -43,6 +43,7 @@ var TaskList = function TaskList(_ref) {
43
43
  classModifiers = _ref.classModifiers,
44
44
  className = _ref.className,
45
45
  formData = _ref.formData,
46
+ annotations = _ref.annotations,
46
47
  attrs = _objectWithoutProperties(_ref, _excluded);
47
48
  var classes = _copReactComponents.Utils.classBuilder(classBlock, classModifiers, className);
48
49
  var cleanedHtmlAttrs = _copReactComponents.Utils.cleanHtmlAttributes(attrs);
@@ -78,7 +79,15 @@ var TaskList = function TaskList(_ref) {
78
79
  className: "tasklist-summary"
79
80
  }, "".concat(refTitle))), /*#__PURE__*/_react.default.createElement("p", {
80
81
  className: "govuk-body govuk-!-font-weight-regular"
81
- }, "".concat(refNumber))), totalSections !== completeSections && /*#__PURE__*/_react.default.createElement("p", {
82
+ }, "".concat(refNumber))), annotations.length > 0 && annotations.map(function (annotation) {
83
+ return /*#__PURE__*/_react.default.createElement("div", {
84
+ className: classes('annotation')
85
+ }, /*#__PURE__*/_react.default.createElement("p", {
86
+ className: "".concat(classes('annotation-key'), " govuk-body")
87
+ }, _copReactComponents.Utils.interpolateString(annotation.key, formData)), /*#__PURE__*/_react.default.createElement("p", {
88
+ className: "".concat(classes('annotation-value'), " govuk-body")
89
+ }, _copReactComponents.Utils.interpolateString(annotation.value, formData)));
90
+ }), totalSections !== completeSections && /*#__PURE__*/_react.default.createElement("p", {
82
91
  className: "govuk-body govuk-!-margin-bottom-0"
83
92
  }, /*#__PURE__*/_react.default.createElement("strong", {
84
93
  className: "tasklist-summary"
@@ -139,7 +148,11 @@ TaskList.propTypes = {
139
148
  firstPage: _propTypes.default.string,
140
149
  alwaysShowFirstPage: _propTypes.default.bool
141
150
  })).isRequired
142
- })).isRequired
151
+ })).isRequired,
152
+ annotations: _propTypes.default.arrayOf(_propTypes.default.shape({
153
+ key: _propTypes.default.string,
154
+ value: _propTypes.default.string
155
+ }))
143
156
  };
144
157
  TaskList.defaultProps = {
145
158
  classBlock: DEFAULT_CLASS,
@@ -152,6 +165,7 @@ TaskList.defaultProps = {
152
165
  notes: {},
153
166
  onTaskAction: undefined,
154
167
  refNumber: undefined,
155
- refTitle: undefined
168
+ refTitle: undefined,
169
+ annotations: []
156
170
  };
157
171
  var _default = exports.default = TaskList;
@@ -58,6 +58,26 @@
58
58
  }
59
59
  }
60
60
 
61
+ .hods-task-list__annotation {
62
+ display: flex;
63
+ flex-flow: row wrap;
64
+ margin-bottom: govuk-spacing(2);
65
+
66
+ .hods-task-list__annotation-key {
67
+ font-weight: bold;
68
+ margin-top: 0;
69
+ margin-bottom: 0;
70
+ margin-right: govuk-spacing(1)
71
+ }
72
+
73
+ .hods-task-list__annotation-value {
74
+ font-weight: normal;
75
+ margin-top: 0;
76
+ margin-bottom: 0;
77
+ }
78
+
79
+ }
80
+
61
81
  .hods-task-list__task-name {
62
82
  display: block;
63
83
  cursor: auto;
@@ -101,6 +101,73 @@ describe('components', function () {
101
101
  expect(subSectionTwoLabel.textContent).toEqual('This is the label for your extra tasks');
102
102
  expect(subSectionTwoList.childNodes.length).toEqual(3);
103
103
  });
104
+ it('should render any provided annotations', function () {
105
+ var COP_REF = '123';
106
+ var REF_TITLE = 'COP reference number';
107
+ var sections = [{
108
+ name: 'These are your tasks',
109
+ label: 'This is the label for your first tasks',
110
+ tasks: [{
111
+ name: 'Nice task',
112
+ state: 'complete',
113
+ pages: ['pageOne']
114
+ }, {
115
+ name: 'Ok task',
116
+ state: 'inProgress',
117
+ pages: ['pageTwo']
118
+ }, {
119
+ name: 'Terrible task',
120
+ state: 'notStarted',
121
+ pages: ['pageThree']
122
+ }]
123
+ }, {
124
+ name: 'These are your extra bonus tasks',
125
+ label: 'This is the label for your extra tasks',
126
+ tasks: [{
127
+ name: 'Nice task',
128
+ state: 'complete',
129
+ pages: ['pageFour']
130
+ }, {
131
+ name: 'Ok task',
132
+ state: 'cannotStartYet',
133
+ pages: ['pageFive']
134
+ }, {
135
+ name: 'Terrible task',
136
+ state: 'cannotStartYet',
137
+ pages: ['pageSix']
138
+ }]
139
+ }];
140
+ var FORM_DATA = {
141
+ port: {
142
+ name: 'Heathrow Airport'
143
+ }
144
+ };
145
+ var ANNOTATIONS = [{
146
+ key: 'Port',
147
+ // eslint-disable-next-line no-template-curly-in-string
148
+ value: '${port.name}'
149
+ }];
150
+ var _render2 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
151
+ refNumber: COP_REF,
152
+ refTitle: REF_TITLE,
153
+ sections: sections,
154
+ annotations: ANNOTATIONS,
155
+ formData: FORM_DATA
156
+ })),
157
+ container = _render2.container;
158
+ var childNodes = container.childNodes;
159
+ expect(childNodes.length).toEqual(1);
160
+ expect(childNodes[0].childNodes.length).toEqual(11);
161
+ var annotation = childNodes[0].childNodes[2];
162
+ expect(annotation.children[0]).toMatchObject({
163
+ tagName: 'P',
164
+ textContent: 'Port'
165
+ });
166
+ expect(annotation.childNodes[1]).toMatchObject({
167
+ tagName: 'P',
168
+ textContent: 'Heathrow Airport'
169
+ });
170
+ });
104
171
  it('should not show incomplete title if form is complete', function () {
105
172
  var COP_REF = '123';
106
173
  var REF_TITLE = 'COP reference number';
@@ -135,12 +202,12 @@ describe('components', function () {
135
202
  pages: ['pageSix']
136
203
  }]
137
204
  }];
138
- var _render2 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
205
+ var _render3 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
139
206
  refNumber: COP_REF,
140
207
  refTitle: REF_TITLE,
141
208
  sections: sections
142
209
  })),
143
- container = _render2.container;
210
+ container = _render3.container;
144
211
  var childNodes = container.childNodes;
145
212
  expect(childNodes[0].childNodes.length).toEqual(7);
146
213
  var _childNodes$0$childNo2 = _slicedToArray(childNodes[0].childNodes, 3),
@@ -179,12 +246,12 @@ describe('components', function () {
179
246
  pages: ['pageThree']
180
247
  }]
181
248
  }];
182
- var _render3 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
249
+ var _render4 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
183
250
  refNumber: COP_REF,
184
251
  refTitle: REF_TITLE,
185
252
  sections: sections
186
253
  })),
187
- container = _render3.container;
254
+ container = _render4.container;
188
255
  var childNodes = container.childNodes;
189
256
  var subSectionOne = childNodes[0].childNodes[4];
190
257
  expect(subSectionOne.childNodes[0].textContent).toEqual('');
@@ -223,11 +290,11 @@ describe('components', function () {
223
290
  pages: ['pageSix']
224
291
  }]
225
292
  }];
226
- var _render4 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
293
+ var _render5 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
227
294
  refNumber: COP_REF,
228
295
  sections: sections
229
296
  })),
230
- container = _render4.container;
297
+ container = _render5.container;
231
298
  var childNodes = container.childNodes;
232
299
  expect(childNodes.length).toEqual(1);
233
300
  expect(childNodes[0].childNodes.length).toEqual(6);
@@ -273,12 +340,12 @@ describe('components', function () {
273
340
  pages: ['pageSix']
274
341
  }]
275
342
  }];
276
- var _render5 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
343
+ var _render6 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
277
344
  refNumber: COP_REF,
278
345
  sections: sections,
279
346
  incompleteTitle: INCOMPLETE_TITLE
280
347
  })),
281
- container = _render5.container;
348
+ container = _render6.container;
282
349
  var childNodes = container.childNodes;
283
350
  // The first child is now the incomplete text.
284
351
  var incompleteForm = childNodes[0].childNodes[0];
@@ -319,12 +386,12 @@ describe('components', function () {
319
386
  pages: ['pageSix']
320
387
  }]
321
388
  }];
322
- var _render6 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
389
+ var _render7 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
323
390
  refNumber: COP_REF,
324
391
  sections: sections,
325
392
  incompleteTitle: INCOMPLETE_TITLE
326
393
  })),
327
- container = _render6.container;
394
+ container = _render7.container;
328
395
  var childNodes = container.childNodes;
329
396
  expect(childNodes.length).toEqual(1);
330
397
  var children = childNodes[0].childNodes;
@@ -357,13 +424,13 @@ describe('components', function () {
357
424
  pages: ['pageThree']
358
425
  }]
359
426
  }];
360
- var _render7 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
427
+ var _render8 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskList.default, {
361
428
  refNumber: COP_REF,
362
429
  refTitle: REF_TITLE,
363
430
  sections: sections,
364
431
  onTaskAction: ON_CLICK
365
432
  })),
366
- container = _render7.container;
433
+ container = _render8.container;
367
434
  var taskList = container.childNodes[0].childNodes[5].childNodes;
368
435
  var firstTask = taskList[0].childNodes[0].childNodes[0];
369
436
  var secondTask = taskList[1].childNodes[0].childNodes[0];
@@ -19,7 +19,12 @@ var _validateRequired = _interopRequireDefault(require("./validateRequired"));
19
19
  var _validateTextArea = _interopRequireDefault(require("./validateTextArea"));
20
20
  var _validateTime = _interopRequireDefault(require("./validateTime"));
21
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } // Local imports
22
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
23
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
24
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
25
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
26
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
27
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } // Local imports
23
28
  /**
24
29
  * Validates a single component.
25
30
  * @param {object} component The component to validate.
@@ -29,7 +34,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
29
34
  */
30
35
  var validateComponent = function validateComponent(component, outerData, formData) {
31
36
  var fd = formData || outerData;
32
- if (!(0, _showComponent.default)(component, fd)) {
37
+ if (!(0, _showComponent.default)(component, _objectSpread(_objectSpread({}, fd), outerData))) {
33
38
  return undefined;
34
39
  }
35
40
  if (component.type === _models.ComponentTypes.CONTAINER) {
@@ -182,6 +182,37 @@ describe('utils.Validate.Component', function () {
182
182
  var DATA = _defineProperty({}, ID, _defineProperty({}, EMAIL_ID, 'alpha.bravo@digital.homeoffice.gov.uk'));
183
183
  expect((0, _validateComponent.default)(CONTAINER, DATA)).toEqual([]);
184
184
  });
185
+ it('should return an empty array when the container has only valid components', function () {
186
+ var TEXT_COMPONENT = {
187
+ id: 'one',
188
+ fieldId: 'one',
189
+ type: _models.ComponentTypes.TEXT,
190
+ label: 'Text component one'
191
+ };
192
+ var TEXT_COMPONENT_TWO = {
193
+ id: 'two',
194
+ fieldId: 'two',
195
+ type: _models.ComponentTypes.TEXT,
196
+ label: 'Text component two',
197
+ required: true,
198
+ show_when: {
199
+ field: 'one',
200
+ op: '=',
201
+ value: 'other'
202
+ }
203
+ };
204
+ var ID = 'container';
205
+ var LABEL = 'field';
206
+ var CONTAINER = setup(ID, _models.ComponentTypes.CONTAINER, LABEL, false);
207
+ CONTAINER.components = [TEXT_COMPONENT, TEXT_COMPONENT_TWO];
208
+ var DATA = _defineProperty({}, ID, {
209
+ one: 'other'
210
+ });
211
+ var errors = (0, _validateComponent.default)(CONTAINER, DATA, {
212
+ colour: 'blue'
213
+ });
214
+ expect(errors.length).toEqual(1);
215
+ });
185
216
  });
186
217
  describe('when the component is a collection', function () {
187
218
  it('should return an empty array when the collection has only valid items', function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "5.81.0",
3
+ "version": "5.82.0",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",