@ukhomeoffice/cop-react-form-renderer 3.17.0 → 3.17.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.
|
@@ -81,7 +81,7 @@ Task.propTypes = {
|
|
|
81
81
|
task: _propTypes.default.shape({
|
|
82
82
|
name: _propTypes.default.string.isRequired,
|
|
83
83
|
pages: _propTypes.default.array.isRequired,
|
|
84
|
-
state: _propTypes.default.string
|
|
84
|
+
state: _propTypes.default.string
|
|
85
85
|
}).isRequired,
|
|
86
86
|
onClick: _propTypes.default.func.isRequired
|
|
87
87
|
};
|
|
@@ -100,7 +100,7 @@ TaskList.propTypes = {
|
|
|
100
100
|
tasks: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
101
101
|
name: _propTypes.default.string.isRequired,
|
|
102
102
|
pages: _propTypes.default.array.isRequired,
|
|
103
|
-
state: _propTypes.default.string
|
|
103
|
+
state: _propTypes.default.string
|
|
104
104
|
})).isRequired
|
|
105
105
|
})).isRequired,
|
|
106
106
|
classBlock: _propTypes.default.string,
|
|
@@ -25,18 +25,18 @@ var TaskState = function TaskState(_ref) {
|
|
|
25
25
|
|
|
26
26
|
var classes = _copReactComponents.Utils.classBuilder(DEFAULT_CLASS, undefined, undefined);
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
|
|
28
|
+
var details = _models.TaskStates.DETAILS[state] || _models.TaskStates.DETAILS.cannotStartYet;
|
|
32
29
|
return /*#__PURE__*/_react.default.createElement(_copReactComponents.Tag, {
|
|
33
|
-
classModifiers:
|
|
30
|
+
classModifiers: details.colour,
|
|
34
31
|
className: classes('tag')
|
|
35
|
-
},
|
|
32
|
+
}, details.label);
|
|
36
33
|
};
|
|
37
34
|
|
|
38
35
|
TaskState.propTypes = {
|
|
39
|
-
state: _propTypes.default.string
|
|
36
|
+
state: _propTypes.default.string
|
|
37
|
+
};
|
|
38
|
+
TaskState.defaultProps = {
|
|
39
|
+
state: _models.TaskStates.TYPES.CANNOT_START_YET
|
|
40
40
|
};
|
|
41
41
|
var _default = TaskState;
|
|
42
42
|
exports.default = _default;
|
|
@@ -14,6 +14,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
14
14
|
// Local imports
|
|
15
15
|
describe('components', function () {
|
|
16
16
|
describe('TaskList.TaskState', function () {
|
|
17
|
+
var checkIsCannotStartYet = function checkIsCannotStartYet(container) {
|
|
18
|
+
expect(container.childNodes.length).toEqual(1);
|
|
19
|
+
expect(container.childNodes[0].classList).toContain('hods-tag');
|
|
20
|
+
expect(container.childNodes[0].classList).toContain("hods-tag--".concat(_models.TaskStates.DETAILS.cannotStartYet.colour));
|
|
21
|
+
expect(container.childNodes[0].textContent).toEqual(_models.TaskStates.DETAILS.cannotStartYet.label);
|
|
22
|
+
return true;
|
|
23
|
+
};
|
|
24
|
+
|
|
17
25
|
it('should render a complete state icon', function () {
|
|
18
26
|
var STATE = _models.TaskStates.TYPES.COMPLETE;
|
|
19
27
|
|
|
@@ -60,12 +68,9 @@ describe('components', function () {
|
|
|
60
68
|
})),
|
|
61
69
|
container = _render4.container;
|
|
62
70
|
|
|
63
|
-
expect(container
|
|
64
|
-
expect(container.childNodes[0].classList).toContain('hods-tag');
|
|
65
|
-
expect(container.childNodes[0].classList).toContain("hods-tag--".concat(_models.TaskStates.DETAILS.cannotStartYet.colour));
|
|
66
|
-
expect(container.childNodes[0].textContent).toEqual(_models.TaskStates.DETAILS.cannotStartYet.label);
|
|
71
|
+
expect(checkIsCannotStartYet(container)).toBeTruthy();
|
|
67
72
|
});
|
|
68
|
-
it('should
|
|
73
|
+
it('should render the "Cannot start yet" state if given an unknown value', function () {
|
|
69
74
|
var STATE = 'spellingError';
|
|
70
75
|
|
|
71
76
|
var _render5 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskState.default, {
|
|
@@ -73,9 +78,9 @@ describe('components', function () {
|
|
|
73
78
|
})),
|
|
74
79
|
container = _render5.container;
|
|
75
80
|
|
|
76
|
-
expect(container
|
|
81
|
+
expect(checkIsCannotStartYet(container)).toBeTruthy();
|
|
77
82
|
});
|
|
78
|
-
it('should
|
|
83
|
+
it('should render the "Cannot start yet" state if given null', function () {
|
|
79
84
|
var STATE = null;
|
|
80
85
|
|
|
81
86
|
var _render6 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskState.default, {
|
|
@@ -83,9 +88,9 @@ describe('components', function () {
|
|
|
83
88
|
})),
|
|
84
89
|
container = _render6.container;
|
|
85
90
|
|
|
86
|
-
expect(container
|
|
91
|
+
expect(checkIsCannotStartYet(container)).toBeTruthy();
|
|
87
92
|
});
|
|
88
|
-
it('should
|
|
93
|
+
it('should render the "Cannot start yet" state if given undefined', function () {
|
|
89
94
|
var STATE = undefined;
|
|
90
95
|
|
|
91
96
|
var _render7 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_TaskState.default, {
|
|
@@ -93,7 +98,7 @@ describe('components', function () {
|
|
|
93
98
|
})),
|
|
94
99
|
container = _render7.container;
|
|
95
100
|
|
|
96
|
-
expect(container
|
|
101
|
+
expect(checkIsCannotStartYet(container)).toBeTruthy();
|
|
97
102
|
});
|
|
98
103
|
});
|
|
99
104
|
});
|