@ukhomeoffice/cop-react-form-renderer 5.41.0 → 5.42.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.
- package/dist/components/CheckYourAnswers/Answer.js +1 -2
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +4 -8
- package/dist/components/CheckYourAnswers/index.js +1 -2
- package/dist/components/CollectionPage/CollectionPage.js +2 -4
- package/dist/components/CollectionPage/index.js +1 -2
- package/dist/components/CollectionSummary/BannerStrip.js +2 -4
- package/dist/components/CollectionSummary/CollectionSummary.js +2 -4
- package/dist/components/CollectionSummary/Confirmation.js +4 -8
- package/dist/components/CollectionSummary/SummaryCard.js +9 -18
- package/dist/components/CollectionSummary/index.js +1 -2
- package/dist/components/FormComponent/Collection.js +4 -6
- package/dist/components/FormComponent/Container.js +2 -4
- package/dist/components/FormComponent/FormComponent.js +1 -2
- package/dist/components/FormComponent/helpers/addLabel.js +1 -2
- package/dist/components/FormComponent/helpers/getComponentDisabled.js +1 -2
- package/dist/components/FormComponent/helpers/getComponentError.js +1 -2
- package/dist/components/FormComponent/helpers/getComponentFieldSet.js +2 -3
- package/dist/components/FormComponent/index.js +1 -2
- package/dist/components/FormPage/FormPage.js +2 -4
- package/dist/components/FormPage/index.js +1 -2
- package/dist/components/FormRenderer/FormRenderer.js +2 -4
- package/dist/components/FormRenderer/handlers/cyaAction.js +1 -2
- package/dist/components/FormRenderer/handlers/getPageId.js +1 -2
- package/dist/components/FormRenderer/handlers/index.js +1 -2
- package/dist/components/FormRenderer/handlers/navigate.js +1 -2
- package/dist/components/FormRenderer/handlers/submissionError.js +1 -2
- package/dist/components/FormRenderer/helpers/canActionProceed.js +1 -2
- package/dist/components/FormRenderer/helpers/canCYASubmit.js +1 -2
- package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +2 -3
- package/dist/components/FormRenderer/helpers/getCYA.js +1 -2
- package/dist/components/FormRenderer/helpers/getFormState.js +1 -2
- package/dist/components/FormRenderer/helpers/getNextPageId.js +2 -3
- package/dist/components/FormRenderer/helpers/getPage.js +1 -2
- package/dist/components/FormRenderer/helpers/getRelevantPages.js +1 -2
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +1 -2
- package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +1 -2
- package/dist/components/FormRenderer/helpers/index.js +1 -2
- package/dist/components/FormRenderer/index.js +1 -2
- package/dist/components/FormRenderer/onCYAAction.js +1 -2
- package/dist/components/FormRenderer/onPageAction.js +1 -2
- package/dist/components/FormRenderer/onTaskAction.js +1 -2
- package/dist/components/PageActions/ActionButton.js +2 -4
- package/dist/components/PageActions/PageActions.js +1 -2
- package/dist/components/PageActions/index.js +1 -2
- package/dist/components/SummaryList/GroupAction.js +1 -2
- package/dist/components/SummaryList/RowAction.js +1 -2
- package/dist/components/SummaryList/SummaryList.js +2 -4
- package/dist/components/SummaryList/SummaryListHeadingRow.js +1 -2
- package/dist/components/SummaryList/SummaryListRow.js +1 -2
- package/dist/components/SummaryList/SummaryListTitleRow.js +1 -2
- package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +1 -2
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +1 -2
- package/dist/components/SummaryList/index.js +1 -2
- package/dist/components/TaskList/Task.js +2 -4
- package/dist/components/TaskList/TaskList.js +3 -6
- package/dist/components/TaskList/TaskState.js +2 -4
- package/dist/components/TaskList/index.js +1 -2
- package/dist/context/HooksContext/HooksContext.js +3 -6
- package/dist/context/HooksContext/index.js +1 -2
- package/dist/context/ValidationContext/ValidationContext.js +2 -4
- package/dist/context/ValidationContext/index.js +1 -2
- package/dist/hooks/useAxios.js +1 -2
- package/dist/hooks/useGetRequest.js +6 -12
- package/dist/hooks/useHooks.js +1 -2
- package/dist/hooks/useRefData.js +3 -6
- package/dist/hooks/useValidation.js +1 -2
- package/dist/index.js +1 -2
- package/dist/models/CollectionLabels.js +1 -2
- package/dist/models/ComponentTypes.js +1 -2
- package/dist/models/EventTypes.js +1 -2
- package/dist/models/FormPages.js +1 -2
- package/dist/models/FormTypes.js +1 -2
- package/dist/models/HubFormats.js +1 -2
- package/dist/models/PageAction.js +3 -6
- package/dist/models/TaskStates.js +2 -4
- package/dist/models/index.js +1 -2
- package/dist/setupTests.js +6 -11
- package/dist/utils/CheckYourAnswers/getCYAAction.js +1 -2
- package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +1 -2
- package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +1 -2
- package/dist/utils/CheckYourAnswers/getCYARow.js +2 -3
- package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +1 -2
- package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +1 -2
- package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +1 -2
- package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +1 -2
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +1 -2
- package/dist/utils/CheckYourAnswers/index.js +1 -2
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +2 -4
- package/dist/utils/CollectionPage/addCollectionPageEntry.js +1 -2
- package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +1 -2
- package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +1 -2
- package/dist/utils/CollectionPage/getCollectionPageActiveId.js +1 -2
- package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +1 -2
- package/dist/utils/CollectionPage/getCollectionPageData.js +1 -2
- package/dist/utils/CollectionPage/getQuickEditPage.js +2 -3
- package/dist/utils/CollectionPage/index.js +1 -2
- package/dist/utils/CollectionPage/mergeCollectionPages.js +1 -2
- package/dist/utils/CollectionPage/removeCollectionPageEntry.js +1 -2
- package/dist/utils/CollectionPage/setCollectionPageData.js +1 -2
- package/dist/utils/Component/addShowWhen.js +1 -2
- package/dist/utils/Component/applyToComponentTree.js +1 -2
- package/dist/utils/Component/cleanAttributes.js +2 -4
- package/dist/utils/Component/elevateNestedComponents.js +3 -4
- package/dist/utils/Component/getComponent.js +2 -4
- package/dist/utils/Component/getDefaultValue.js +1 -2
- package/dist/utils/Component/getDefaultValueFromConfig.js +1 -2
- package/dist/utils/Component/index.js +1 -2
- package/dist/utils/Component/isEditable.js +2 -4
- package/dist/utils/Component/optionIsSelected.js +1 -2
- package/dist/utils/Component/setupContainerComponentsPath.js +1 -2
- package/dist/utils/Component/showComponent.js +1 -2
- package/dist/utils/Component/wrapInFormGroup.js +1 -2
- package/dist/utils/Condition/index.js +1 -2
- package/dist/utils/Condition/meetsAllConditions.js +1 -2
- package/dist/utils/Condition/meetsCondition.js +1 -2
- package/dist/utils/Condition/meetsOneCondition.js +1 -2
- package/dist/utils/Condition/setupConditions.js +1 -2
- package/dist/utils/Container/getEditableComponents.js +1 -2
- package/dist/utils/Container/index.js +1 -2
- package/dist/utils/Container/setupNesting.js +3 -4
- package/dist/utils/Container/showContainer.js +1 -2
- package/dist/utils/Data/applyFormula.js +1 -2
- package/dist/utils/Data/getAutocompleteSource.js +51 -18
- package/dist/utils/Data/getAutocompleteSource.test.js +89 -221
- package/dist/utils/Data/getDataPath.js +1 -2
- package/dist/utils/Data/getOptions.js +1 -2
- package/dist/utils/Data/getSourceData.js +1 -2
- package/dist/utils/Data/index.js +1 -2
- package/dist/utils/Data/refDataToOptions.js +1 -2
- package/dist/utils/Data/setDataItem.js +1 -2
- package/dist/utils/Data/setupFormData.js +1 -2
- package/dist/utils/Data/setupRefDataUrlForComponent.js +1 -2
- package/dist/utils/FormPage/applyConditionalProperties.js +1 -2
- package/dist/utils/FormPage/getFormPage.js +1 -2
- package/dist/utils/FormPage/getFormPages.js +1 -2
- package/dist/utils/FormPage/getPageActions.js +1 -2
- package/dist/utils/FormPage/getPageTitle.js +1 -2
- package/dist/utils/FormPage/getParagraphFromText.js +1 -2
- package/dist/utils/FormPage/index.js +1 -2
- package/dist/utils/FormPage/showFormPage.js +1 -2
- package/dist/utils/FormPage/showFormPageCYA.js +1 -2
- package/dist/utils/FormPage/useComponent.js +1 -2
- package/dist/utils/Format/formatData.js +1 -2
- package/dist/utils/Format/formatDataForComponent.js +2 -4
- package/dist/utils/Format/formatDataForForm.js +1 -2
- package/dist/utils/Format/formatDataForPage.js +2 -4
- package/dist/utils/Format/index.js +1 -2
- package/dist/utils/Hub/getFormHub.js +1 -2
- package/dist/utils/Hub/index.js +1 -2
- package/dist/utils/Meta/constants.js +2 -4
- package/dist/utils/Meta/documents/getDocuments.js +1 -2
- package/dist/utils/Meta/documents/index.js +1 -2
- package/dist/utils/Meta/documents/setDocumentsForField.js +1 -2
- package/dist/utils/Meta/index.js +1 -2
- package/dist/utils/Operate/checkValueIsTruthy.js +1 -2
- package/dist/utils/Operate/getFirstOf.js +1 -2
- package/dist/utils/Operate/getIndexOfMatchingValueIn.js +1 -2
- package/dist/utils/Operate/index.js +1 -2
- package/dist/utils/Operate/persistValueInFormData.js +1 -2
- package/dist/utils/Operate/runPageOperations.js +1 -2
- package/dist/utils/Operate/setValueInFormData.js +1 -2
- package/dist/utils/Operate/shouldRun.js +1 -2
- package/dist/utils/Validate/additional/conditionallyRequired.js +1 -2
- package/dist/utils/Validate/additional/index.js +1 -2
- package/dist/utils/Validate/additional/mustBeAfter.js +1 -2
- package/dist/utils/Validate/additional/mustBeBefore.js +1 -2
- package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +1 -2
- package/dist/utils/Validate/additional/mustBeGreaterThan.js +1 -2
- package/dist/utils/Validate/additional/mustBeInTheFuture.js +1 -2
- package/dist/utils/Validate/additional/mustBeInThePast.js +1 -2
- package/dist/utils/Validate/additional/mustBeLessThan.js +1 -2
- package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -2
- package/dist/utils/Validate/additional/mustBeNumbersOnly.js +1 -2
- package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -2
- package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +1 -2
- package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -2
- package/dist/utils/Validate/additional/mustNotContainSql.js +1 -2
- package/dist/utils/Validate/additional/mustSelectOnlyOne.js +1 -2
- package/dist/utils/Validate/additional/utils.js +3 -6
- package/dist/utils/Validate/index.js +1 -2
- package/dist/utils/Validate/validateCollection.js +1 -2
- package/dist/utils/Validate/validateComponent.js +2 -3
- package/dist/utils/Validate/validateContainer.js +1 -2
- package/dist/utils/Validate/validateDate.js +2 -4
- package/dist/utils/Validate/validateEmail.js +1 -2
- package/dist/utils/Validate/validateMultifile.js +2 -4
- package/dist/utils/Validate/validatePage.js +1 -2
- package/dist/utils/Validate/validateRegex.js +1 -2
- package/dist/utils/Validate/validateRequired.js +1 -2
- package/dist/utils/Validate/validateTextArea.js +1 -2
- package/dist/utils/Validate/validateTime.js +1 -2
- package/dist/utils/index.js +1 -2
- package/package.json +2 -2
|
@@ -2,10 +2,49 @@
|
|
|
2
2
|
|
|
3
3
|
var _getAutocompleteSource = _interopRequireDefault(require("./getAutocompleteSource"));
|
|
4
4
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
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); }
|
|
6
|
+
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; }
|
|
7
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
+
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; }
|
|
9
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
10
|
+
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
|
|
7
11
|
describe('utils', function () {
|
|
8
12
|
describe('Data', function () {
|
|
13
|
+
// test data
|
|
14
|
+
var gbCurrency = {
|
|
15
|
+
currencyName: 'Great British Pounds',
|
|
16
|
+
currencyCode: 'GBP',
|
|
17
|
+
value: 'GBP',
|
|
18
|
+
label: 'GBP',
|
|
19
|
+
slangTerm: 'quid'
|
|
20
|
+
};
|
|
21
|
+
var usCurrency = {
|
|
22
|
+
currencyName: 'United States Dollars',
|
|
23
|
+
currencyCode: 'USD',
|
|
24
|
+
value: 'USD',
|
|
25
|
+
label: 'USD',
|
|
26
|
+
slangTerm: 'bucks',
|
|
27
|
+
synonyms: ['greenbacks']
|
|
28
|
+
};
|
|
29
|
+
var options = {
|
|
30
|
+
alpha: {
|
|
31
|
+
value: 'a',
|
|
32
|
+
label: 'Alpha'
|
|
33
|
+
},
|
|
34
|
+
bravo: {
|
|
35
|
+
value: 'b',
|
|
36
|
+
label: 'Bravo'
|
|
37
|
+
},
|
|
38
|
+
alIncluded: {
|
|
39
|
+
value: 'c',
|
|
40
|
+
label: 'Call me alan'
|
|
41
|
+
},
|
|
42
|
+
alStart: {
|
|
43
|
+
value: 'd',
|
|
44
|
+
label: 'Word Alphabet'
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var testCurrencies = [gbCurrency, usCurrency];
|
|
9
48
|
describe('getAutocompleteSource', function () {
|
|
10
49
|
it('should handle a null config', function () {
|
|
11
50
|
var SOURCE = (0, _getAutocompleteSource.default)(null);
|
|
@@ -19,26 +58,14 @@ describe('utils', function () {
|
|
|
19
58
|
it('should get any specified options from the config', function () {
|
|
20
59
|
var CONFIG = {
|
|
21
60
|
data: {
|
|
22
|
-
options: [
|
|
23
|
-
value: 'a',
|
|
24
|
-
label: 'Alpha'
|
|
25
|
-
}, {
|
|
26
|
-
value: 'b',
|
|
27
|
-
label: 'Bravo'
|
|
28
|
-
}]
|
|
61
|
+
options: [options.alpha, options.bravo]
|
|
29
62
|
}
|
|
30
63
|
};
|
|
31
64
|
var SOURCE = (0, _getAutocompleteSource.default)(CONFIG);
|
|
32
65
|
expect(typeof SOURCE === 'function').toBeTruthy();
|
|
33
66
|
SOURCE('a', function (results) {
|
|
34
67
|
expect(results.length).toEqual(2);
|
|
35
|
-
expect(results).toEqual([
|
|
36
|
-
value: 'a',
|
|
37
|
-
label: 'Alpha'
|
|
38
|
-
}, {
|
|
39
|
-
value: 'b',
|
|
40
|
-
label: 'Bravo'
|
|
41
|
-
}]);
|
|
68
|
+
expect(results).toEqual([options.alpha, options.bravo]);
|
|
42
69
|
});
|
|
43
70
|
SOURCE('al', function (results) {
|
|
44
71
|
expect(results.length).toEqual(1);
|
|
@@ -51,82 +78,43 @@ describe('utils', function () {
|
|
|
51
78
|
it('should handle an empty query', function () {
|
|
52
79
|
var CONFIG = {
|
|
53
80
|
data: {
|
|
54
|
-
options: [
|
|
55
|
-
value: 'a',
|
|
56
|
-
label: 'Alpha'
|
|
57
|
-
}, {
|
|
58
|
-
value: 'b',
|
|
59
|
-
label: 'Bravo'
|
|
60
|
-
}]
|
|
81
|
+
options: [options.alpha, options.bravo]
|
|
61
82
|
}
|
|
62
83
|
};
|
|
63
84
|
var SOURCE = (0, _getAutocompleteSource.default)(CONFIG);
|
|
64
85
|
SOURCE('', function (results) {
|
|
65
86
|
expect(results.length).toEqual(2);
|
|
66
|
-
expect(results).toEqual([
|
|
67
|
-
value: 'a',
|
|
68
|
-
label: 'Alpha'
|
|
69
|
-
}, {
|
|
70
|
-
value: 'b',
|
|
71
|
-
label: 'Bravo'
|
|
72
|
-
}]);
|
|
87
|
+
expect(results).toEqual([options.alpha, options.bravo]);
|
|
73
88
|
});
|
|
74
89
|
});
|
|
75
90
|
it('should handle an undefined query', function () {
|
|
76
91
|
var CONFIG = {
|
|
77
92
|
data: {
|
|
78
|
-
options: [
|
|
79
|
-
value: 'a',
|
|
80
|
-
label: 'Alpha'
|
|
81
|
-
}, {
|
|
82
|
-
value: 'b',
|
|
83
|
-
label: 'Bravo'
|
|
84
|
-
}]
|
|
93
|
+
options: [options.alpha, options.bravo]
|
|
85
94
|
}
|
|
86
95
|
};
|
|
87
96
|
var SOURCE = (0, _getAutocompleteSource.default)(CONFIG);
|
|
88
97
|
SOURCE(undefined, function (results) {
|
|
89
98
|
expect(results.length).toEqual(2);
|
|
90
|
-
expect(results).toEqual([
|
|
91
|
-
value: 'a',
|
|
92
|
-
label: 'Alpha'
|
|
93
|
-
}, {
|
|
94
|
-
value: 'b',
|
|
95
|
-
label: 'Bravo'
|
|
96
|
-
}]);
|
|
99
|
+
expect(results).toEqual([options.alpha, options.bravo]);
|
|
97
100
|
});
|
|
98
101
|
});
|
|
99
102
|
it('should handle a null query', function () {
|
|
100
103
|
var CONFIG = {
|
|
101
104
|
data: {
|
|
102
|
-
options: [
|
|
103
|
-
value: 'a',
|
|
104
|
-
label: 'Alpha'
|
|
105
|
-
}, {
|
|
106
|
-
value: 'b',
|
|
107
|
-
label: 'Bravo'
|
|
108
|
-
}]
|
|
105
|
+
options: [options.alpha, options.bravo]
|
|
109
106
|
}
|
|
110
107
|
};
|
|
111
108
|
var SOURCE = (0, _getAutocompleteSource.default)(CONFIG);
|
|
112
109
|
SOURCE(null, function (results) {
|
|
113
110
|
expect(results.length).toEqual(2);
|
|
114
|
-
expect(results).toEqual([
|
|
115
|
-
value: 'a',
|
|
116
|
-
label: 'Alpha'
|
|
117
|
-
}, {
|
|
118
|
-
value: 'b',
|
|
119
|
-
label: 'Bravo'
|
|
120
|
-
}]);
|
|
111
|
+
expect(results).toEqual([options.alpha, options.bravo]);
|
|
121
112
|
});
|
|
122
113
|
});
|
|
123
114
|
it('should handle a missing label on an option', function () {
|
|
124
115
|
var CONFIG = {
|
|
125
116
|
data: {
|
|
126
|
-
options: [{
|
|
127
|
-
value: 'a',
|
|
128
|
-
label: 'Alpha'
|
|
129
|
-
}, {
|
|
117
|
+
options: [options.alpha, {
|
|
130
118
|
value: 'b'
|
|
131
119
|
}]
|
|
132
120
|
}
|
|
@@ -135,20 +123,28 @@ describe('utils', function () {
|
|
|
135
123
|
expect(typeof SOURCE === 'function').toBeTruthy();
|
|
136
124
|
SOURCE('a', function (results) {
|
|
137
125
|
expect(results.length).toEqual(1);
|
|
138
|
-
expect(results).toEqual([
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
126
|
+
expect(results).toEqual([options.alpha]);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
it('should return matches in the right order', function () {
|
|
130
|
+
var CONFIG = {
|
|
131
|
+
data: {
|
|
132
|
+
options: [options.alIncluded, options.alStart, options.bravo, options.alpha]
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
var SOURCE = (0, _getAutocompleteSource.default)(CONFIG);
|
|
136
|
+
expect(typeof SOURCE === 'function').toBeTruthy();
|
|
137
|
+
SOURCE('al', function (results) {
|
|
138
|
+
expect(results.length).toEqual(3);
|
|
139
|
+
expect(results).toEqual([options.alpha, options.alStart, options.alIncluded]);
|
|
142
140
|
});
|
|
143
141
|
});
|
|
144
142
|
it('should match options using a defined synonym', function () {
|
|
145
143
|
var CONFIG = {
|
|
146
144
|
data: {
|
|
147
|
-
options: [{
|
|
148
|
-
value: 'a',
|
|
149
|
-
label: 'Alpha',
|
|
145
|
+
options: [_objectSpread(_objectSpread({}, options.alpha), {}, {
|
|
150
146
|
synonyms: ['first']
|
|
151
|
-
}, {
|
|
147
|
+
}), {
|
|
152
148
|
value: 'b'
|
|
153
149
|
}]
|
|
154
150
|
}
|
|
@@ -157,11 +153,9 @@ describe('utils', function () {
|
|
|
157
153
|
expect(typeof SOURCE === 'function').toBeTruthy();
|
|
158
154
|
SOURCE('first', function (results) {
|
|
159
155
|
expect(results.length).toEqual(1);
|
|
160
|
-
expect(results).toEqual([{
|
|
161
|
-
value: 'a',
|
|
162
|
-
label: 'Alpha',
|
|
156
|
+
expect(results).toEqual([_objectSpread(_objectSpread({}, options.alpha), {}, {
|
|
163
157
|
synonyms: ['first']
|
|
164
|
-
}]);
|
|
158
|
+
})]);
|
|
165
159
|
});
|
|
166
160
|
});
|
|
167
161
|
});
|
|
@@ -175,43 +169,18 @@ describe('utils', function () {
|
|
|
175
169
|
format: '${currencyName} (${currencyCode})'
|
|
176
170
|
},
|
|
177
171
|
data: {
|
|
178
|
-
options:
|
|
179
|
-
currencyName: 'Great British Pounds',
|
|
180
|
-
currencyCode: 'GBP',
|
|
181
|
-
value: 'GBP',
|
|
182
|
-
label: 'GBP'
|
|
183
|
-
}, {
|
|
184
|
-
currencyName: 'United States Dollars',
|
|
185
|
-
currencyCode: 'USD',
|
|
186
|
-
value: 'USD',
|
|
187
|
-
label: 'USD'
|
|
188
|
-
}]
|
|
172
|
+
options: testCurrencies
|
|
189
173
|
}
|
|
190
174
|
};
|
|
191
175
|
var SOURCE = (0, _getAutocompleteSource.default)(CONFIG);
|
|
192
176
|
expect(typeof SOURCE === 'function').toBeTruthy();
|
|
193
177
|
SOURCE('GB', function (results) {
|
|
194
178
|
expect(results.length).toEqual(1);
|
|
195
|
-
expect(results).toEqual([
|
|
196
|
-
currencyName: 'Great British Pounds',
|
|
197
|
-
currencyCode: 'GBP',
|
|
198
|
-
value: 'GBP',
|
|
199
|
-
label: 'GBP'
|
|
200
|
-
}]);
|
|
179
|
+
expect(results).toEqual([gbCurrency]);
|
|
201
180
|
});
|
|
202
181
|
SOURCE(' (', function (results) {
|
|
203
182
|
expect(results.length).toEqual(2);
|
|
204
|
-
expect(results).toEqual(
|
|
205
|
-
currencyName: 'Great British Pounds',
|
|
206
|
-
currencyCode: 'GBP',
|
|
207
|
-
value: 'GBP',
|
|
208
|
-
label: 'GBP'
|
|
209
|
-
}, {
|
|
210
|
-
currencyName: 'United States Dollars',
|
|
211
|
-
currencyCode: 'USD',
|
|
212
|
-
value: 'USD',
|
|
213
|
-
label: 'USD'
|
|
214
|
-
}]);
|
|
183
|
+
expect(results).toEqual(testCurrencies);
|
|
215
184
|
});
|
|
216
185
|
});
|
|
217
186
|
it('should handle an empty query', function () {
|
|
@@ -223,33 +192,13 @@ describe('utils', function () {
|
|
|
223
192
|
format: '${currencyName} (${currencyCode})'
|
|
224
193
|
},
|
|
225
194
|
data: {
|
|
226
|
-
options:
|
|
227
|
-
currencyName: 'Great British Pounds',
|
|
228
|
-
currencyCode: 'GBP',
|
|
229
|
-
value: 'GBP',
|
|
230
|
-
label: 'GBP'
|
|
231
|
-
}, {
|
|
232
|
-
currencyName: 'United States Dollars',
|
|
233
|
-
currencyCode: 'USD',
|
|
234
|
-
value: 'USD',
|
|
235
|
-
label: 'USD'
|
|
236
|
-
}]
|
|
195
|
+
options: testCurrencies
|
|
237
196
|
}
|
|
238
197
|
};
|
|
239
198
|
var SOURCE = (0, _getAutocompleteSource.default)(CONFIG);
|
|
240
199
|
SOURCE('', function (results) {
|
|
241
200
|
expect(results.length).toEqual(2);
|
|
242
|
-
expect(results).toEqual(
|
|
243
|
-
currencyName: 'Great British Pounds',
|
|
244
|
-
currencyCode: 'GBP',
|
|
245
|
-
value: 'GBP',
|
|
246
|
-
label: 'GBP'
|
|
247
|
-
}, {
|
|
248
|
-
currencyName: 'United States Dollars',
|
|
249
|
-
currencyCode: 'USD',
|
|
250
|
-
value: 'USD',
|
|
251
|
-
label: 'USD'
|
|
252
|
-
}]);
|
|
201
|
+
expect(results).toEqual(testCurrencies);
|
|
253
202
|
});
|
|
254
203
|
});
|
|
255
204
|
it('should handle an undefined query', function () {
|
|
@@ -261,33 +210,13 @@ describe('utils', function () {
|
|
|
261
210
|
format: '${currencyName} (${currencyCode})'
|
|
262
211
|
},
|
|
263
212
|
data: {
|
|
264
|
-
options:
|
|
265
|
-
currencyName: 'Great British Pounds',
|
|
266
|
-
currencyCode: 'GBP',
|
|
267
|
-
value: 'GBP',
|
|
268
|
-
label: 'GBP'
|
|
269
|
-
}, {
|
|
270
|
-
currencyName: 'United States Dollars',
|
|
271
|
-
currencyCode: 'USD',
|
|
272
|
-
value: 'USD',
|
|
273
|
-
label: 'USD'
|
|
274
|
-
}]
|
|
213
|
+
options: testCurrencies
|
|
275
214
|
}
|
|
276
215
|
};
|
|
277
216
|
var SOURCE = (0, _getAutocompleteSource.default)(CONFIG);
|
|
278
217
|
SOURCE(undefined, function (results) {
|
|
279
218
|
expect(results.length).toEqual(2);
|
|
280
|
-
expect(results).toEqual(
|
|
281
|
-
currencyName: 'Great British Pounds',
|
|
282
|
-
currencyCode: 'GBP',
|
|
283
|
-
value: 'GBP',
|
|
284
|
-
label: 'GBP'
|
|
285
|
-
}, {
|
|
286
|
-
currencyName: 'United States Dollars',
|
|
287
|
-
currencyCode: 'USD',
|
|
288
|
-
value: 'USD',
|
|
289
|
-
label: 'USD'
|
|
290
|
-
}]);
|
|
219
|
+
expect(results).toEqual(testCurrencies);
|
|
291
220
|
});
|
|
292
221
|
});
|
|
293
222
|
it('should handle a null query', function () {
|
|
@@ -299,33 +228,13 @@ describe('utils', function () {
|
|
|
299
228
|
format: '${currencyName} (${currencyCode})'
|
|
300
229
|
},
|
|
301
230
|
data: {
|
|
302
|
-
options:
|
|
303
|
-
currencyName: 'Great British Pounds',
|
|
304
|
-
currencyCode: 'GBP',
|
|
305
|
-
value: 'GBP',
|
|
306
|
-
label: 'GBP'
|
|
307
|
-
}, {
|
|
308
|
-
currencyName: 'United States Dollars',
|
|
309
|
-
currencyCode: 'USD',
|
|
310
|
-
value: 'USD',
|
|
311
|
-
label: 'USD'
|
|
312
|
-
}]
|
|
231
|
+
options: testCurrencies
|
|
313
232
|
}
|
|
314
233
|
};
|
|
315
234
|
var SOURCE = (0, _getAutocompleteSource.default)(CONFIG);
|
|
316
235
|
SOURCE(null, function (results) {
|
|
317
236
|
expect(results.length).toEqual(2);
|
|
318
|
-
expect(results).toEqual(
|
|
319
|
-
currencyName: 'Great British Pounds',
|
|
320
|
-
currencyCode: 'GBP',
|
|
321
|
-
value: 'GBP',
|
|
322
|
-
label: 'GBP'
|
|
323
|
-
}, {
|
|
324
|
-
currencyName: 'United States Dollars',
|
|
325
|
-
currencyCode: 'USD',
|
|
326
|
-
value: 'USD',
|
|
327
|
-
label: 'USD'
|
|
328
|
-
}]);
|
|
237
|
+
expect(results).toEqual(testCurrencies);
|
|
329
238
|
});
|
|
330
239
|
});
|
|
331
240
|
it('should handle a missing label on an option', function () {
|
|
@@ -337,12 +246,7 @@ describe('utils', function () {
|
|
|
337
246
|
format: '${currencyName} (${currencyCode})'
|
|
338
247
|
},
|
|
339
248
|
data: {
|
|
340
|
-
options: [{
|
|
341
|
-
currencyName: 'Great British Pounds',
|
|
342
|
-
currencyCode: 'GBP',
|
|
343
|
-
value: 'GBP',
|
|
344
|
-
label: 'GBP'
|
|
345
|
-
}, {
|
|
249
|
+
options: [gbCurrency, {
|
|
346
250
|
currencyName: 'United States Dollars',
|
|
347
251
|
currencyCode: 'USD',
|
|
348
252
|
value: 'USD'
|
|
@@ -356,12 +260,7 @@ describe('utils', function () {
|
|
|
356
260
|
// format for item labels means the label is constructed upon processing
|
|
357
261
|
// a query - we're not relying on the 'label' field of the option.
|
|
358
262
|
expect(results.length).toEqual(2);
|
|
359
|
-
expect(results).toEqual([{
|
|
360
|
-
currencyName: 'Great British Pounds',
|
|
361
|
-
currencyCode: 'GBP',
|
|
362
|
-
value: 'GBP',
|
|
363
|
-
label: 'GBP'
|
|
364
|
-
}, {
|
|
263
|
+
expect(results).toEqual([gbCurrency, {
|
|
365
264
|
currencyName: 'United States Dollars',
|
|
366
265
|
currencyCode: 'USD',
|
|
367
266
|
value: 'USD',
|
|
@@ -378,31 +277,16 @@ describe('utils', function () {
|
|
|
378
277
|
format: '${currencyName} (${currencyCode})'
|
|
379
278
|
},
|
|
380
279
|
data: {
|
|
381
|
-
options:
|
|
382
|
-
currencyName: 'Great British Pounds',
|
|
383
|
-
currencyCode: 'GBP',
|
|
384
|
-
value: 'GBP',
|
|
385
|
-
label: 'GBP'
|
|
386
|
-
}, {
|
|
387
|
-
currencyName: 'United States Dollars',
|
|
388
|
-
currencyCode: 'USD',
|
|
389
|
-
value: 'USD',
|
|
390
|
-
label: 'USD',
|
|
391
|
-
synonyms: ['bucks']
|
|
392
|
-
}]
|
|
280
|
+
options: testCurrencies
|
|
393
281
|
}
|
|
394
282
|
};
|
|
395
283
|
var SOURCE = (0, _getAutocompleteSource.default)(CONFIG);
|
|
396
284
|
expect(typeof SOURCE === 'function').toBeTruthy();
|
|
397
|
-
SOURCE('
|
|
285
|
+
SOURCE('greenbacks', function (results) {
|
|
398
286
|
expect(results.length).toEqual(1);
|
|
399
|
-
expect(results).toEqual(
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
value: 'USD',
|
|
403
|
-
label: 'USD',
|
|
404
|
-
synonyms: ['bucks']
|
|
405
|
-
}]);
|
|
287
|
+
expect(results).toEqual(testCurrencies.filter(function (c) {
|
|
288
|
+
return c.currencyCode === 'USD';
|
|
289
|
+
}));
|
|
406
290
|
});
|
|
407
291
|
});
|
|
408
292
|
it('should match options using defined extra searchable fields', function () {
|
|
@@ -415,32 +299,16 @@ describe('utils', function () {
|
|
|
415
299
|
extraFieldsToSearch: ['slangTerm']
|
|
416
300
|
},
|
|
417
301
|
data: {
|
|
418
|
-
options:
|
|
419
|
-
currencyName: 'Great British Pounds',
|
|
420
|
-
currencyCode: 'GBP',
|
|
421
|
-
value: 'GBP',
|
|
422
|
-
label: 'GBP',
|
|
423
|
-
slangTerm: 'Quid'
|
|
424
|
-
}, {
|
|
425
|
-
currencyName: 'United States Dollars',
|
|
426
|
-
currencyCode: 'USD',
|
|
427
|
-
value: 'USD',
|
|
428
|
-
label: 'USD',
|
|
429
|
-
slangTerm: 'Dollary-doos'
|
|
430
|
-
}]
|
|
302
|
+
options: testCurrencies
|
|
431
303
|
}
|
|
432
304
|
};
|
|
433
305
|
var SOURCE = (0, _getAutocompleteSource.default)(CONFIG);
|
|
434
306
|
expect(typeof SOURCE === 'function').toBeTruthy();
|
|
435
|
-
SOURCE('
|
|
307
|
+
SOURCE('buc', function (results) {
|
|
436
308
|
expect(results.length).toEqual(1);
|
|
437
|
-
expect(results).toEqual(
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
value: 'USD',
|
|
441
|
-
label: 'USD',
|
|
442
|
-
slangTerm: 'Dollary-doos'
|
|
443
|
-
}]);
|
|
309
|
+
expect(results).toEqual(testCurrencies.filter(function (c) {
|
|
310
|
+
return c.currencyCode === 'USD';
|
|
311
|
+
}));
|
|
444
312
|
});
|
|
445
313
|
});
|
|
446
314
|
});
|
package/dist/utils/Data/index.js
CHANGED
|
@@ -29,5 +29,4 @@ var getPageTitle = function getPageTitle(title, formData) {
|
|
|
29
29
|
});
|
|
30
30
|
return typeof shownOption === 'string' ? _copReactComponents.Utils.interpolateString(shownOption, formData) : _copReactComponents.Utils.interpolateString(shownOption.title, formData);
|
|
31
31
|
};
|
|
32
|
-
var _default = getPageTitle;
|
|
33
|
-
exports.default = _default;
|
|
32
|
+
var _default = exports.default = getPageTitle;
|
|
@@ -52,5 +52,4 @@ var showFormPage = function showFormPage(page, data) {
|
|
|
52
52
|
// the page has no editable components. In either case, it should be shown.
|
|
53
53
|
return true;
|
|
54
54
|
};
|
|
55
|
-
var _default = showFormPage;
|
|
56
|
-
exports.default = _default;
|
|
55
|
+
var _default = exports.default = showFormPage;
|
|
@@ -27,11 +27,9 @@ var formatDataForComponent = function formatDataForComponent(component, data, ev
|
|
|
27
27
|
* @param {object} data The top-level form data.
|
|
28
28
|
* @param {string} eventType What type of event initiated this call.
|
|
29
29
|
*/
|
|
30
|
-
var formatDataForComponents = function formatDataForComponents(components, data, eventType) {
|
|
30
|
+
var formatDataForComponents = exports.formatDataForComponents = function formatDataForComponents(components, data, eventType) {
|
|
31
31
|
components.forEach(function (component) {
|
|
32
32
|
return formatDataForComponent(component, data, eventType);
|
|
33
33
|
});
|
|
34
34
|
};
|
|
35
|
-
exports.
|
|
36
|
-
var _default = formatDataForComponent;
|
|
37
|
-
exports.default = _default;
|
|
35
|
+
var _default = exports.default = formatDataForComponent;
|
|
@@ -24,5 +24,4 @@ var formatDataForForm = function formatDataForForm(form, baseData, eventType) {
|
|
|
24
24
|
(0, _formatDataForPage.formatDataForPages)(form.pages, data, eventType);
|
|
25
25
|
return data;
|
|
26
26
|
};
|
|
27
|
-
var _default = formatDataForForm;
|
|
28
|
-
exports.default = _default;
|
|
27
|
+
var _default = exports.default = formatDataForForm;
|
|
@@ -23,11 +23,9 @@ var formatDataForPage = function formatDataForPage(page, data, eventType) {
|
|
|
23
23
|
* @param {object} data The top-level form data.
|
|
24
24
|
* @param {string} eventType What type of event initiated this call.
|
|
25
25
|
*/
|
|
26
|
-
var formatDataForPages = function formatDataForPages(pages, data, eventType) {
|
|
26
|
+
var formatDataForPages = exports.formatDataForPages = function formatDataForPages(pages, data, eventType) {
|
|
27
27
|
pages.forEach(function (page) {
|
|
28
28
|
return formatDataForPage(page, data, eventType);
|
|
29
29
|
});
|
|
30
30
|
};
|
|
31
|
-
exports.
|
|
32
|
-
var _default = formatDataForPage;
|
|
33
|
-
exports.default = _default;
|
|
31
|
+
var _default = exports.default = formatDataForPage;
|