@ukhomeoffice/cop-react-form-renderer 5.74.5 → 5.74.6

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.
@@ -14,6 +14,11 @@ exports.default = void 0;
14
14
  */
15
15
  var optionIsSelected = function optionIsSelected(componentValue, option) {
16
16
  if (Array.isArray(componentValue)) {
17
+ if (option.refdata_match) {
18
+ return componentValue.some(function (v) {
19
+ return v.id === option.refdata_match.id;
20
+ });
21
+ }
17
22
  return componentValue.includes(option.value);
18
23
  }
19
24
  return componentValue === option.value;
@@ -11,6 +11,20 @@ describe('utils.Component.isSelected', function () {
11
11
  value: SELECTED_VALUE
12
12
  }, {
13
13
  value: NOT_SELECTED_VALUE
14
+ }, {
15
+ refdata_match: {
16
+ id: 99
17
+ },
18
+ nested: {
19
+ value: true
20
+ }
21
+ }, {
22
+ refdata_match: {
23
+ id: 100
24
+ },
25
+ nested: {
26
+ value: true
27
+ }
14
28
  }];
15
29
  var COMPONENT = {
16
30
  id: 'a',
@@ -29,6 +43,18 @@ describe('utils.Component.isSelected', function () {
29
43
  expect((0, _optionIsSelected.default)(PAGE.formData[COMPONENT.id], OPTIONS[0])).toEqual(true);
30
44
  expect((0, _optionIsSelected.default)(PAGE.formData[COMPONENT.id], OPTIONS[1])).toEqual(false);
31
45
  });
46
+ it('should properly identify which option is selected for checkboxes using refdata_match', function () {
47
+ var PAGE = {
48
+ formData: {
49
+ a: [{
50
+ id: 99
51
+ }]
52
+ }
53
+ };
54
+ COMPONENT.type = 'checkboxes';
55
+ expect((0, _optionIsSelected.default)(PAGE.formData[COMPONENT.id], OPTIONS[2])).toEqual(true);
56
+ expect((0, _optionIsSelected.default)(PAGE.formData[COMPONENT.id], OPTIONS[3])).toEqual(false);
57
+ });
32
58
  it('should properly identify which option is selected for radios', function () {
33
59
  var PAGE = {
34
60
  formData: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "5.74.5",
3
+ "version": "5.74.6",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",