@ukhomeoffice/cop-react-form-renderer 4.32.2 → 4.32.3

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.
@@ -174,26 +174,26 @@ describe('utils.CollectionPage.mergeCollectionPages', function () {
174
174
  },
175
175
  components: [{
176
176
  type: 'text',
177
- show_when: [{
177
+ show_when: {
178
178
  field: 'field',
179
179
  op: '=',
180
180
  value: 'value'
181
- }]
181
+ }
182
182
  }, {
183
183
  type: 'container',
184
184
  components: [{
185
185
  type: 'date',
186
- show_when: [{
186
+ show_when: {
187
187
  field: 'field',
188
188
  op: '=',
189
189
  value: 'otherValue'
190
- }]
190
+ }
191
191
  }],
192
- show_when: [{
192
+ show_when: {
193
193
  field: 'field',
194
194
  op: '=',
195
195
  value: 'otherValue'
196
- }]
196
+ }
197
197
  }],
198
198
  formData: {}
199
199
  });
@@ -36,7 +36,7 @@ var addShowWhen = function addShowWhen(component, condition) {
36
36
  if (result.show_when) {
37
37
  result.show_when = Array.isArray(result.show_when) ? [].concat(result.show_when, [_objectSpread({}, condition)]) : [result.show_when, _objectSpread({}, condition)];
38
38
  } else {
39
- result.show_when = condition.type === 'or' ? result.show_when = _objectSpread({}, condition) : result.show_when = [_objectSpread({}, condition)];
39
+ result.show_when = condition;
40
40
  }
41
41
 
42
42
  return result;
@@ -44,7 +44,27 @@ describe('utils.Component.addShowWhen', function () {
44
44
  var result = (0, _addShowWhen.default)(COMPONENT, NEW_SHOW_WHEN);
45
45
  expect(result).toEqual({
46
46
  alpha: 'bravo',
47
- show_when: [NEW_SHOW_WHEN]
47
+ show_when: NEW_SHOW_WHEN
48
+ });
49
+ });
50
+ it('should add the array type show_when to a component with no existing show_whens', function () {
51
+ var NEW_ARRAY_SHOW_WHEN = [{
52
+ field: 'abc',
53
+ op: '=',
54
+ value: 'bcd'
55
+ }, {
56
+ field: 'cde',
57
+ op: '=',
58
+ value: 'efg'
59
+ }];
60
+ var COMPONENT = {
61
+ alpha: 'bravo'
62
+ };
63
+ var result = (0, _addShowWhen.default)(COMPONENT, NEW_ARRAY_SHOW_WHEN);
64
+ console.log(result);
65
+ expect(result).toEqual({
66
+ alpha: 'bravo',
67
+ show_when: NEW_ARRAY_SHOW_WHEN
48
68
  });
49
69
  });
50
70
  it('should add the show_when to a component with a single show_when', function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "4.32.2",
3
+ "version": "4.32.3",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",