@ukhomeoffice/cop-react-form-renderer 5.69.0 → 5.70.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.
|
@@ -26,6 +26,10 @@ var interpolateOptions = function interpolateOptions(config, options) {
|
|
|
26
26
|
if (typeof opt === 'string') {
|
|
27
27
|
return opt;
|
|
28
28
|
}
|
|
29
|
+
if (config.alternativeHintField) {
|
|
30
|
+
// eslint-disable-next-line no-param-reassign
|
|
31
|
+
opt.hint = opt[config.alternativeHintField];
|
|
32
|
+
}
|
|
29
33
|
return _objectSpread(_objectSpread({}, opt), {}, {
|
|
30
34
|
value: _copReactComponents.Utils.interpolateString(opt.value, config.formData),
|
|
31
35
|
label: _copReactComponents.Utils.interpolateString(opt.label, config.formData)
|
|
@@ -190,6 +190,24 @@ describe('utils', function () {
|
|
|
190
190
|
expect(options).toEqual(MERGED_CONFIG);
|
|
191
191
|
});
|
|
192
192
|
});
|
|
193
|
+
it('should override the hint if specified in the config', function () {
|
|
194
|
+
var CONFIG = {
|
|
195
|
+
alternativeHintField: 'description',
|
|
196
|
+
options: [{
|
|
197
|
+
value: 'a',
|
|
198
|
+
label: 'Alpha',
|
|
199
|
+
description: 'first'
|
|
200
|
+
}, {
|
|
201
|
+
value: 'b',
|
|
202
|
+
label: 'Bravo',
|
|
203
|
+
description: 'second'
|
|
204
|
+
}]
|
|
205
|
+
};
|
|
206
|
+
(0, _getOptions.default)(CONFIG, function (options) {
|
|
207
|
+
expect(options[0].hint).toEqual(CONFIG.options[0].description);
|
|
208
|
+
expect(options[1].hint).toEqual(CONFIG.options[1].description);
|
|
209
|
+
});
|
|
210
|
+
});
|
|
193
211
|
});
|
|
194
212
|
});
|
|
195
213
|
});
|