@ukhomeoffice/cop-react-form-renderer 2.8.5 → 2.9.1

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.
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+
3
+ var _models = require("../../models");
4
+
5
+ var _validateContainer = _interopRequireDefault(require("./validateContainer"));
6
+
7
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
+
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
+
11
+ describe('utils.Validate.Container', function () {
12
+ var setup = function setup(id, type, label, required, additionalValidation) {
13
+ return {
14
+ id: id,
15
+ fieldId: id,
16
+ type: type,
17
+ label: label,
18
+ required: required,
19
+ additionalValidation: additionalValidation
20
+ };
21
+ };
22
+
23
+ it('should return an empty array when the component is null', function () {
24
+ expect((0, _validateContainer.default)(null, {})).toEqual([]);
25
+ });
26
+ it('should return an empty array when the container has an undefined components array', function () {
27
+ var ID = 'container';
28
+ var LABEL = 'field';
29
+ var CONTAINER = setup(ID, _models.ComponentTypes.CONTAINER, LABEL, false);
30
+ expect((0, _validateContainer.default)(CONTAINER, null)).toEqual([]);
31
+ });
32
+ it('should return an empty array when the container has no components', function () {
33
+ var ID = 'container';
34
+ var LABEL = 'field';
35
+ var CONTAINER = setup(ID, _models.ComponentTypes.CONTAINER, LABEL, false);
36
+ CONTAINER.components = [];
37
+ expect((0, _validateContainer.default)(CONTAINER, null)).toEqual([]);
38
+ });
39
+ it('should return an empty array when the container has only valid components', function () {
40
+ var EMAIL_ID = 'email';
41
+ var EMAIL_LABEL = 'Email';
42
+ var EMAIL = setup(EMAIL_ID, _models.ComponentTypes.EMAIL, EMAIL_LABEL, false);
43
+ var ID = 'container';
44
+ var LABEL = 'field';
45
+ var CONTAINER = setup(ID, _models.ComponentTypes.CONTAINER, LABEL, false);
46
+ CONTAINER.components = [EMAIL];
47
+
48
+ var DATA = _defineProperty({}, ID, _defineProperty({}, EMAIL_ID, 'alpha.bravo@digital.homeoffice.gov.uk'));
49
+
50
+ expect((0, _validateContainer.default)(CONTAINER, DATA)).toEqual([]);
51
+ });
52
+ it('should return an array containing an error when the container has an invalid component', function () {
53
+ var EMAIL_ID = 'email';
54
+ var EMAIL_LABEL = 'Email';
55
+ var EMAIL = setup(EMAIL_ID, _models.ComponentTypes.EMAIL, EMAIL_LABEL, false);
56
+ var ID = 'container';
57
+ var LABEL = 'field';
58
+ var CONTAINER = setup(ID, _models.ComponentTypes.CONTAINER, LABEL, false);
59
+ CONTAINER.components = [EMAIL];
60
+
61
+ var DATA = _defineProperty({}, ID, _defineProperty({}, EMAIL_ID, 'alpha.bravo@digital.homeoffice.com'));
62
+
63
+ expect((0, _validateContainer.default)(CONTAINER, DATA)).toEqual([{
64
+ id: EMAIL_ID,
65
+ error: "Enter ".concat(EMAIL_LABEL.toLowerCase(), " in the correct format, like jane.doe@homeoffice.gov.uk")
66
+ }]);
67
+ });
68
+ });
@@ -23,6 +23,8 @@ var _FormPage = _interopRequireDefault(require("./FormPage"));
23
23
 
24
24
  var _Hub = _interopRequireDefault(require("./Hub"));
25
25
 
26
+ var _Meta = _interopRequireDefault(require("./Meta"));
27
+
26
28
  var _Validate = _interopRequireDefault(require("./Validate"));
27
29
 
28
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -36,12 +38,13 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
36
38
  var Utils = _objectSpread({
37
39
  CheckYourAnswers: _CheckYourAnswers.default,
38
40
  Component: _Component.default,
41
+ Condition: _Condition.default,
39
42
  Container: _Container.default,
40
43
  Data: _Data.default,
41
44
  Format: _Format.default,
42
45
  FormPage: _FormPage.default,
43
46
  Hub: _Hub.default,
44
- Condition: _Condition.default,
47
+ Meta: _Meta.default,
45
48
  Validate: _Validate.default
46
49
  }, _copReactComponents.Utils);
47
50
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/cop-react-form-renderer",
3
- "version": "2.8.5",
3
+ "version": "2.9.1",
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.5.1",
19
+ "@ukhomeoffice/cop-react-components": "1.6.0",
20
20
  "axios": "^0.21.1",
21
21
  "dayjs": "^1.11.0",
22
22
  "govuk-frontend": "^3.13.0",