@ukhomeoffice/cop-react-form-renderer 6.11.1 → 6.12.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.
Files changed (36) hide show
  1. package/dist/components/CheckYourAnswers/Answer.js +1 -1
  2. package/dist/components/CheckYourAnswers/CheckYourAnswers.js +6 -2
  3. package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +131 -50
  4. package/dist/components/CollectionSummary/CollectionSummary.js +6 -4
  5. package/dist/components/CollectionSummary/CollectionSummary.scss +5 -0
  6. package/dist/components/CollectionSummary/CollectionSummary.test.js +60 -36
  7. package/dist/components/CollectionSummary/RenderListView.js +7 -4
  8. package/dist/components/CollectionSummary/SummaryCard.js +6 -4
  9. package/dist/components/CollectionSummary/SummaryCard.scss +6 -0
  10. package/dist/components/CollectionSummary/SummaryCard.test.js +5 -5
  11. package/dist/components/CollectionSummary/SummaryCardDetails.js +3 -2
  12. package/dist/components/CollectionSummary/SummaryCardDetails.scss +2 -0
  13. package/dist/components/FormComponent/FormComponent.js +1 -1
  14. package/dist/components/FormPage/FormPage.js +19 -7
  15. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +25 -13
  16. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +59 -1
  17. package/dist/components/FormRenderer/onPageAction.js +5 -1
  18. package/dist/json/actions.json +17 -0
  19. package/dist/json/actionsNoSave.json +17 -0
  20. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +7 -4
  21. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +39 -0
  22. package/dist/utils/CheckYourAnswers/showComponentCYA.js +1 -1
  23. package/dist/utils/Data/deleteValues.js +22 -0
  24. package/dist/utils/Data/deleteValues.test.js +57 -0
  25. package/dist/utils/Data/getAutocompleteSource.test.js +14 -5
  26. package/dist/utils/Data/getOptions.js +2 -1
  27. package/dist/utils/Data/getOptions.test.js +26 -8
  28. package/dist/utils/Data/index.js +2 -0
  29. package/dist/utils/Operate/deleteValueInFormData.js +26 -0
  30. package/dist/utils/Operate/deleteValueInFormData.test.js +60 -0
  31. package/dist/utils/Operate/runPageOperations.js +2 -0
  32. package/dist/utils/Validate/additional/index.js +4 -1
  33. package/dist/utils/Validate/additional/index.test.js +66 -0
  34. package/dist/utils/Validate/additional/mustBeOneOf.js +21 -0
  35. package/dist/utils/Validate/additional/mustBeOneOf.test.js +36 -0
  36. package/package.json +1 -1
@@ -44,6 +44,12 @@ $govuk-font-family: 'Roboto', arial, sans-serif;
44
44
  margin-right: govuk-spacing(2);
45
45
  }
46
46
 
47
+ &-title {
48
+ margin-block-start: 0;
49
+ margin-block-end: 0;
50
+ font-size: 1em;
51
+ }
52
+
47
53
  &-detail {
48
54
  font-weight: normal;
49
55
  }
@@ -81,7 +81,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
81
81
  expect(headerBanners.tagName).toEqual('DIV');
82
82
  expect(headerBanners.classList).toContain(_BannerStrip.DEFAULT_CLASS);
83
83
  var headerTitle = headerContentDiv.children[1];
84
- expect(headerTitle.tagName).toEqual('DIV');
84
+ expect(headerTitle.tagName).toEqual('H2');
85
85
  expect(headerTitle.classList).toContain(classes('header-content-title'));
86
86
  expect(headerTitle.textContent).toEqual(CONFIG.title);
87
87
  var headerDetails = headerContentDiv.children[2];
@@ -113,7 +113,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
113
113
  // and the details.
114
114
 
115
115
  var headerTitle = headerContentDiv.children[0];
116
- expect(headerTitle.tagName).toEqual('DIV');
116
+ expect(headerTitle.tagName).toEqual('H2');
117
117
  expect(headerTitle.classList).toContain(classes('header-content-title'));
118
118
  expect(headerTitle.textContent).toEqual(CONFIG.title);
119
119
  var headerDetails = headerContentDiv.children[1];
@@ -148,7 +148,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
148
148
  // the title.
149
149
 
150
150
  var headerTitle = headerContentDiv.children[1];
151
- expect(headerTitle.tagName).toEqual('DIV');
151
+ expect(headerTitle.tagName).toEqual('H2');
152
152
  expect(headerTitle.classList).toContain(classes('header-content-title'));
153
153
  expect(headerTitle.textContent).toEqual(CONFIG.title);
154
154
  });
@@ -171,7 +171,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
171
171
  var _checkSetup4 = checkSetup(container),
172
172
  headerContentDiv = _checkSetup4.headerContentDiv;
173
173
  var headerTitle = headerContentDiv.children[0];
174
- expect(headerTitle.tagName).toEqual('DIV');
174
+ expect(headerTitle.tagName).toEqual('H2');
175
175
  expect(headerTitle.classList).toContain(classes('header-content-title'));
176
176
  expect(headerTitle.textContent).toEqual("".concat(ENTRY.titleText, " that is interpolated"));
177
177
  });
@@ -211,7 +211,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
211
211
  var _checkSetup5 = checkSetup(container),
212
212
  headerContentDiv = _checkSetup5.headerContentDiv;
213
213
  var headerTitle = headerContentDiv.children[0];
214
- expect(headerTitle.tagName).toEqual('DIV');
214
+ expect(headerTitle.tagName).toEqual('H2');
215
215
  expect(headerTitle.classList).toContain(classes('header-content-title'));
216
216
  expect(headerTitle.textContent).toEqual("".concat(ENTRY.titleText, " that is interpolated"));
217
217
  });
@@ -168,7 +168,8 @@ var SummaryCardDetails = function SummaryCardDetails(_ref) {
168
168
  childMasterPages: [],
169
169
  formData: _objectSpread(_objectSpread(_objectSpread({}, formData), entryData), entry),
170
170
  entryData: entry,
171
- hideChildSectionTitles: true
171
+ hideChildSectionTitles: true,
172
+ optionalFieldPlaceholder: optionalFieldPlaceholder
172
173
  });
173
174
  }));
174
175
  }
@@ -182,7 +183,7 @@ var SummaryCardDetails = function SummaryCardDetails(_ref) {
182
183
  className: classes('section')
183
184
  }, !hideChildSectionTitles && /*#__PURE__*/_react.default.createElement("h3", {
184
185
  className: classes('section-title')
185
- }, _utils.default.FormPage.getConditionalText(section.title, _objectSpread(_objectSpread({}, childPage.formData), entryData))), /*#__PURE__*/_react.default.createElement("div", {
186
+ }, _utils.default.FormPage.getConditionalText(section.title, _objectSpread(_objectSpread({}, childPage.formData), entryData))), /*#__PURE__*/_react.default.createElement("dl", {
186
187
  className: classes('section-content'),
187
188
  style: {
188
189
  '--dividers': columns.length - 1
@@ -141,6 +141,8 @@ $govuk-font-family: 'Roboto', arial, sans-serif;
141
141
  grid-column-end: var(--column);
142
142
  grid-row-start: var(--row);
143
143
  grid-row-end: var(--row);
144
+ margin-block-start: 0;
145
+ margin-block-end: 0;
144
146
  }
145
147
 
146
148
  .hods-form-summary-card-details__divider {
@@ -89,7 +89,7 @@ var FormComponent = function FormComponent(_ref) {
89
89
  };
90
90
  (0, _react.useEffect)(function () {
91
91
  var defaultValue = _utils.default.Component.defaultValue(component, formData);
92
- if (!value && defaultValue) {
92
+ if (!value && !(formData !== null && formData !== void 0 && formData[component.fieldId]) && defaultValue) {
93
93
  if (typeof onComponentChange === 'function') {
94
94
  onComponentChange({
95
95
  target: {
@@ -62,13 +62,25 @@ var FormPage = function FormPage(_ref) {
62
62
  var onPageChange = function onPageChange(_ref2) {
63
63
  var target = _ref2.target;
64
64
  var formPage = page;
65
- formPage.formData[target.name] = target.value;
66
- setPatch(function (prev) {
67
- return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, target.name, target.value));
68
- });
69
- setPatchLabel(function (prev) {
70
- return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, target.component, target.label));
71
- });
65
+ if (target.value == null) {
66
+ delete formPage.formData[target.name];
67
+ setPatch(function (prev) {
68
+ var data = prev;
69
+ return delete data[target.name];
70
+ });
71
+ setPatchLabel(function (prev) {
72
+ var data = prev;
73
+ return delete data[target.component];
74
+ });
75
+ } else {
76
+ formPage.formData[target.name] = target.value;
77
+ setPatch(function (prev) {
78
+ return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, target.name, target.value));
79
+ });
80
+ setPatchLabel(function (prev) {
81
+ return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, target.component, target.label));
82
+ });
83
+ }
72
84
  if (typeof onChange === 'function') {
73
85
  onChange(page.formData);
74
86
  }
@@ -5,6 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _optionIsSelected = _interopRequireDefault(require("../../../utils/Component/optionIsSelected"));
8
+ var _getCollectionPageActiveId = _interopRequireDefault(require("../../../utils/CollectionPage/getCollectionPageActiveId"));
9
+ var _getCollectionPageData = _interopRequireDefault(require("../../../utils/CollectionPage/getCollectionPageData"));
10
+ var _setCollectionPageData = _interopRequireDefault(require("../../../utils/CollectionPage/setCollectionPageData"));
8
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
12
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
13
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -13,6 +16,14 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
13
16
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
14
17
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } // Local imports
15
18
  var parentComponents = ['radios', 'checkboxes'];
19
+ var getActiveIds = function getActiveIds(collectionName, formData) {
20
+ var nameParts = collectionName.split('.');
21
+ var result = {};
22
+ nameParts.forEach(function (part) {
23
+ result["".concat(part, "ActiveId")] = formData["".concat(part, "ActiveId")];
24
+ });
25
+ return result;
26
+ };
16
27
  function getIdsToDelete(component, selectedValue) {
17
28
  var _component$data;
18
29
  var idsToDelete = [];
@@ -25,29 +36,30 @@ function getIdsToDelete(component, selectedValue) {
25
36
  });
26
37
  return idsToDelete;
27
38
  }
28
- ;
29
39
  var cleanHiddenNestedData = function cleanHiddenNestedData(patch, page) {
40
+ var _patch = patch;
30
41
  page.components.forEach(function (component) {
31
42
  if (!parentComponents.includes(component.type)) {
32
43
  return;
33
44
  }
34
- var _patch = patch;
35
45
  var idsToDelete = getIdsToDelete(component, _patch[component.id]);
36
46
  idsToDelete.forEach(function (id) {
37
47
  delete _patch[id];
38
48
  });
39
49
  });
40
- if (page.collection && patch[page.collection.name]) {
41
- var _page$formData;
42
- var activeId = patch["".concat(page.collection.name, "ActiveId")] || ((_page$formData = page.formData) === null || _page$formData === void 0 ? void 0 : _page$formData["".concat(page.collection.name, "ActiveId")]);
43
- var _patch = patch;
44
- _patch[page.collection.name] = _patch[page.collection.name].map(function (entry) {
45
- return entry.id === activeId ? cleanHiddenNestedData(entry, _objectSpread(_objectSpread({}, page), {}, {
46
- collection: undefined
47
- })) : entry;
48
- });
50
+ if (page.collection) {
51
+ _patch = _objectSpread(_objectSpread({}, getActiveIds(page.collection.name, page.formData)), _patch);
52
+ var collectionData = (0, _getCollectionPageData.default)(page.collection.name, _patch);
53
+ if (collectionData) {
54
+ var activeId = (0, _getCollectionPageActiveId.default)(page.collection.name, _patch);
55
+ var modifiedCollection = collectionData.map(function (entry) {
56
+ return entry.id === activeId ? cleanHiddenNestedData(entry, _objectSpread(_objectSpread({}, page), {}, {
57
+ collection: undefined
58
+ })) : entry;
59
+ });
60
+ (0, _setCollectionPageData.default)(page.collection.name, modifiedCollection, _patch);
61
+ }
49
62
  }
50
- ;
51
- return patch;
63
+ return _patch;
52
64
  };
53
65
  var _default = exports.default = cleanHiddenNestedData;
@@ -78,7 +78,7 @@ describe('components', function () {
78
78
  expect(updatedPatchCheckboxes.nested1).toBeFalsy();
79
79
  expect(updatedPatchCheckboxes.nested2).toBeTruthy();
80
80
  });
81
- it('remove data corresponding to hidden nested components within the active collection entry', function () {
81
+ it('should remove data corresponding to hidden nested components within the active collection entry', function () {
82
82
  var patch = {
83
83
  collectionNameActiveId: '456',
84
84
  collectionName: [{
@@ -100,6 +100,9 @@ describe('components', function () {
100
100
  collection: {
101
101
  name: 'collectionName'
102
102
  },
103
+ formData: {
104
+ collectionNameActiveId: '456'
105
+ },
103
106
  components: [{
104
107
  id: 'parent',
105
108
  type: 'radios',
@@ -126,6 +129,61 @@ describe('components', function () {
126
129
  expect(updatedPatch.collectionName[1].nested1).toBeFalsy();
127
130
  expect(updatedPatch.collectionName[1].nested2).toBeTruthy();
128
131
  });
132
+ it('should remove data corresponding to hidden nested components when collection is nested within an entity', function () {
133
+ var patch = {
134
+ collectionNameActiveId: '456',
135
+ entities: [{
136
+ id: '777',
137
+ collectionName: [{
138
+ id: '123',
139
+ parent: 'option1',
140
+ nested1: 'should be included',
141
+ nested2: 'should be included'
142
+ }, {
143
+ id: '456',
144
+ parent: 'option2',
145
+ nested1: 'should not be included',
146
+ nested2: 'should be included'
147
+ }]
148
+ }]
149
+ };
150
+ var page = {
151
+ id: 'page',
152
+ name: 'page',
153
+ title: 'Page',
154
+ collection: {
155
+ name: 'entities.collectionName'
156
+ },
157
+ formData: {
158
+ collectionNameActiveId: '456',
159
+ entitiesActiveId: '777'
160
+ },
161
+ components: [{
162
+ id: 'parent',
163
+ type: 'radios',
164
+ data: {
165
+ options: [{
166
+ value: 'option1',
167
+ nested: [{
168
+ id: 'nested1',
169
+ fieldId: 'nested1'
170
+ }]
171
+ }, {
172
+ value: 'option2',
173
+ nested: [{
174
+ id: 'nested2',
175
+ fieldId: 'nested2'
176
+ }]
177
+ }]
178
+ }
179
+ }]
180
+ };
181
+ var updatedPatch = (0, _cleanHiddenNestedData.default)(patch, page);
182
+ expect(updatedPatch.entities[0].collectionName[0].nested1).toBeTruthy();
183
+ expect(updatedPatch.entities[0].collectionName[0].nested2).toBeTruthy();
184
+ expect(updatedPatch.entities[0].collectionName[1].nested1).toBeFalsy();
185
+ expect(updatedPatch.entities[0].collectionName[1].nested2).toBeTruthy();
186
+ });
129
187
  });
130
188
  });
131
189
  });
@@ -100,7 +100,11 @@ var onPageAction = function onPageAction(action, patch, patchLabel, hooks, data,
100
100
  break;
101
101
  }
102
102
  ;
103
- /* eslint-enable no-case-declarations */
103
+
104
+ // If a value has been deleted from formData,
105
+ // also delete it from data before doing object spread,
106
+ // or else it will reappear in submissionData.
107
+ _utils.default.Data.deleteValues(data, formState.page.formData);
104
108
 
105
109
  // Save draft or submit.
106
110
  var submissionData = _utils.default.Format.form({
@@ -0,0 +1,17 @@
1
+ [
2
+ {
3
+ "type": "submit",
4
+ "label": "Submit",
5
+ "validate": true
6
+ },
7
+ {
8
+ "type": "saveAndReturn",
9
+ "show_when": {
10
+ "field": "areYouACivilServant",
11
+ "op": "nin",
12
+ "values": [
13
+ "no"
14
+ ]
15
+ }
16
+ }
17
+ ]
@@ -0,0 +1,17 @@
1
+ [
2
+ {
3
+ "type": "submit",
4
+ "label": "Submit",
5
+ "validate": true
6
+ },
7
+ {
8
+ "type": "saveAndReturn",
9
+ "show_when": {
10
+ "field": "areYouACivilServant",
11
+ "op": "nin",
12
+ "values": [
13
+ "yes"
14
+ ]
15
+ }
16
+ }
17
+ ]
@@ -204,8 +204,9 @@ var getCYARowsForCollectionPage = function getCYARowsForCollectionPage(page, onA
204
204
  rows.push(getCollectionNameHeading(page, collectionName, page.collection.collectionHeading, headingChangeAction));
205
205
  }
206
206
  var itemIndex = 0;
207
- var result = Array.isArray(page.collection.onlyShowActiveEntryOnCYA) ? (0, _meetsAllConditions.default)(page.collection.onlyShowActiveEntryOnCYA, data) : page.collection.onlyShowActiveEntryOnCYA;
208
- if (result) {
207
+ var hideItemTitles = Array.isArray(page.collection.hideItemTitles) ? (0, _meetsAllConditions.default)(page.collection.hideItemTitles, data) : page.collection.hideItemTitles;
208
+ var onlyShowActiveEntry = Array.isArray(page.collection.onlyShowActiveEntryOnCYA) ? (0, _meetsAllConditions.default)(page.collection.onlyShowActiveEntryOnCYA, data) : page.collection.onlyShowActiveEntryOnCYA;
209
+ if (onlyShowActiveEntry) {
209
210
  var activeEntry = collectionData.find(function (entry, index) {
210
211
  itemIndex = index;
211
212
  return entry.id === activeId;
@@ -222,9 +223,11 @@ var getCYARowsForCollectionPage = function getCYARowsForCollectionPage(page, onA
222
223
  var labelCount = itemIndex + 1;
223
224
  var actionPosition = ((_page$collection2 = page.collection) === null || _page$collection2 === void 0 ? void 0 : _page$collection2.actionPosition) || 'top';
224
225
  var fullPath = "".concat(page.collection.name, "[").concat(itemIndex, "]");
225
- var titleRow = getTitleRowForItem(page, item, page.id, labelCount, fullPath);
226
226
  var actionRows = getActionRows(page, item, onAction, labelCount, activeIds);
227
- rows = rows.concat(titleRow);
227
+ if (!hideItemTitles) {
228
+ var titleRow = getTitleRowForItem(page, item, page.id, labelCount, fullPath);
229
+ rows = rows.concat(titleRow);
230
+ }
228
231
  if (actionPosition === 'top') {
229
232
  rows = rows.concat(actionRows);
230
233
  }
@@ -103,6 +103,45 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
103
103
  expect(ROWS.length).toEqual(7); // Collection title, item title, action rows & component rows
104
104
  expect(ROWS[1].key).toEqual('Collection entry 1');
105
105
  });
106
+ it('should hide titles when hideItemTitles is true', function () {
107
+ var FORM_DATA = {
108
+ collection: [{
109
+ id: '01',
110
+ testText: 'value'
111
+ }]
112
+ };
113
+ var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
114
+ formData: FORM_DATA,
115
+ collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
116
+ hideItemTitles: true
117
+ })
118
+ });
119
+ var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
120
+ expect(ROWS.length).toEqual(6); // Collection title, NO item title, action rows & component rows
121
+ });
122
+
123
+ it('should hide titles when hideItemTitles is a show_when that is true', function () {
124
+ var FORM_DATA = {
125
+ shouldShow: false,
126
+ collection: [{
127
+ id: '01',
128
+ testText: 'value'
129
+ }]
130
+ };
131
+ var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
132
+ formData: FORM_DATA,
133
+ collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
134
+ hideItemTitles: [{
135
+ field: 'shouldShow',
136
+ op: '=',
137
+ value: false
138
+ }]
139
+ })
140
+ });
141
+ var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
142
+ expect(ROWS.length).toEqual(6); // Collection title, NO item title, action rows & component rows
143
+ });
144
+
106
145
  it('should provide default titles if collection.labels.item is not specified', function () {
107
146
  var FORM_DATA = {
108
147
  collection: [{
@@ -33,7 +33,7 @@ var showComponentCYA = function showComponentCYA(options, data) {
33
33
  }
34
34
  if (options.hideOnCyaWhenEmpty) {
35
35
  if (options.type === _models.ComponentTypes.COLLECTION) {
36
- var itemCollectionsData = (0, _getSourceData.default)(data, options.full_path);
36
+ var itemCollectionsData = (0, _getSourceData.default)(data, options.full_path || options.fieldId);
37
37
  if (!(itemCollectionsData !== null && itemCollectionsData !== void 0 && itemCollectionsData.length)) {
38
38
  return false;
39
39
  }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ /**
8
+ * Find values in data not in formData
9
+ * and delete them from data.
10
+ * @param {object} data The page's data.
11
+ * @param {object} formData The page's formData.
12
+ */
13
+ var deleteValues = function deleteValues(data, formData) {
14
+ var deletedValues = Object.keys(data).filter(function (k) {
15
+ return !(k in formData);
16
+ });
17
+ var node = data;
18
+ deletedValues.forEach(function (i) {
19
+ return delete node[i];
20
+ });
21
+ };
22
+ var _default = exports.default = deleteValues;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ var _deleteValues = _interopRequireDefault(require("./deleteValues"));
4
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5
+ describe('Utils.Data.deleteValues', function () {
6
+ it('Should delete values from data', function () {
7
+ var DATA = {
8
+ a: '1',
9
+ b: '2',
10
+ c: '3'
11
+ };
12
+ var FORMDATA = {
13
+ a: '1'
14
+ };
15
+ (0, _deleteValues.default)(DATA, FORMDATA);
16
+ expect(DATA).toEqual({
17
+ a: '1'
18
+ });
19
+ });
20
+ it('Should leave data unchanged if no differences', function () {
21
+ var DATA = {
22
+ a: '1',
23
+ b: '2',
24
+ c: '3'
25
+ };
26
+ var FORMDATA = {
27
+ a: '1',
28
+ b: '2',
29
+ c: '3'
30
+ };
31
+ (0, _deleteValues.default)(DATA, FORMDATA);
32
+ expect(DATA).toEqual({
33
+ a: '1',
34
+ b: '2',
35
+ c: '3'
36
+ });
37
+ });
38
+ it('Should leave data unchanged if form data has additional fields', function () {
39
+ var DATA = {
40
+ a: '1',
41
+ b: '2',
42
+ c: '3'
43
+ };
44
+ var FORMDATA = {
45
+ a: '1',
46
+ b: '2',
47
+ c: '3',
48
+ d: '4'
49
+ };
50
+ (0, _deleteValues.default)(DATA, FORMDATA);
51
+ expect(DATA).toEqual({
52
+ a: '1',
53
+ b: '2',
54
+ c: '3'
55
+ });
56
+ });
57
+ });
@@ -14,6 +14,7 @@ describe('utils', function () {
14
14
  var gbCurrency = {
15
15
  currencyName: 'Great British Pounds',
16
16
  currencyCode: 'GBP',
17
+ hint: 'hint',
17
18
  value: 'GBP',
18
19
  label: 'GBP',
19
20
  slangTerm: 'quid'
@@ -21,6 +22,7 @@ describe('utils', function () {
21
22
  var usCurrency = {
22
23
  currencyName: 'United States Dollars',
23
24
  currencyCode: 'USD',
25
+ hint: 'hint',
24
26
  value: 'USD',
25
27
  label: 'USD',
26
28
  slangTerm: 'bucks',
@@ -29,19 +31,23 @@ describe('utils', function () {
29
31
  var options = {
30
32
  alpha: {
31
33
  value: 'a',
32
- label: 'Alpha'
34
+ label: 'Alpha',
35
+ hint: 'hint'
33
36
  },
34
37
  bravo: {
35
38
  value: 'b',
36
- label: 'Bravo'
39
+ label: 'Bravo',
40
+ hint: 'hint'
37
41
  },
38
42
  alIncluded: {
39
43
  value: 'c',
40
- label: 'Call me alan'
44
+ label: 'Call me alan',
45
+ hint: 'hint'
41
46
  },
42
47
  alStart: {
43
48
  value: 'd',
44
- label: 'Word Alphabet'
49
+ label: 'Word Alphabet',
50
+ hint: 'hint'
45
51
  }
46
52
  };
47
53
  var testCurrencies = [gbCurrency, usCurrency];
@@ -71,7 +77,8 @@ describe('utils', function () {
71
77
  expect(results.length).toEqual(1);
72
78
  expect(results).toEqual([{
73
79
  value: 'a',
74
- label: 'Alpha'
80
+ label: 'Alpha',
81
+ hint: 'hint'
75
82
  }]);
76
83
  });
77
84
  });
@@ -249,6 +256,7 @@ describe('utils', function () {
249
256
  options: [gbCurrency, {
250
257
  currencyName: 'United States Dollars',
251
258
  currencyCode: 'USD',
259
+ hint: 'hint',
252
260
  value: 'USD'
253
261
  }]
254
262
  }
@@ -263,6 +271,7 @@ describe('utils', function () {
263
271
  expect(results).toEqual([gbCurrency, {
264
272
  currencyName: 'United States Dollars',
265
273
  currencyCode: 'USD',
274
+ hint: 'hint',
266
275
  value: 'USD',
267
276
  label: ''
268
277
  }]);
@@ -32,7 +32,8 @@ var interpolateOptions = function interpolateOptions(config, options) {
32
32
  }
33
33
  return _objectSpread(_objectSpread({}, opt), {}, {
34
34
  value: _copReactComponents.Utils.interpolateString(opt.value, config.formData),
35
- label: _copReactComponents.Utils.interpolateString(opt.label, config.formData)
35
+ label: _copReactComponents.Utils.interpolateString(opt.label, config.formData),
36
+ hint: _copReactComponents.Utils.interpolateString(opt.hint, config.formData)
36
37
  });
37
38
  }).filter(function (n) {
38
39
  return n;