@ukhomeoffice/cop-react-form-renderer 4.72.1 → 4.72.2

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.
@@ -16,6 +16,20 @@ describe('utils', function () {
16
16
  var value = (0, _getSourceData.default)(DATA, FIELD_ID);
17
17
  expect(value).toEqual(VALUE);
18
18
  });
19
+ it('should handle boolean true', function () {
20
+ var FIELD_ID = 'field';
21
+ var VALUE = true;
22
+ var DATA = _defineProperty({}, FIELD_ID, VALUE);
23
+ var value = (0, _getSourceData.default)(DATA, FIELD_ID);
24
+ expect(value).toStrictEqual(true);
25
+ });
26
+ it('should handle boolean false', function () {
27
+ var FIELD_ID = 'field';
28
+ var VALUE = false;
29
+ var DATA = _defineProperty({}, FIELD_ID, VALUE);
30
+ var value = (0, _getSourceData.default)(DATA, FIELD_ID);
31
+ expect(value).toStrictEqual(false);
32
+ });
19
33
  it('should return a nested value', function () {
20
34
  var FIELD_ID = 'field.nested';
21
35
  var VALUE = 'nested value';
@@ -26,7 +26,7 @@ var persistValueInFormData = function persistValueInFormData(config, data, onCha
26
26
  } else {
27
27
  value = config === null || config === void 0 ? void 0 : config.value;
28
28
  }
29
- if (value && config.name && data[config.name] !== value) {
29
+ if (value != null && config.name && data[config.name] !== value) {
30
30
  onChange({
31
31
  target: {
32
32
  name: config.name,
@@ -35,6 +35,19 @@ describe('Utils.Operate.persistValueInFormData', function () {
35
35
  });
36
36
  expect(ON_CHANGE_COUNT).toEqual(1);
37
37
  });
38
+ it('Should trigger a change correctly with boolean false', function () {
39
+ var CONFIG = {
40
+ name: 'alpha',
41
+ value: false
42
+ };
43
+ (0, _persistValueInFormData.default)(CONFIG, DATA, ON_CHANGE);
44
+ expect(DATA).toEqual({
45
+ alpha: false,
46
+ beta: 'charlie',
47
+ charlie: '123'
48
+ });
49
+ expect(ON_CHANGE_COUNT).toEqual(1);
50
+ });
38
51
  it('Should not call onChange when value is unchanged', function () {
39
52
  var CONFIG = {
40
53
  name: 'alpha',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "4.72.1",
3
+ "version": "4.72.2",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",