@ukhomeoffice/cop-react-form-renderer 2.6.2-alpha → 2.7.3

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 (27) hide show
  1. package/dist/components/CheckYourAnswers/Answer.js +3 -1
  2. package/dist/components/CheckYourAnswers/Answer.test.js +3 -2
  3. package/dist/components/CheckYourAnswers/CheckYourAnswers.js +45 -5
  4. package/dist/components/CheckYourAnswers/CheckYourAnswers.scss +10 -0
  5. package/dist/components/CheckYourAnswers/CheckYourAnswers.stories.mdx +331 -269
  6. package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +74 -12
  7. package/dist/components/FormRenderer/FormRenderer.test.js +8 -8
  8. package/dist/components/FormRenderer/helpers/canActionProceed.js +1 -1
  9. package/dist/components/FormRenderer/helpers/canCYASubmit.js +1 -1
  10. package/dist/components/SummaryList/GroupAction.js +68 -0
  11. package/dist/components/SummaryList/GroupAction.test.js +94 -0
  12. package/dist/components/SummaryList/SummaryList.js +15 -4
  13. package/dist/components/SummaryList/SummaryList.scss +29 -5
  14. package/dist/components/SummaryList/SummaryList.test.js +47 -4
  15. package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +27 -0
  16. package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +77 -0
  17. package/dist/components/TaskList/TaskList.js +4 -2
  18. package/dist/components/TaskList/TaskList.scss +11 -3
  19. package/dist/components/TaskList/TaskList.test.js +21 -15
  20. package/dist/json/groupOfRow.json +137 -0
  21. package/dist/json/groupOfRowData.json +15 -0
  22. package/dist/json/taskList.json +18 -8
  23. package/dist/models/PageAction.js +2 -1
  24. package/dist/models/TaskStates.js +4 -4
  25. package/dist/utils/Validate/validatePage.js +7 -6
  26. package/dist/utils/Validate/validatePage.test.js +60 -12
  27. package/package.json +2 -2
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+
3
+ var _getGroupActionAttributes = _interopRequireDefault(require("./getGroupActionAttributes"));
4
+
5
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
+
7
+ describe('components', function () {
8
+ describe('SummaryList', function () {
9
+ describe('helpers', function () {
10
+ describe('getGroupActionAttributes', function () {
11
+ it('should handle a null row', function () {
12
+ expect((0, _getGroupActionAttributes.default)(null)).toEqual({});
13
+ });
14
+ it('should handle a row without an action', function () {
15
+ expect((0, _getGroupActionAttributes.default)({})).toEqual({});
16
+ });
17
+ it('should handle a row with an empty action', function () {
18
+ var ROW = {
19
+ action: {}
20
+ };
21
+ expect((0, _getGroupActionAttributes.default)(ROW)).toEqual({});
22
+ });
23
+ it('should handle a row with a page', function () {
24
+ var PAGE = 'alpha';
25
+ var ROW = {
26
+ action: {
27
+ page: PAGE
28
+ }
29
+ };
30
+ expect((0, _getGroupActionAttributes.default)(ROW)).toEqual({
31
+ href: "/".concat(PAGE)
32
+ });
33
+ });
34
+ it('should handle a row with an onAction function', function () {
35
+ var ON_ACTION_CALLS = [];
36
+
37
+ var ON_ACTION = function ON_ACTION(row) {
38
+ ON_ACTION_CALLS.push(row);
39
+ };
40
+
41
+ var ROW = {
42
+ action: {
43
+ onAction: ON_ACTION
44
+ }
45
+ };
46
+ var ATTRS = (0, _getGroupActionAttributes.default)(ROW);
47
+ expect(ATTRS.onClick).toBeDefined();
48
+ expect(ATTRS.href).not.toBeDefined();
49
+ ATTRS.onClick();
50
+ expect(ON_ACTION_CALLS.length).toEqual(1);
51
+ expect(ON_ACTION_CALLS[0]).toEqual(ROW);
52
+ });
53
+ it('should favour onAction over href', function () {
54
+ var ON_ACTION_CALLS = [];
55
+
56
+ var ON_ACTION = function ON_ACTION(row) {
57
+ ON_ACTION_CALLS.push(row);
58
+ };
59
+
60
+ var HREF = 'http://alpha.homeoffice.gov.uk';
61
+ var ROW = {
62
+ action: {
63
+ href: HREF,
64
+ onAction: ON_ACTION
65
+ }
66
+ };
67
+ var ATTRS = (0, _getGroupActionAttributes.default)(ROW);
68
+ expect(ATTRS.onClick).toBeDefined();
69
+ expect(ATTRS.href).not.toBeDefined();
70
+ ATTRS.onClick();
71
+ expect(ON_ACTION_CALLS.length).toEqual(1);
72
+ expect(ON_ACTION_CALLS[0]).toEqual(ROW);
73
+ });
74
+ });
75
+ });
76
+ });
77
+ });
@@ -68,8 +68,10 @@ var TaskList = function TaskList(_ref) {
68
68
  return /*#__PURE__*/_react.default.createElement("div", _extends({}, attrs, {
69
69
  className: classes()
70
70
  }), /*#__PURE__*/_react.default.createElement("h2", {
71
- className: "govuk-heading-s govuk-!-margin-bottom-2"
72
- }, "".concat(refTitle, " ").concat(refNumber)), numberOfSections !== numberOfCompleteSections && /*#__PURE__*/_react.default.createElement("h2", {
71
+ className: "hods-task-reference-description govuk-heading-s govuk-!-margin-bottom-2 govuk-!-padding-right-1"
72
+ }, "".concat(refTitle)), /*#__PURE__*/_react.default.createElement("h2", {
73
+ className: "govuk-heading-s hods-task-reference"
74
+ }, "".concat(refNumber)), numberOfSections !== numberOfCompleteSections && /*#__PURE__*/_react.default.createElement("h2", {
73
75
  className: "govuk-heading-s govuk-!-margin-bottom-2"
74
76
  }, "Incomplete form"), /*#__PURE__*/_react.default.createElement("p", {
75
77
  className: "govuk-body govuk-!-margin-bottom-7"
@@ -15,9 +15,7 @@
15
15
  @include govuk-responsive-margin(9, 'bottom');
16
16
  list-style: none;
17
17
  padding-left: 0;
18
- @include govuk-media-query($from: tablet) {
19
- padding-left: govuk-spacing(6);
20
- }
18
+ padding-left: govuk-spacing(4);
21
19
  }
22
20
  }
23
21
 
@@ -54,6 +52,16 @@
54
52
  }
55
53
  }
56
54
 
55
+ .hods-task-reference-description{
56
+ @include govuk-media-query($from: 450px) {
57
+ float: left;
58
+ }
59
+ }
60
+
61
+ .hods-task-reference{
62
+ font-weight: normal;
63
+ }
64
+
57
65
  // The `hods-task-list__task-completed` class was previously used on the task
58
66
  // list for the completed tag (changed in 86c90ec) – it's still included here to
59
67
  // avoid breaking task lists in existing prototypes.
@@ -57,23 +57,26 @@ describe('components', function () {
57
57
  expect(container.childNodes.length).toEqual(1);
58
58
  var referenceHeading = container.childNodes[0].childNodes[0];
59
59
  expect(referenceHeading.tagName).toEqual('H2');
60
- expect(referenceHeading.textContent).toEqual('COP reference number 123');
61
- var incompleteForm = container.childNodes[0].childNodes[1];
60
+ expect(referenceHeading.textContent).toEqual('COP reference number');
61
+ var referenceNumber = container.childNodes[0].childNodes[1];
62
+ expect(referenceNumber.tagName).toEqual('H2');
63
+ expect(referenceNumber.textContent).toEqual('123');
64
+ var incompleteForm = container.childNodes[0].childNodes[2];
62
65
  expect(incompleteForm.tagName).toEqual('H2');
63
66
  expect(incompleteForm.textContent).toEqual('Incomplete form');
64
- var numComplete = container.childNodes[0].childNodes[2];
67
+ var numComplete = container.childNodes[0].childNodes[3];
65
68
  expect(numComplete.tagName).toEqual('P');
66
69
  expect(numComplete.textContent).toEqual('You have completed 2 of 6 sections');
67
- expect(container.childNodes[0].childNodes.length).toEqual(7);
68
- var subSectionOneHeading = container.childNodes[0].childNodes[3];
70
+ expect(container.childNodes[0].childNodes.length).toEqual(8);
71
+ var subSectionOneHeading = container.childNodes[0].childNodes[4];
69
72
  expect(subSectionOneHeading.tagName).toEqual('H2');
70
73
  expect(subSectionOneHeading.textContent).toEqual('1. These are your tasks');
71
- var subSectionOneList = container.childNodes[0].childNodes[4];
74
+ var subSectionOneList = container.childNodes[0].childNodes[5];
72
75
  expect(subSectionOneList.childNodes.length).toEqual(3);
73
- var subSectionTwoHeading = container.childNodes[0].childNodes[5];
76
+ var subSectionTwoHeading = container.childNodes[0].childNodes[6];
74
77
  expect(subSectionTwoHeading.tagName).toEqual('H2');
75
78
  expect(subSectionTwoHeading.textContent).toEqual('2. These are your extra bonus tasks');
76
- var subSectionTwoList = container.childNodes[0].childNodes[6];
79
+ var subSectionTwoList = container.childNodes[0].childNodes[7];
77
80
  expect(subSectionTwoList.childNodes.length).toEqual(3);
78
81
  });
79
82
  it('should not show incomplete form if form is complete', function () {
@@ -118,11 +121,14 @@ describe('components', function () {
118
121
  })),
119
122
  container = _render2.container;
120
123
 
121
- expect(container.childNodes[0].childNodes.length).toEqual(6);
124
+ expect(container.childNodes[0].childNodes.length).toEqual(7);
122
125
  var referenceHeading = container.childNodes[0].childNodes[0];
123
126
  expect(referenceHeading.tagName).toEqual('H2');
124
- expect(referenceHeading.textContent).toEqual('COP reference number 123');
125
- var numComplete = container.childNodes[0].childNodes[1];
127
+ expect(referenceHeading.textContent).toEqual('COP reference number');
128
+ var referenceNumber = container.childNodes[0].childNodes[1];
129
+ expect(referenceNumber.tagName).toEqual('H2');
130
+ expect(referenceNumber.textContent).toEqual('123');
131
+ var numComplete = container.childNodes[0].childNodes[2];
126
132
  expect(numComplete.tagName).toEqual('P');
127
133
  expect(numComplete.textContent).toEqual('You have completed 6 of 6 sections');
128
134
  });
@@ -153,7 +159,7 @@ describe('components', function () {
153
159
  })),
154
160
  container = _render3.container;
155
161
 
156
- var subSectionOne = container.childNodes[0].childNodes[3];
162
+ var subSectionOne = container.childNodes[0].childNodes[4];
157
163
  expect(subSectionOne.childNodes[0].textContent).toEqual('');
158
164
  expect(subSectionOne.childNodes[1].textContent).toEqual('These are your tasks');
159
165
  });
@@ -192,9 +198,9 @@ describe('components', function () {
192
198
  })),
193
199
  container = _render4.container;
194
200
 
195
- var firstTask = container.childNodes[0].childNodes[4].childNodes[0].childNodes[0].childNodes[0];
196
- var secondTask = container.childNodes[0].childNodes[4].childNodes[1].childNodes[0].childNodes[0];
197
- var thirdTask = container.childNodes[0].childNodes[4].childNodes[2].childNodes[0].childNodes[0];
201
+ var firstTask = container.childNodes[0].childNodes[5].childNodes[0].childNodes[0].childNodes[0];
202
+ var secondTask = container.childNodes[0].childNodes[5].childNodes[1].childNodes[0].childNodes[0];
203
+ var thirdTask = container.childNodes[0].childNodes[5].childNodes[2].childNodes[0].childNodes[0];
198
204
 
199
205
  _react.fireEvent.click(firstTask.childNodes[0]);
200
206
 
@@ -0,0 +1,137 @@
1
+ {
2
+ "id": "cop-secondForm",
3
+ "version": "1",
4
+ "name": "cop-secondForm",
5
+ "title": "Cop - Second Form",
6
+ "type": "cya",
7
+ "components": [
8
+ {
9
+ "id": "firstName",
10
+ "fieldId": "firstName",
11
+ "label": "First name",
12
+ "type": "text",
13
+ "readonly": false
14
+ },
15
+ {
16
+ "id": "surname",
17
+ "fieldId": "surname",
18
+ "label": "Last name",
19
+ "type": "text",
20
+ "readonly": false
21
+ },
22
+ {
23
+ "id": "dateGroup",
24
+ "fieldId": "dateGroup",
25
+ "label": "Date",
26
+ "type": "date",
27
+ "required": true,
28
+ "readonly": false
29
+ },
30
+ {
31
+ "id": "timeGroup",
32
+ "fieldId": "timeGroup",
33
+ "label": "Time",
34
+ "type": "time",
35
+ "required": true,
36
+ "readonly": false
37
+ },
38
+ {
39
+ "id": "portGroup",
40
+ "fieldId": "portGroup",
41
+ "label": "Port",
42
+ "type": "text",
43
+ "required": true,
44
+ "readonly": false
45
+ },
46
+ {
47
+ "id": "whereGroup",
48
+ "fieldId": "whereGroup",
49
+ "label": "Where did you see the incident take place",
50
+ "type": "text",
51
+ "required": true,
52
+ "readonly": false
53
+ },
54
+ {
55
+ "id": "extraDetails",
56
+ "fieldId": "extraDetails",
57
+ "label": "Extra details",
58
+ "type": "textarea",
59
+ "readonly": false
60
+ }
61
+ ],
62
+ "pages": [
63
+ {
64
+ "id": "names",
65
+ "name": "names",
66
+ "title": "Name",
67
+ "components": [
68
+ {
69
+ "use": "firstName"
70
+ },
71
+ {
72
+ "use": "surname"
73
+ }
74
+ ],
75
+ "cya_link": {
76
+ "page": "names",
77
+ "aria_suffix": "names"
78
+ },
79
+ "actions": [ "saveAndContinue", "saveAndReturn" ]
80
+ },
81
+ {
82
+ "id": "dateLocDet",
83
+ "name": "dateLocDetName",
84
+ "title": "Date and location details",
85
+ "components": [
86
+ {
87
+ "use": "dateGroup"
88
+ },
89
+ {
90
+ "use": "timeGroup"
91
+ },
92
+ {
93
+ "use": "portGroup"
94
+ },
95
+ {
96
+ "use": "whereGroup"
97
+ }
98
+ ],
99
+ "cya_link": {
100
+ "page": "dateLocDet",
101
+ "aria_suffix": "Date and location details"
102
+ },
103
+ "actions": [ "saveAndContinue", "saveAndReturn" ]
104
+ },
105
+ {
106
+ "id": "additional-info",
107
+ "name": "additional-info",
108
+ "title": "Additional Information",
109
+ "components": [
110
+ {
111
+ "use": "extraDetails"
112
+ }
113
+ ],
114
+ "cya_link": {
115
+ "page": "additional-info",
116
+ "aria_suffix": "Additional Information"
117
+ },
118
+ "actions": [ "saveAndContinue", "saveAndReturn" ]
119
+ }
120
+ ],
121
+ "cya": {
122
+ "hide_page_titles": false,
123
+ "hide_actions": false,
124
+ "groups": [
125
+ {
126
+ "pageId": "dateLocDet"
127
+ },
128
+ {
129
+ "pageId": "names",
130
+ "title": "Names"
131
+ }
132
+ ],
133
+ "actions": [
134
+ { "type": "submit", "label": "Submit", "validate": true }
135
+ ]
136
+ }
137
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "currentUser": {
3
+ "givenName": "John",
4
+ "familyName": "Smith"
5
+ },
6
+ "businessKey": "123456789",
7
+ "dateGroupField": "01-01-2022",
8
+ "timeGroupField": "14:57",
9
+ "portGroupField": "Glasgow",
10
+ "whereGroupField": "terminal",
11
+ "firstName": "sample",
12
+ "surname": "test",
13
+ "age": "12",
14
+ "extraDetails": "extra notes here"
15
+ }
@@ -72,8 +72,10 @@
72
72
  "actions": [
73
73
  {
74
74
  "type": "saveAndNavigate",
75
- "page": "eventMode"
76
- }
75
+ "page": "eventMode",
76
+ "label": "Save and continue"
77
+ },
78
+ "saveAndReturn"
77
79
  ],
78
80
  "cya_link": {
79
81
  "page": "eventDate",
@@ -93,7 +95,8 @@
93
95
  {
94
96
  "type": "saveAndNavigate",
95
97
  "page": "cya"
96
- }
98
+ },
99
+ "saveAndReturn"
97
100
  ],
98
101
  "cya_link": {
99
102
  "page": "eventMode",
@@ -113,7 +116,8 @@
113
116
  {
114
117
  "type": "saveAndNavigate",
115
118
  "page": "cya"
116
- }
119
+ },
120
+ "saveAndReturn"
117
121
  ],
118
122
  "cya_link": {
119
123
  "page": "officeDetails",
@@ -133,7 +137,8 @@
133
137
  {
134
138
  "type": "saveAndNavigate",
135
139
  "page": "cya"
136
- }
140
+ },
141
+ "saveAndReturn"
137
142
  ],
138
143
  "cya_link": {
139
144
  "page": "immigrationDate",
@@ -153,7 +158,8 @@
153
158
  {
154
159
  "type": "saveAndNavigate",
155
160
  "page": "surname"
156
- }
161
+ },
162
+ "saveAndReturn"
157
163
  ],
158
164
  "cya_link": {
159
165
  "page": "firstName",
@@ -173,7 +179,8 @@
173
179
  {
174
180
  "type": "saveAndNavigate",
175
181
  "page": "cya"
176
- }
182
+ },
183
+ "saveAndReturn"
177
184
  ],
178
185
  "cya_link": {
179
186
  "page": "surname",
@@ -223,6 +230,9 @@
223
230
  ]
224
231
  },
225
232
  "cya": {
226
- "hide_page_titles": false
233
+ "hide_page_titles": false,
234
+ "actions": [
235
+ { "type": "saveAndContinue", "label": "save cont", "validate": true }
236
+ ]
227
237
  }
228
238
  }
@@ -28,7 +28,8 @@ var DefaultPageActions = (_DefaultPageActions = {}, _defineProperty(_DefaultPage
28
28
  label: 'Save and continue'
29
29
  }), _defineProperty(_DefaultPageActions, TYPE_SAVE_AND_NAVIGATE, {
30
30
  type: TYPE_SAVE_AND_NAVIGATE,
31
- validate: true
31
+ validate: true,
32
+ label: 'Save and continue'
32
33
  }), _defineProperty(_DefaultPageActions, TYPE_SAVE_AND_RETURN, {
33
34
  type: TYPE_SAVE_AND_RETURN,
34
35
  validate: false,
@@ -22,16 +22,16 @@ var StateTypes = {
22
22
  exports.StateTypes = StateTypes;
23
23
  var StateDetails = (_StateDetails = {}, _defineProperty(_StateDetails, TYPE_COMPLETE, {
24
24
  label: 'Completed',
25
- colour: ''
25
+ colour: 'dark-blue'
26
26
  }), _defineProperty(_StateDetails, TYPE_IN_PROGRESS, {
27
27
  label: 'In Progress',
28
- colour: 'blue'
28
+ colour: 'white'
29
29
  }), _defineProperty(_StateDetails, TYPE_NOT_STARTED, {
30
30
  label: 'Not Started',
31
- colour: 'grey'
31
+ colour: 'dark-grey'
32
32
  }), _defineProperty(_StateDetails, TYPE_CANNOT_START_YET, {
33
33
  label: 'Cannot Start Yet',
34
- colour: 'grey'
34
+ colour: 'dark-grey'
35
35
  }), _StateDetails);
36
36
  var TaskStates = {
37
37
  TYPES: StateTypes,
@@ -7,20 +7,21 @@ exports.default = void 0;
7
7
 
8
8
  var _validateComponent = _interopRequireDefault(require("./validateComponent"));
9
9
 
10
+ var _showFormPage = _interopRequireDefault(require("../FormPage/showFormPage"));
11
+
10
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
13
 
12
14
  // Local imports
13
15
 
14
16
  /**
15
17
  * Validate all of the components on a page.
16
- * @param {Array} components The components to validate.
17
- * @param {object} formData The data to use that holds this components' values.
18
+ * @param {object} page The page to validate
18
19
  * @returns An array containing all of the errors.
19
20
  */
20
- var validatePage = function validatePage(components, formData) {
21
- if (Array.isArray(components)) {
22
- return components.reduce(function (errors, component) {
23
- return errors.concat((0, _validateComponent.default)(component, formData));
21
+ var validatePage = function validatePage(page) {
22
+ if ((0, _showFormPage.default)(page, page.formData) && Array.isArray(page.components)) {
23
+ return page.components.reduce(function (errors, component) {
24
+ return errors.concat((0, _validateComponent.default)(component, page.formData));
24
25
  }, []).filter(function (e) {
25
26
  return !!e;
26
27
  }).flat();
@@ -21,20 +21,36 @@ describe('utils', function () {
21
21
  };
22
22
 
23
23
  it('should return no error when the components array is null', function () {
24
- expect((0, _validatePage.default)(null, {}).length).toEqual(0);
24
+ var PAGE = {
25
+ components: null,
26
+ formData: null
27
+ };
28
+ expect((0, _validatePage.default)(PAGE).length).toEqual(0);
25
29
  });
26
30
  it('should return no error when the components array is empty', function () {
27
- expect((0, _validatePage.default)([], {}).length).toEqual(0);
31
+ var PAGE = {
32
+ components: [],
33
+ formData: null
34
+ };
35
+ expect((0, _validatePage.default)(PAGE).length).toEqual(0);
28
36
  });
29
37
  describe('when there is no form data', function () {
30
38
  it('should return no errors when no components are required', function () {
31
39
  var COMPONENTS = [setup('a', _models.ComponentTypes.TEXT, 'Alpha', false), setup('b', _models.ComponentTypes.TEXT, 'Bravo', false)];
32
- expect((0, _validatePage.default)(COMPONENTS, null).length).toEqual(0);
40
+ var PAGE = {
41
+ components: COMPONENTS,
42
+ formData: null
43
+ };
44
+ expect((0, _validatePage.default)(PAGE).length).toEqual(0);
33
45
  });
34
46
  it('should return an error for each required component', function () {
35
47
  var COMPONENTS = [setup('a', _models.ComponentTypes.TEXT, 'Alpha', true), setup('b', _models.ComponentTypes.TEXT, 'Bravo', true), setup('c', _models.ComponentTypes.TEXT, 'Charlie', false), // The only unrequired one
36
48
  setup('d', _models.ComponentTypes.TEXT, 'Delta', true), setup('e', _models.ComponentTypes.TEXT, 'Echo', true)];
37
- var RESULT = (0, _validatePage.default)(COMPONENTS, null);
49
+ var PAGE = {
50
+ components: COMPONENTS,
51
+ formData: null
52
+ };
53
+ var RESULT = (0, _validatePage.default)(PAGE);
38
54
  expect(RESULT.length).toEqual(4);
39
55
  expect(RESULT[0]).toEqual({
40
56
  id: 'a',
@@ -61,19 +77,35 @@ describe('utils', function () {
61
77
  };
62
78
  it('should return no errors when none of the components are required or email types', function () {
63
79
  var COMPONENTS = [setup('alpha', _models.ComponentTypes.TEXT, 'Alpha', false), setup('bravo', _models.ComponentTypes.TEXT, 'Bravo', false)];
64
- expect((0, _validatePage.default)(COMPONENTS, DATA).length).toEqual(0);
80
+ var PAGE = {
81
+ components: COMPONENTS,
82
+ formData: DATA
83
+ };
84
+ expect((0, _validatePage.default)(PAGE).length).toEqual(0);
65
85
  });
66
86
  it('should return no errors when all of the components are required but not email types', function () {
67
87
  var COMPONENTS = [setup('alpha', _models.ComponentTypes.TEXT, 'Alpha', true), setup('bravo', _models.ComponentTypes.TEXT, 'Bravo', true)];
68
- expect((0, _validatePage.default)(COMPONENTS, DATA).length).toEqual(0);
88
+ var PAGE = {
89
+ components: COMPONENTS,
90
+ formData: DATA
91
+ };
92
+ expect((0, _validatePage.default)(PAGE).length).toEqual(0);
69
93
  });
70
94
  it('should return no errors when none of the components are required but are all email types', function () {
71
95
  var COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', false), setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo', false)];
72
- expect((0, _validatePage.default)(COMPONENTS, DATA).length).toEqual(0);
96
+ var PAGE = {
97
+ components: COMPONENTS,
98
+ formData: DATA
99
+ };
100
+ expect((0, _validatePage.default)(PAGE).length).toEqual(0);
73
101
  });
74
102
  it('should return no errors when all of the components are required and email types', function () {
75
103
  var COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', true), setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo', true)];
76
- expect((0, _validatePage.default)(COMPONENTS, DATA).length).toEqual(0);
104
+ var PAGE = {
105
+ components: COMPONENTS,
106
+ formData: DATA
107
+ };
108
+ expect((0, _validatePage.default)(PAGE).length).toEqual(0);
77
109
  });
78
110
  });
79
111
  describe('when the form data has one field missing and includes an invalid email', function () {
@@ -83,11 +115,19 @@ describe('utils', function () {
83
115
  };
84
116
  it('should return no errors when none of the components are required or email types', function () {
85
117
  var COMPONENTS = [setup('alpha', _models.ComponentTypes.TEXT, 'Alpha', false), setup('bravo', _models.ComponentTypes.TEXT, 'Bravo', false), setup('charlie', _models.ComponentTypes.TEXT, 'Charlie', false)];
86
- expect((0, _validatePage.default)(COMPONENTS, DATA).length).toEqual(0);
118
+ var PAGE = {
119
+ components: COMPONENTS,
120
+ formData: null
121
+ };
122
+ expect((0, _validatePage.default)(PAGE).length).toEqual(0);
87
123
  });
88
124
  it('should return an error for the missing field when all are required but not email types', function () {
89
125
  var COMPONENTS = [setup('alpha', _models.ComponentTypes.TEXT, 'Alpha', true), setup('bravo', _models.ComponentTypes.TEXT, 'Bravo', true), setup('charlie', _models.ComponentTypes.TEXT, 'Charlie', true)];
90
- var RESULT = (0, _validatePage.default)(COMPONENTS, DATA);
126
+ var PAGE = {
127
+ components: COMPONENTS,
128
+ formData: DATA
129
+ };
130
+ var RESULT = (0, _validatePage.default)(PAGE);
91
131
  expect(RESULT.length).toEqual(1);
92
132
  expect(RESULT[0]).toEqual({
93
133
  id: 'charlie',
@@ -96,7 +136,11 @@ describe('utils', function () {
96
136
  });
97
137
  it('should return an error for the invalid email field when none are required but all email types', function () {
98
138
  var COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', false), setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo', false), setup('charlie', _models.ComponentTypes.EMAIL, 'Charlie', false)];
99
- var RESULT = (0, _validatePage.default)(COMPONENTS, DATA);
139
+ var PAGE = {
140
+ components: COMPONENTS,
141
+ formData: DATA
142
+ };
143
+ var RESULT = (0, _validatePage.default)(PAGE);
100
144
  expect(RESULT.length).toEqual(1);
101
145
  expect(RESULT[0]).toEqual({
102
146
  id: 'bravo',
@@ -105,7 +149,11 @@ describe('utils', function () {
105
149
  });
106
150
  it('should return an error for both invalid fields when all are required and email types', function () {
107
151
  var COMPONENTS = [setup('alpha', _models.ComponentTypes.EMAIL, 'Alpha', true), setup('bravo', _models.ComponentTypes.EMAIL, 'Bravo', true), setup('charlie', _models.ComponentTypes.EMAIL, 'Charlie', true)];
108
- var RESULT = (0, _validatePage.default)(COMPONENTS, DATA);
152
+ var PAGE = {
153
+ components: COMPONENTS,
154
+ formData: DATA
155
+ };
156
+ var RESULT = (0, _validatePage.default)(PAGE);
109
157
  expect(RESULT.length).toEqual(2);
110
158
  expect(RESULT[0]).toEqual({
111
159
  id: 'bravo',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "2.6.2-alpha",
3
+ "version": "2.7.3",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "clean": "rimraf dist",
@@ -16,7 +16,7 @@
16
16
  "post-compile": "rimraf dist/*.test.* dist/**/*.test.* dist/**/*.stories.* dist/docs dist/assets"
17
17
  },
18
18
  "dependencies": {
19
- "@ukhomeoffice/cop-react-components": "1.3.0",
19
+ "@ukhomeoffice/cop-react-components": "1.5.1",
20
20
  "axios": "^0.21.1",
21
21
  "dayjs": "^1.11.0",
22
22
  "govuk-frontend": "^3.13.0",