@ukhomeoffice/cop-react-form-renderer 4.9.0 → 4.9.1
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/helpers/getComponentDisabled.js +2 -4
- package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +2 -0
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +1 -1
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +1 -0
- package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +4 -0
- package/dist/utils/Operate/persistValueInFormData.test.js +1 -0
- package/dist/utils/Operate/runPageOperations.test.js +2 -0
- package/dist/utils/Operate/setValueInFormData.test.js +1 -0
- package/package.json +1 -1
|
@@ -5,13 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
+
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
11
9
|
|
|
12
10
|
var getComponentDisabled = function getComponentDisabled(disabled, formData) {
|
|
13
11
|
if (typeof disabled === 'string') {
|
|
14
|
-
return !!
|
|
12
|
+
return !!_copReactComponents.Utils.interpolateString(disabled, formData);
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
return !!disabled;
|
|
@@ -18,9 +18,11 @@ describe('components.FormComponent.helpers.getComponentDisabled', function () {
|
|
|
18
18
|
expect((0, _getComponentDisabled.default)(true, DATA)).toEqual(true);
|
|
19
19
|
});
|
|
20
20
|
it('should interpolate correctly if disabled is a field path', function () {
|
|
21
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
21
22
|
expect((0, _getComponentDisabled.default)('${shouldDisable}', DATA)).toEqual(true);
|
|
22
23
|
});
|
|
23
24
|
it('should return false if interpolating a field that does not exist', function () {
|
|
25
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
24
26
|
expect((0, _getComponentDisabled.default)('${notARealField}', DATA)).toEqual(false);
|
|
25
27
|
});
|
|
26
28
|
});
|
|
@@ -38,7 +38,7 @@ describe('utils', function () {
|
|
|
38
38
|
it('should remove selected item from the form data', function () {
|
|
39
39
|
var data = null;
|
|
40
40
|
|
|
41
|
-
var ON_ACTION = function ON_ACTION(
|
|
41
|
+
var ON_ACTION = function ON_ACTION(_, call_back) {
|
|
42
42
|
data = call_back(TEST_DATA);
|
|
43
43
|
};
|
|
44
44
|
|
|
@@ -32,6 +32,7 @@ describe('Utils.Operate.getIndexOfPriorMatchingValueIn', function () {
|
|
|
32
32
|
expect(result).toEqual('2');
|
|
33
33
|
});
|
|
34
34
|
it('Should handle interpolated string for field', function () {
|
|
35
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
35
36
|
var CONFIG = {
|
|
36
37
|
target: 'arrayOfValues',
|
|
37
38
|
field: '${fieldName}'
|
|
@@ -62,6 +63,7 @@ describe('Utils.Operate.getIndexOfPriorMatchingValueIn', function () {
|
|
|
62
63
|
expect(result).toEqual(null); // Cutoff occurs before matching value is reached.
|
|
63
64
|
});
|
|
64
65
|
it('Should handle interpolated string for cutoff.field', function () {
|
|
66
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
65
67
|
var CONFIG = {
|
|
66
68
|
target: 'arrayOfValues',
|
|
67
69
|
value: 'cde',
|
|
@@ -95,6 +97,7 @@ describe('Utils.Operate.getIndexOfPriorMatchingValueIn', function () {
|
|
|
95
97
|
expect(result).toEqual(null); // Should ignore the matching value.
|
|
96
98
|
});
|
|
97
99
|
it('Should handle interpolated string for ignore.field', function () {
|
|
100
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
98
101
|
var CONFIG = {
|
|
99
102
|
target: 'arrayOfValues',
|
|
100
103
|
value: 'cde',
|
|
@@ -106,6 +109,7 @@ describe('Utils.Operate.getIndexOfPriorMatchingValueIn', function () {
|
|
|
106
109
|
expect(result).toEqual(null); // Should ignore the matching value.
|
|
107
110
|
});
|
|
108
111
|
it('Should handle interpolated string for target', function () {
|
|
112
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
109
113
|
var CONFIG = {
|
|
110
114
|
target: '${targetName}',
|
|
111
115
|
value: 'cde'
|
|
@@ -90,6 +90,7 @@ describe('Utils.Operate.persistValueInFormData', function () {
|
|
|
90
90
|
expect(ON_CHANGE_COUNT).toEqual(0);
|
|
91
91
|
});
|
|
92
92
|
it('Should correctly interpolate a field value', function () {
|
|
93
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
93
94
|
var CONFIG = {
|
|
94
95
|
name: 'alpha',
|
|
95
96
|
field: '${beta}'
|
|
@@ -63,6 +63,7 @@ describe('Utils.Operate.runPageOperations', function () {
|
|
|
63
63
|
}, {
|
|
64
64
|
output: 'secondOpResult',
|
|
65
65
|
function: 'setValueInFormData',
|
|
66
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
66
67
|
field: '${firstOpResult}'
|
|
67
68
|
}]
|
|
68
69
|
};
|
|
@@ -77,6 +78,7 @@ describe('Utils.Operate.runPageOperations', function () {
|
|
|
77
78
|
operations: [{
|
|
78
79
|
function: 'setValueInFormData',
|
|
79
80
|
value: 'leaf',
|
|
81
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
80
82
|
output: '${delta}.trunk.branch'
|
|
81
83
|
}]
|
|
82
84
|
};
|
|
@@ -25,6 +25,7 @@ describe('Utils.Operate.addToFormData', function () {
|
|
|
25
25
|
expect(result).toEqual(DATA.a);
|
|
26
26
|
});
|
|
27
27
|
it('Should handle interpolated field strings', function () {
|
|
28
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
28
29
|
var CONFIG = {
|
|
29
30
|
field: 'b[${indexOfThree}]'
|
|
30
31
|
};
|