@ukhomeoffice/cop-react-form-renderer 5.0.0-alpha → 5.0.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 (277) hide show
  1. package/dist/components/CheckYourAnswers/Answer.js +18 -7
  2. package/dist/components/CheckYourAnswers/Answer.test.js +137 -0
  3. package/dist/components/CheckYourAnswers/CheckYourAnswers.js +70 -46
  4. package/dist/components/CheckYourAnswers/CheckYourAnswers.stories.mdx +410 -0
  5. package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +551 -0
  6. package/dist/components/CollectionPage/CollectionPage.js +15 -10
  7. package/dist/components/CollectionPage/CollectionPage.test.js +382 -0
  8. package/dist/components/FormComponent/Collection.js +91 -48
  9. package/dist/components/FormComponent/Collection.scss +2 -1
  10. package/dist/components/FormComponent/Collection.test.js +807 -0
  11. package/dist/components/FormComponent/Container.js +35 -16
  12. package/dist/components/FormComponent/Container.test.js +370 -0
  13. package/dist/components/FormComponent/FormComponent.js +39 -13
  14. package/dist/components/FormComponent/FormComponent.stories.mdx +184 -0
  15. package/dist/components/FormComponent/FormComponent.test.js +226 -0
  16. package/dist/components/FormComponent/helpers/addLabel.js +5 -4
  17. package/dist/components/FormComponent/helpers/getComponentFieldSet.js +16 -0
  18. package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +29 -0
  19. package/dist/components/FormComponent/helpers/index.js +8 -1
  20. package/dist/components/FormPage/FormPage.js +69 -30
  21. package/dist/components/FormPage/FormPage.stories.mdx +155 -0
  22. package/dist/components/FormPage/FormPage.test.js +330 -0
  23. package/dist/components/FormRenderer/FormRenderer.js +142 -228
  24. package/dist/components/FormRenderer/FormRenderer.stories.mdx +183 -0
  25. package/dist/components/FormRenderer/FormRenderer.test.js +968 -0
  26. package/dist/components/FormRenderer/handlers/index.js +1 -2
  27. package/dist/components/FormRenderer/handlers/navigate.js +3 -1
  28. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +35 -14
  29. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +88 -5
  30. package/dist/components/FormRenderer/helpers/getCYA.js +11 -2
  31. package/dist/components/FormRenderer/helpers/getNextPageId.js +13 -7
  32. package/dist/components/FormRenderer/helpers/getRelevantPages.js +10 -2
  33. package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +1 -1
  34. package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +2 -2
  35. package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +6 -2
  36. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +171 -51
  37. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +307 -24
  38. package/dist/components/FormRenderer/helpers/index.js +1 -2
  39. package/dist/components/FormRenderer/onCYAAction.js +108 -0
  40. package/dist/components/FormRenderer/onCYAAction.test.js +583 -0
  41. package/dist/components/FormRenderer/onPageAction.js +145 -0
  42. package/dist/components/FormRenderer/onPageAction.test.js +678 -0
  43. package/dist/components/FormRenderer/onTaskAction.js +48 -0
  44. package/dist/components/FormRenderer/onTaskAction.test.js +217 -0
  45. package/dist/components/PageActions/ActionButton.js +0 -3
  46. package/dist/components/PageActions/ActionButton.test.js +93 -0
  47. package/dist/components/PageActions/PageActions.js +2 -2
  48. package/dist/components/PageActions/PageActions.stories.mdx +74 -0
  49. package/dist/components/PageActions/PageActions.test.js +132 -0
  50. package/dist/components/SummaryList/GroupAction.js +2 -2
  51. package/dist/components/SummaryList/GroupAction.test.js +80 -0
  52. package/dist/components/SummaryList/RowAction.js +2 -2
  53. package/dist/components/SummaryList/RowAction.test.js +80 -0
  54. package/dist/components/SummaryList/SummaryList.js +29 -12
  55. package/dist/components/SummaryList/SummaryList.scss +19 -0
  56. package/dist/components/SummaryList/SummaryList.stories.mdx +90 -0
  57. package/dist/components/SummaryList/SummaryList.test.js +400 -0
  58. package/dist/components/SummaryList/SummaryListHeadingRow.js +30 -0
  59. package/dist/components/SummaryList/SummaryListRow.js +5 -2
  60. package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +2 -1
  61. package/dist/components/SummaryList/helpers/getRowActionAttributes.js +2 -1
  62. package/dist/components/TaskList/Task.js +3 -3
  63. package/dist/components/TaskList/Task.test.js +167 -0
  64. package/dist/components/TaskList/TaskList.js +73 -22
  65. package/dist/components/TaskList/TaskList.stories.mdx +164 -0
  66. package/dist/components/TaskList/TaskList.test.js +389 -0
  67. package/dist/components/TaskList/TaskState.js +2 -2
  68. package/dist/components/TaskList/TaskState.test.js +86 -0
  69. package/dist/components/index.js +14 -0
  70. package/dist/context/HooksContext/HooksContext.js +72 -8
  71. package/dist/context/HooksContext/HooksContext.test.js +44 -0
  72. package/dist/context/ValidationContext/ValidationContext.js +38 -28
  73. package/dist/context/ValidationContext/ValidationContext.test.js +84 -0
  74. package/dist/hooks/useAxios.js +10 -12
  75. package/dist/hooks/useGetRequest.js +48 -49
  76. package/dist/hooks/useRefData.js +7 -4
  77. package/dist/index.js +34 -1
  78. package/dist/json/addressDetails.json +149 -0
  79. package/dist/json/areYouACivilServant.json +7 -0
  80. package/dist/json/firstForm.json +94 -0
  81. package/dist/json/grade.json +108 -0
  82. package/dist/json/group.data.json +21 -0
  83. package/dist/json/group.json +402 -0
  84. package/dist/json/groupOfRow.json +137 -0
  85. package/dist/json/groupOfRowData.json +15 -0
  86. package/dist/json/port.json +346 -0
  87. package/dist/json/saveAndContinue.json +98 -0
  88. package/dist/json/sublocation.json +859 -0
  89. package/dist/json/taskList.json +265 -0
  90. package/dist/json/team.json +17351 -0
  91. package/dist/json/terminal.json +81 -0
  92. package/dist/json/userProfile.data.json +21 -0
  93. package/dist/json/userProfile.json +276 -0
  94. package/dist/models/ComponentTypes.js +8 -0
  95. package/dist/models/PageAction.js +4 -1
  96. package/dist/models/TaskStates.js +10 -2
  97. package/dist/models/index.js +16 -1
  98. package/dist/setupTests.js +46 -0
  99. package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
  100. package/dist/utils/CheckYourAnswers/getCYAAction.test.js +121 -0
  101. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +6 -2
  102. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +71 -0
  103. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +6 -2
  104. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +55 -0
  105. package/dist/utils/CheckYourAnswers/getCYARow.js +14 -11
  106. package/dist/utils/CheckYourAnswers/getCYARow.test.js +291 -0
  107. package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +4 -1
  108. package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +70 -0
  109. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +15 -10
  110. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +288 -0
  111. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +94 -36
  112. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +414 -0
  113. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +21 -7
  114. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +486 -0
  115. package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +11 -3
  116. package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +346 -0
  117. package/dist/utils/CheckYourAnswers/showComponentCYA.js +19 -3
  118. package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +143 -0
  119. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +5 -1
  120. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +40 -0
  121. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +53 -0
  122. package/dist/utils/CollectionPage/mergeCollectionPages.js +25 -17
  123. package/dist/utils/CollectionPage/mergeCollectionPages.test.js +130 -0
  124. package/dist/utils/Component/addShowWhen.js +44 -0
  125. package/dist/utils/Component/addShowWhen.test.js +216 -0
  126. package/dist/utils/Component/applyToComponentTree.js +71 -0
  127. package/dist/utils/Component/applyToComponentTree.test.js +127 -0
  128. package/dist/utils/Component/cleanAttributes.js +8 -2
  129. package/dist/utils/Component/cleanAttributes.test.js +68 -0
  130. package/dist/utils/Component/elevateNestedComponents.js +4 -1
  131. package/dist/utils/Component/elevateNestedComponents.test.js +122 -0
  132. package/dist/utils/Component/getComponent.js +80 -11
  133. package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +4 -4
  134. package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +25 -24
  135. package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +66 -5
  136. package/dist/utils/Component/getComponentTests/getComponent.date.test.js +2 -2
  137. package/dist/utils/Component/getComponentTests/getComponent.details.test.js +9 -7
  138. package/dist/utils/Component/getComponentTests/getComponent.email.test.js +3 -3
  139. package/dist/utils/Component/getComponentTests/getComponent.file.test.js +3 -3
  140. package/dist/utils/Component/getComponentTests/getComponent.list.test.js +44 -0
  141. package/dist/utils/Component/getComponentTests/{getComponent.textarea.test.js → getComponent.multifile.test.js} +29 -21
  142. package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +159 -83
  143. package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +43 -0
  144. package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +3 -3
  145. package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +55 -5
  146. package/dist/utils/Component/getComponentTests/getComponent.select.test.js +3 -9
  147. package/dist/utils/Component/getComponentTests/getComponent.text.test.js +3 -3
  148. package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +109 -0
  149. package/dist/utils/Component/getComponentTests/getComponent.time.test.js +7 -7
  150. package/dist/utils/Component/getDefaultValue.js +4 -1
  151. package/dist/utils/Component/getDefaultValue.test.js +50 -0
  152. package/dist/utils/Component/index.js +2 -0
  153. package/dist/utils/Component/isEditable.js +2 -2
  154. package/dist/utils/Component/isEditable.test.js +43 -0
  155. package/dist/utils/Component/optionIsSelected.js +22 -0
  156. package/dist/utils/Component/optionIsSelected.test.js +42 -0
  157. package/dist/utils/Component/setupContainerComponentsPath.js +40 -0
  158. package/dist/utils/Component/setupContainerComponentsPath.test.js +78 -0
  159. package/dist/utils/Component/showComponent.test.js +156 -0
  160. package/dist/utils/Component/wrapInFormGroup.js +1 -1
  161. package/dist/utils/Condition/meetsAllConditions.js +1 -1
  162. package/dist/utils/Condition/meetsAllConditions.test.js +61 -0
  163. package/dist/utils/Condition/meetsCondition.js +74 -4
  164. package/dist/utils/Condition/meetsCondition.test.js +763 -0
  165. package/dist/utils/Condition/meetsOneCondition.js +1 -1
  166. package/dist/utils/Condition/meetsOneCondition.test.js +100 -0
  167. package/dist/utils/Condition/setupConditions.js +6 -3
  168. package/dist/utils/Condition/setupConditions.test.js +33 -0
  169. package/dist/utils/Container/getEditableComponents.test.js +135 -0
  170. package/dist/utils/Container/setupNesting.js +21 -2
  171. package/dist/utils/Container/setupNesting.test.js +145 -0
  172. package/dist/utils/Container/showContainer.test.js +178 -0
  173. package/dist/utils/Data/applyFormula.js +20 -11
  174. package/dist/utils/Data/applyFormula.test.js +263 -0
  175. package/dist/utils/Data/getAutocompleteSource.js +6 -2
  176. package/dist/utils/Data/getAutocompleteSource.test.js +352 -0
  177. package/dist/utils/Data/getDataPath.test.js +48 -0
  178. package/dist/utils/Data/getOptions.js +17 -3
  179. package/dist/utils/Data/getOptions.test.js +140 -0
  180. package/dist/utils/Data/getSourceData.js +2 -2
  181. package/dist/utils/Data/getSourceData.test.js +153 -0
  182. package/dist/utils/Data/refDataToOptions.js +4 -1
  183. package/dist/utils/Data/refDataToOptions.test.js +196 -0
  184. package/dist/utils/Data/setDataItem.test.js +110 -0
  185. package/dist/utils/Data/setupFormData.js +39 -16
  186. package/dist/utils/Data/setupFormData.test.js +410 -0
  187. package/dist/utils/Data/setupRefDataUrlForComponent.js +4 -1
  188. package/dist/utils/Data/setupRefDataUrlForComponent.test.js +131 -0
  189. package/dist/utils/FormPage/applyConditionalProperties.js +35 -0
  190. package/dist/utils/FormPage/applyConditionalProperties.test.js +61 -0
  191. package/dist/utils/FormPage/getFormPage.js +5 -2
  192. package/dist/utils/FormPage/getFormPage.test.js +206 -0
  193. package/dist/utils/FormPage/getFormPages.js +4 -1
  194. package/dist/utils/FormPage/getFormPages.test.js +97 -0
  195. package/dist/utils/FormPage/getPageActions.js +8 -4
  196. package/dist/utils/FormPage/getPageActions.test.js +114 -0
  197. package/dist/utils/FormPage/getParagraphFromText.test.js +27 -0
  198. package/dist/utils/FormPage/index.js +2 -0
  199. package/dist/utils/FormPage/showFormPage.js +2 -2
  200. package/dist/utils/FormPage/showFormPage.test.js +180 -0
  201. package/dist/utils/FormPage/showFormPageCYA.js +1 -0
  202. package/dist/utils/FormPage/showFormPageCYA.test.js +28 -0
  203. package/dist/utils/FormPage/useComponent.js +29 -14
  204. package/dist/utils/FormPage/useComponent.test.js +167 -0
  205. package/dist/utils/Format/formatData.test.js +45 -0
  206. package/dist/utils/Format/formatDataForComponent.js +2 -1
  207. package/dist/utils/Format/formatDataForComponent.test.js +142 -0
  208. package/dist/utils/Format/formatDataForForm.js +4 -1
  209. package/dist/utils/Format/formatDataForForm.test.js +81 -0
  210. package/dist/utils/Format/formatDataForPage.test.js +99 -0
  211. package/dist/utils/Hub/getFormHub.test.js +105 -0
  212. package/dist/utils/Meta/documents/getDocuments.test.js +4 -1
  213. package/dist/utils/Meta/documents/index.js +2 -2
  214. package/dist/utils/Meta/documents/setDocumentsForField.js +31 -0
  215. package/dist/utils/Meta/documents/setDocumentsForField.test.js +59 -0
  216. package/dist/utils/Operate/checkValueIsTruthy.test.js +42 -0
  217. package/dist/utils/Operate/getFirstOf.js +31 -0
  218. package/dist/utils/Operate/getFirstOf.test.js +86 -0
  219. package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +163 -0
  220. package/dist/utils/Operate/persistValueInFormData.js +2 -1
  221. package/dist/utils/Operate/persistValueInFormData.test.js +115 -0
  222. package/dist/utils/Operate/runPageOperations.js +3 -1
  223. package/dist/utils/Operate/runPageOperations.test.js +105 -0
  224. package/dist/utils/Operate/setValueInFormData.test.js +44 -0
  225. package/dist/utils/Operate/shouldRun.js +16 -13
  226. package/dist/utils/Operate/shouldRun.test.js +66 -0
  227. package/dist/utils/Validate/additional/conditionallyRequired.js +24 -0
  228. package/dist/utils/Validate/additional/conditionallyRequired.test.js +73 -0
  229. package/dist/utils/Validate/additional/index.js +13 -4
  230. package/dist/utils/Validate/additional/mustBeAfter.js +8 -6
  231. package/dist/utils/Validate/additional/mustBeAfter.test.js +15 -1
  232. package/dist/utils/Validate/additional/mustBeBefore.js +9 -5
  233. package/dist/utils/Validate/additional/mustBeBefore.test.js +14 -0
  234. package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +1 -1
  235. package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +6 -3
  236. package/dist/utils/Validate/additional/mustBeGreaterThan.js +22 -0
  237. package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +56 -0
  238. package/dist/utils/Validate/additional/mustBeInTheFuture.js +1 -1
  239. package/dist/utils/Validate/additional/mustBeInThePast.js +5 -5
  240. package/dist/utils/Validate/additional/mustBeLessThan.js +7 -6
  241. package/dist/utils/Validate/additional/mustBeLessThan.test.js +11 -1
  242. package/dist/utils/Validate/additional/mustBeNumbersOnly.js +9 -5
  243. package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +10 -2
  244. package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +1 -0
  245. package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +4 -1
  246. package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +19 -0
  247. package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +36 -0
  248. package/dist/utils/Validate/additional/mustSelectOnlyOne.js +29 -0
  249. package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +52 -0
  250. package/dist/utils/Validate/additional/utils.js +18 -18
  251. package/dist/utils/Validate/index.js +6 -0
  252. package/dist/utils/Validate/validateCollection.js +20 -5
  253. package/dist/utils/Validate/validateCollection.test.js +125 -0
  254. package/dist/utils/Validate/validateComponent.js +36 -20
  255. package/dist/utils/Validate/validateComponent.test.js +365 -0
  256. package/dist/utils/Validate/validateContainer.js +9 -3
  257. package/dist/utils/Validate/validateContainer.test.js +75 -0
  258. package/dist/utils/Validate/validateDate.js +4 -3
  259. package/dist/utils/Validate/validateDate.test.js +114 -0
  260. package/dist/utils/Validate/validateEmail.js +14 -1
  261. package/dist/utils/Validate/validateEmail.test.js +74 -0
  262. package/dist/utils/Validate/validateMultifile.js +32 -0
  263. package/dist/utils/Validate/validateMultifile.test.js +47 -0
  264. package/dist/utils/Validate/validatePage.js +12 -6
  265. package/dist/utils/Validate/validatePage.test.js +472 -0
  266. package/dist/utils/Validate/validateRegex.js +2 -5
  267. package/dist/utils/Validate/validateRegex.test.js +42 -0
  268. package/dist/utils/Validate/validateRequired.js +2 -4
  269. package/dist/utils/Validate/validateRequired.test.js +63 -0
  270. package/dist/utils/Validate/validateTextArea.js +37 -0
  271. package/dist/utils/Validate/validateTextArea.test.js +42 -0
  272. package/dist/utils/Validate/validateTime.js +2 -2
  273. package/dist/utils/Validate/validateTime.test.js +59 -0
  274. package/dist/utils/index.js +4 -1
  275. package/package.json +35 -50
  276. package/dist/utils/Meta/documents/setDocumentForField.js +0 -29
  277. package/dist/utils/Meta/documents/setDocumentForField.test.js +0 -49
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ var _getDataPath = _interopRequireDefault(require("./getDataPath"));
4
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5
+ describe('utils.Data.getDataPath', function () {
6
+ var CURRENT_PATH = 'this.is.the.current.path';
7
+ var RELATIVE = 'relative.path';
8
+ var ABSOLUTE = 'absolute.path';
9
+ var doTest = function doTest(path, currentPath, expected) {
10
+ expect((0, _getDataPath.default)(path, currentPath)).toEqual(expected);
11
+ };
12
+ it("should return an absolute path appropriately", function () {
13
+ doTest(ABSOLUTE, CURRENT_PATH, ABSOLUTE);
14
+ });
15
+ it("should return an absolute path appropriately where the current path is null", function () {
16
+ doTest(ABSOLUTE, null, ABSOLUTE);
17
+ });
18
+ [{
19
+ p: "./".concat(RELATIVE),
20
+ e: "this.is.the.current.".concat(RELATIVE),
21
+ d: 'a sibling node'
22
+ }, {
23
+ p: "../".concat(RELATIVE),
24
+ e: "this.is.the.".concat(RELATIVE),
25
+ d: 'a cousin node'
26
+ }, {
27
+ p: "./../".concat(RELATIVE),
28
+ e: "this.is.the.".concat(RELATIVE),
29
+ d: 'a cousin node with leading dot-slash'
30
+ }, {
31
+ p: "../../../../../../../".concat(RELATIVE),
32
+ e: RELATIVE,
33
+ d: 'an inappropriately nested node'
34
+ }].forEach(function (test) {
35
+ it("should return ".concat(test.d, " appropriately"), function () {
36
+ doTest(test.p, CURRENT_PATH, test.e);
37
+ });
38
+ it("should return ".concat(test.d, " appropriately where the current path is null"), function () {
39
+ doTest(test.p, null, RELATIVE);
40
+ });
41
+ });
42
+ it('should handle a null path and return null', function () {
43
+ doTest(null, CURRENT_PATH, null);
44
+ });
45
+ it('should handle an undefined path and return undefined', function () {
46
+ doTest(undefined, CURRENT_PATH, undefined);
47
+ });
48
+ });
@@ -5,11 +5,22 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _copReactComponents = require("@ukhomeoffice/cop-react-components");
8
+ var _Condition = _interopRequireDefault(require("../Condition"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
8
11
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
9
12
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
15
+ 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); }
11
16
  var interpolateOptions = function interpolateOptions(config, options) {
12
17
  return options.map(function (opt) {
18
+ if (opt.show_when) {
19
+ var result = opt.show_when.type === 'or' ? _Condition.default.meetsOne(opt, config.formData) : _Condition.default.meetsAll(opt, config.formData);
20
+ if (!result) {
21
+ return null;
22
+ }
23
+ }
13
24
  if (typeof opt === 'string') {
14
25
  return opt;
15
26
  }
@@ -17,17 +28,20 @@ var interpolateOptions = function interpolateOptions(config, options) {
17
28
  value: _copReactComponents.Utils.interpolateString(opt.value, config.formData),
18
29
  label: _copReactComponents.Utils.interpolateString(opt.label, config.formData)
19
30
  });
31
+ }).filter(function (n) {
32
+ return n;
20
33
  });
21
34
  };
22
35
  var getOptions = function getOptions(config, callback) {
23
36
  if (config) {
24
37
  if (config.options) {
25
38
  return callback(interpolateOptions(config, config.options));
26
- } else if (config.data && config.data.options) {
39
+ }
40
+ if (config.data && config.data.options) {
27
41
  return callback(interpolateOptions(config, config.data.options));
28
42
  }
29
43
  }
30
- callback([]);
44
+ return callback([]);
31
45
  };
32
46
  var _default = getOptions;
33
47
  exports.default = _default;
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+
3
+ var _getOptions = _interopRequireDefault(require("./getOptions"));
4
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5
+ // Local imports
6
+
7
+ describe('utils', function () {
8
+ describe('Data', function () {
9
+ describe('getOptions', function () {
10
+ it('should handle a null config', function () {
11
+ (0, _getOptions.default)(null, function (options) {
12
+ expect(options).toEqual([]);
13
+ });
14
+ });
15
+ it('should get any specified options from the config', function () {
16
+ var CONFIG = {
17
+ options: [{
18
+ value: 'a',
19
+ label: 'Alpha'
20
+ }, {
21
+ value: 'b',
22
+ label: 'Bravo'
23
+ }]
24
+ };
25
+ (0, _getOptions.default)(CONFIG, function (options) {
26
+ expect(options).toEqual(CONFIG.options);
27
+ });
28
+ });
29
+ it('should get any specified options from the data property of the config', function () {
30
+ var CONFIG = {
31
+ data: {
32
+ options: [{
33
+ value: 'a',
34
+ label: 'Alpha'
35
+ }, {
36
+ value: 'b',
37
+ label: 'Bravo'
38
+ }]
39
+ }
40
+ };
41
+ (0, _getOptions.default)(CONFIG, function (options) {
42
+ expect(options).toEqual(CONFIG.data.options);
43
+ });
44
+ });
45
+ it('should use the top-level options over those in the data property', function () {
46
+ var CONFIG = {
47
+ options: [{
48
+ value: 'a',
49
+ label: 'Alpha'
50
+ }, {
51
+ value: 'b',
52
+ label: 'Bravo'
53
+ }],
54
+ data: {
55
+ options: [{
56
+ value: 'c',
57
+ label: 'Charlie'
58
+ }, {
59
+ value: 'd',
60
+ label: 'Delta'
61
+ }]
62
+ }
63
+ };
64
+ (0, _getOptions.default)(CONFIG, function (options) {
65
+ expect(options).toEqual(CONFIG.options);
66
+ });
67
+ });
68
+ it('should exclude options from the config that fail show_when checks', function () {
69
+ var CONFIG = {
70
+ id: 'test',
71
+ options: [{
72
+ value: 'a',
73
+ label: 'Alpha',
74
+ show_when: {
75
+ field: 'other',
76
+ op: 'eq',
77
+ value: 'c'
78
+ }
79
+ }, {
80
+ value: 'b',
81
+ label: 'Bravo',
82
+ show_when: {
83
+ field: 'other',
84
+ op: 'neq',
85
+ value: 'c'
86
+ }
87
+ }],
88
+ formData: {
89
+ other: 'c'
90
+ }
91
+ };
92
+ (0, _getOptions.default)(CONFIG, function (options) {
93
+ expect(options).toEqual([CONFIG.options[0]]);
94
+ });
95
+ });
96
+ it('should exclude options from the config that fail or type show_when checks', function () {
97
+ var CONFIG = {
98
+ id: 'test',
99
+ options: [{
100
+ value: 'a',
101
+ label: 'Alpha',
102
+ show_when: {
103
+ type: 'or',
104
+ conditions: [{
105
+ field: 'other',
106
+ op: 'eq',
107
+ value: 'c'
108
+ }, {
109
+ field: 'other',
110
+ op: 'eq',
111
+ value: 'd'
112
+ }]
113
+ }
114
+ }, {
115
+ value: 'b',
116
+ label: 'Bravo',
117
+ show_when: {
118
+ type: 'or',
119
+ conditions: [{
120
+ field: 'other',
121
+ op: 'eq',
122
+ value: 'e'
123
+ }, {
124
+ field: 'other',
125
+ op: 'eq',
126
+ value: 'f'
127
+ }]
128
+ }
129
+ }],
130
+ formData: {
131
+ other: 'c'
132
+ }
133
+ };
134
+ (0, _getOptions.default)(CONFIG, function (options) {
135
+ expect(options).toEqual([CONFIG.options[0]]);
136
+ });
137
+ });
138
+ });
139
+ });
140
+ });
@@ -7,8 +7,8 @@ exports.default = void 0;
7
7
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
8
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
9
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
11
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
12
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
13
  var getItemInArray = function getItemInArray(arr, index) {
14
14
  if (Array.isArray(arr)) {
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+
3
+ var _getSourceData = _interopRequireDefault(require("./getSourceData"));
4
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
6
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
8
+ 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); }
9
+ describe('utils', function () {
10
+ describe('Data', function () {
11
+ describe('getSourceData', function () {
12
+ it('should return the value at the top level', function () {
13
+ var FIELD_ID = 'field';
14
+ var VALUE = 'value';
15
+ var DATA = _defineProperty({}, FIELD_ID, VALUE);
16
+ var value = (0, _getSourceData.default)(DATA, FIELD_ID);
17
+ expect(value).toEqual(VALUE);
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
+ });
33
+ it('should return a nested value', function () {
34
+ var FIELD_ID = 'field.nested';
35
+ var VALUE = 'nested value';
36
+ var DATA = {
37
+ field: {
38
+ nested: VALUE
39
+ }
40
+ };
41
+ var value = (0, _getSourceData.default)(DATA, FIELD_ID);
42
+ expect(value).toEqual(VALUE);
43
+ });
44
+ it('should return a deeply nested value', function () {
45
+ var FIELD_ID = 'field.nested.and.even.further.down';
46
+ var VALUE = 'deeply nested value';
47
+ var DATA = {
48
+ field: {
49
+ nested: {
50
+ and: {
51
+ even: {
52
+ further: {
53
+ down: VALUE
54
+ }
55
+ }
56
+ }
57
+ }
58
+ }
59
+ };
60
+ var value = (0, _getSourceData.default)(DATA, FIELD_ID);
61
+ expect(value).toEqual(VALUE);
62
+ });
63
+ it('should handle null data', function () {
64
+ var FIELD_ID = 'field.nested';
65
+ var value = (0, _getSourceData.default)(null, FIELD_ID);
66
+ expect(value).toBeUndefined();
67
+ });
68
+ it('should handle undefined data', function () {
69
+ var FIELD_ID = 'field.nested';
70
+ var value = (0, _getSourceData.default)(undefined, FIELD_ID);
71
+ expect(value).toBeUndefined();
72
+ });
73
+ it('should handle missing value', function () {
74
+ var FIELD_ID = 'field.nested';
75
+ var VALUE = 'other value';
76
+ var DATA = {
77
+ field: {
78
+ other: VALUE
79
+ }
80
+ };
81
+ var value = (0, _getSourceData.default)(DATA, FIELD_ID);
82
+ expect(value).toBeUndefined();
83
+ });
84
+ it('should handle null fieldId', function () {
85
+ var VALUE = 'value';
86
+ var DATA = {
87
+ field: VALUE
88
+ };
89
+ var value = (0, _getSourceData.default)(DATA, null);
90
+ expect(value).toBeUndefined();
91
+ });
92
+ it('should handle undefined fieldId', function () {
93
+ var VALUE = 'value';
94
+ var DATA = {
95
+ field: VALUE
96
+ };
97
+ var value = (0, _getSourceData.default)(DATA, undefined);
98
+ expect(value).toBeUndefined();
99
+ });
100
+ it('should handle empty fieldId', function () {
101
+ var VALUE = 'value';
102
+ var DATA = {
103
+ field: VALUE
104
+ };
105
+ var value = (0, _getSourceData.default)(DATA, '');
106
+ expect(value).toBeUndefined();
107
+ });
108
+ it('should handle fieldId with trailing dot', function () {
109
+ var FIELD_ID = 'field.';
110
+ var VALUE = 'value';
111
+ var DATA = {
112
+ field: VALUE
113
+ };
114
+ var value = (0, _getSourceData.default)(DATA, FIELD_ID);
115
+ expect(value).toBeUndefined();
116
+ });
117
+ it('should handle fieldId with leading dot', function () {
118
+ var FIELD_ID = '.field';
119
+ var VALUE = 'value';
120
+ var DATA = {
121
+ field: VALUE
122
+ };
123
+ var value = (0, _getSourceData.default)(DATA, FIELD_ID);
124
+ expect(value).toBeUndefined();
125
+ });
126
+ it('should handle fieldId that is just a dot', function () {
127
+ var FIELD_ID = '.';
128
+ var VALUE = 'value';
129
+ var DATA = {
130
+ field: VALUE
131
+ };
132
+ var value = (0, _getSourceData.default)(DATA, FIELD_ID);
133
+ expect(value).toBeUndefined();
134
+ });
135
+ it('should handle a reference to an array item', function () {
136
+ var FIELD_ID = 'items[1]';
137
+ var ALPHA = 'alpha';
138
+ var BETA = 'beta';
139
+ var DATA = {
140
+ items: [ALPHA, BETA]
141
+ };
142
+ var value = (0, _getSourceData.default)(DATA, FIELD_ID);
143
+ expect(value).toEqual(BETA);
144
+ });
145
+ it('should handle a reference to an array that does not exist', function () {
146
+ var FIELD_ID = 'items[1]';
147
+ var DATA = {};
148
+ var value = (0, _getSourceData.default)(DATA, FIELD_ID);
149
+ expect(value).toBeUndefined();
150
+ });
151
+ });
152
+ });
153
+ });
@@ -4,9 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
7
8
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
8
9
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
12
+ 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); }
10
13
  var getValueAndLabel = function getValueAndLabel(opt, itemStructure) {
11
14
  var _value;
12
15
  var value = opt.value || opt.id;
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+
3
+ var _refDataToOptions = _interopRequireDefault(require("./refDataToOptions"));
4
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5
+ // Local imports
6
+
7
+ describe('utils', function () {
8
+ describe('Data', function () {
9
+ describe('refDataToOptions', function () {
10
+ it('can handle a null refData', function () {
11
+ expect((0, _refDataToOptions.default)(null)).toEqual([]);
12
+ });
13
+ it('can handle an undefined refData', function () {
14
+ expect((0, _refDataToOptions.default)(undefined)).toEqual([]);
15
+ });
16
+ it('can handle genuine refData', function () {
17
+ var REF_DATA = [{
18
+ id: 'a',
19
+ name: 'Alpha'
20
+ }, {
21
+ id: 'b',
22
+ name: 'Bravo'
23
+ }, {
24
+ id: 'c',
25
+ name: 'Charlie'
26
+ }];
27
+ expect((0, _refDataToOptions.default)(REF_DATA)).toEqual([{
28
+ id: 'a',
29
+ name: 'Alpha',
30
+ value: 'a',
31
+ label: 'Alpha'
32
+ }, {
33
+ id: 'b',
34
+ name: 'Bravo',
35
+ value: 'b',
36
+ label: 'Bravo'
37
+ }, {
38
+ id: 'c',
39
+ name: 'Charlie',
40
+ value: 'c',
41
+ label: 'Charlie'
42
+ }]);
43
+ });
44
+ it('can handle refData that is already in a usable options format', function () {
45
+ var REF_DATA = [{
46
+ value: 'a',
47
+ label: 'Alpha'
48
+ }, {
49
+ value: 'b',
50
+ label: 'Bravo'
51
+ }, {
52
+ value: 'c',
53
+ label: 'Charlie'
54
+ }];
55
+ expect((0, _refDataToOptions.default)(REF_DATA)).toEqual([{
56
+ value: 'a',
57
+ label: 'Alpha'
58
+ }, {
59
+ value: 'b',
60
+ label: 'Bravo'
61
+ }, {
62
+ value: 'c',
63
+ label: 'Charlie'
64
+ }]);
65
+ });
66
+ it('can handle refData that is in a mixed format', function () {
67
+ var REF_DATA = [{
68
+ id: 'a',
69
+ name: 'Alpha',
70
+ type: 'Delta'
71
+ }, {
72
+ value: 'b',
73
+ label: 'Bravo'
74
+ }, {
75
+ id: 'c',
76
+ name: 'Charlie',
77
+ type: 'Delta'
78
+ }];
79
+ expect((0, _refDataToOptions.default)(REF_DATA)).toEqual([{
80
+ id: 'a',
81
+ name: 'Alpha',
82
+ value: 'a',
83
+ label: 'Alpha',
84
+ type: 'Delta'
85
+ }, {
86
+ value: 'b',
87
+ label: 'Bravo'
88
+ }, {
89
+ id: 'c',
90
+ name: 'Charlie',
91
+ value: 'c',
92
+ label: 'Charlie',
93
+ type: 'Delta'
94
+ }]);
95
+ });
96
+ it('can handle refData that contains strings and objects', function () {
97
+ var REF_DATA = [{
98
+ id: 'a',
99
+ name: 'Alpha',
100
+ type: 'Delta'
101
+ }, {
102
+ value: 'b',
103
+ label: 'Bravo'
104
+ }, 'Charlie', {
105
+ id: 'd',
106
+ name: 'Delta',
107
+ type: 'Delta'
108
+ }];
109
+ expect((0, _refDataToOptions.default)(REF_DATA)).toEqual([{
110
+ id: 'a',
111
+ name: 'Alpha',
112
+ value: 'a',
113
+ label: 'Alpha',
114
+ type: 'Delta'
115
+ }, {
116
+ value: 'b',
117
+ label: 'Bravo'
118
+ }, 'Charlie', {
119
+ id: 'd',
120
+ name: 'Delta',
121
+ value: 'd',
122
+ label: 'Delta',
123
+ type: 'Delta'
124
+ }]);
125
+ });
126
+ it('can handle refData with custom value and label properties', function () {
127
+ var REF_DATA = [{
128
+ id: 1,
129
+ displayName: 'Alpha'
130
+ }, {
131
+ id: 2,
132
+ displayName: 'Bravo'
133
+ }, {
134
+ id: 3,
135
+ displayName: 'Charlie'
136
+ }];
137
+ var ITEM_STRUCTURE = {
138
+ value: 'id',
139
+ label: 'displayName'
140
+ };
141
+ expect((0, _refDataToOptions.default)(REF_DATA, ITEM_STRUCTURE)).toEqual([{
142
+ id: 1,
143
+ displayName: 'Alpha',
144
+ value: '1',
145
+ label: 'Alpha'
146
+ }, {
147
+ id: 2,
148
+ displayName: 'Bravo',
149
+ value: '2',
150
+ label: 'Bravo'
151
+ }, {
152
+ id: 3,
153
+ displayName: 'Charlie',
154
+ value: '3',
155
+ label: 'Charlie'
156
+ }]);
157
+ });
158
+ it('can handle refData with missing custom value and label properties', function () {
159
+ var REF_DATA = [{
160
+ id: 1,
161
+ name: 'Alpha'
162
+ }, {
163
+ id: 2,
164
+ name: 'Bravo',
165
+ displayName: 'Bravo Zulu'
166
+ }, {
167
+ id: 3,
168
+ objId: 'chaz',
169
+ name: 'Charlie'
170
+ }];
171
+ var ITEM_STRUCTURE = {
172
+ value: 'objId',
173
+ label: 'displayName'
174
+ };
175
+ expect((0, _refDataToOptions.default)(REF_DATA, ITEM_STRUCTURE)).toEqual([{
176
+ id: 1,
177
+ name: 'Alpha',
178
+ value: '1',
179
+ label: 'Alpha'
180
+ }, {
181
+ id: 2,
182
+ name: 'Bravo',
183
+ displayName: 'Bravo Zulu',
184
+ value: '2',
185
+ label: 'Bravo Zulu'
186
+ }, {
187
+ id: 3,
188
+ objId: 'chaz',
189
+ name: 'Charlie',
190
+ value: 'chaz',
191
+ label: 'Charlie'
192
+ }]);
193
+ });
194
+ });
195
+ });
196
+ });