@ukhomeoffice/cop-react-form-renderer 4.22.4-charlie → 4.22.5

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.
@@ -24,15 +24,15 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
24
24
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
25
25
 
26
26
  var getCYARowsForContainer = function getCYARowsForContainer(page, container, formData, onAction) {
27
- if ((0, _showComponentCYA.default)(container, page.formData)) {
27
+ if ((0, _showComponentCYA.default)(container, _objectSpread(_objectSpread({}, page.formData), formData))) {
28
28
  var allComponents = (0, _elevateNestedComponents.default)(container.components, formData);
29
29
  return allComponents.filter(function (c) {
30
- return (0, _showComponentCYA.default)(c, page.formData);
30
+ return (0, _showComponentCYA.default)(c, _objectSpread(_objectSpread({}, page.formData), formData));
31
31
  }).flatMap(function (component) {
32
32
  var fd = formData ? formData[component.fieldId] : undefined;
33
33
 
34
34
  if (component.type === _models.ComponentTypes.CONTAINER) {
35
- return getCYARowsForContainer(page, component, fd, onAction);
35
+ return getCYARowsForContainer(page, component, _objectSpread(_objectSpread({}, fd), formData), onAction);
36
36
  }
37
37
 
38
38
  if (component.type === _models.ComponentTypes.COLLECTION) {
@@ -320,6 +320,44 @@ describe('utils.CheckYourAnswers.getCYARowsForContainer', function () {
320
320
  checkTitleRow(1, ROWS[2]);
321
321
  checkValueRow(1, ROWS[3], 'Charlie');
322
322
  });
323
+ it('should conditionally show an appropriate row for a single text component inside a container belonging to a partial-collection', function () {
324
+ var OUTER_ID = 'a';
325
+ var INNER_ID = 'b';
326
+ var FORM_DATA = {
327
+ collectionName: [{
328
+ container: _defineProperty({}, INNER_ID, 'Bravo'),
329
+ other_data: true
330
+ }, {
331
+ container: _defineProperty({}, INNER_ID, 'Charlie'),
332
+ other_data: false
333
+ }]
334
+ };
335
+ var PAGE = {
336
+ id: 'page',
337
+ formData: FORM_DATA,
338
+ cya_link: {},
339
+ collection: 'collectionName'
340
+ };
341
+ var CONTAINER = {
342
+ id: 'container',
343
+ fieldId: 'container',
344
+ type: _models.ComponentTypes.CONTAINER,
345
+ components: [{
346
+ id: INNER_ID,
347
+ fieldId: INNER_ID,
348
+ label: INNER_ID,
349
+ type: 'text'
350
+ }],
351
+ formData: FORM_DATA,
352
+ show_when: {
353
+ field: 'other_data',
354
+ op: '=',
355
+ value: true
356
+ }
357
+ };
358
+ expect((0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.collectionName[0], function () {}).length).toEqual(1);
359
+ expect((0, _getCYARowsForContainer.default)(PAGE, CONTAINER, FORM_DATA.collectionName[1], function () {})).toBeFalsy();
360
+ });
323
361
  it('should get the appropriate number for rows components with nested components inside a container', function () {
324
362
  var FORM_DATA = {
325
363
  container: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "4.22.4-charlie",
3
+ "version": "4.22.5",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",