orc-shared 1.3.0-dev.9 → 1.4.0-dev.2
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/MaterialUI/DataDisplay/PredefinedElements/InformationItem.js +8 -4
- package/dist/components/MaterialUI/Inputs/DatePicker.js +5 -3
- package/dist/components/MaterialUI/Inputs/InputBase.js +5 -1
- package/dist/components/MaterialUI/Inputs/InputBaseProps.js +4 -1
- package/package.json +3 -3
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.js +9 -3
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.test.js +121 -0
- package/src/components/MaterialUI/Inputs/DatePicker.js +3 -2
- package/src/components/MaterialUI/Inputs/DatePicker.test.js +28 -0
- package/src/components/MaterialUI/Inputs/InputBase.js +6 -1
- package/src/components/MaterialUI/Inputs/InputBase.test.js +39 -0
- package/src/components/MaterialUI/Inputs/InputBaseProps.js +2 -0
- package/src/components/MaterialUI/Inputs/InputBaseProps.test.js +2 -0
- package/src/utils/timezoneHelper.test.js +4 -4
|
@@ -94,7 +94,9 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
|
|
|
94
94
|
var InformationItemChildren = function InformationItemChildren(_ref) {
|
|
95
95
|
var classes = _ref.classes,
|
|
96
96
|
children = _ref.children,
|
|
97
|
-
showNotAvailable = _ref.showNotAvailable
|
|
97
|
+
showNotAvailable = _ref.showNotAvailable,
|
|
98
|
+
_ref$isMaxLineCountEn = _ref.isMaxLineCountEnabled,
|
|
99
|
+
isMaxLineCountEnabled = _ref$isMaxLineCountEn === void 0 ? true : _ref$isMaxLineCountEn;
|
|
98
100
|
|
|
99
101
|
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
100
102
|
formatMessage = _useIntl.formatMessage;
|
|
@@ -104,7 +106,7 @@ var InformationItemChildren = function InformationItemChildren(_ref) {
|
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
var multipleLinesTextProps = new _textProps.default();
|
|
107
|
-
multipleLinesTextProps.set(_textProps.default.propNames.lineCount, 2);
|
|
109
|
+
if (isMaxLineCountEnabled) multipleLinesTextProps.set(_textProps.default.propNames.lineCount, 2);
|
|
108
110
|
multipleLinesTextProps.set(_textProps.default.propNames.classes, classes.value);
|
|
109
111
|
var value = children != null ? children : showNotAvailable ? formatMessage(_sharedMessages.default.notAvailable) : "";
|
|
110
112
|
return /*#__PURE__*/_react.default.createElement(_MultipleLinesText.default, {
|
|
@@ -156,7 +158,8 @@ var InformationItem = function InformationItem(_ref4) {
|
|
|
156
158
|
_ref4$showNotAvailabl = _ref4.showNotAvailable,
|
|
157
159
|
showNotAvailable = _ref4$showNotAvailabl === void 0 ? false : _ref4$showNotAvailabl,
|
|
158
160
|
_ref4$marginTop = _ref4.marginTop,
|
|
159
|
-
marginTop = _ref4$marginTop === void 0 ? 0 : _ref4$marginTop
|
|
161
|
+
marginTop = _ref4$marginTop === void 0 ? 0 : _ref4$marginTop,
|
|
162
|
+
isMaxLineCountEnabled = _ref4.isMaxLineCountEnabled;
|
|
160
163
|
var classes = useStyles({
|
|
161
164
|
required: required,
|
|
162
165
|
error: error,
|
|
@@ -171,7 +174,8 @@ var InformationItem = function InformationItem(_ref4) {
|
|
|
171
174
|
}), /*#__PURE__*/_react.default.createElement(InformationItemChildren, {
|
|
172
175
|
classes: classes,
|
|
173
176
|
children: children,
|
|
174
|
-
showNotAvailable: showNotAvailable
|
|
177
|
+
showNotAvailable: showNotAvailable,
|
|
178
|
+
isMaxLineCountEnabled: isMaxLineCountEnabled
|
|
175
179
|
}));
|
|
176
180
|
};
|
|
177
181
|
|
|
@@ -23,7 +23,7 @@ var _metadata = require("../../../selectors/metadata");
|
|
|
23
23
|
|
|
24
24
|
var _reactRedux = require("react-redux");
|
|
25
25
|
|
|
26
|
-
var _excluded = ["value", "useTime", "useDate", "onChange", "dateFormat", "showTimeZone", "timeInputLabel", "readOnly", "showTimeSelectOnly", "metadata", "timePickerTimeZone", "error"];
|
|
26
|
+
var _excluded = ["value", "useTime", "useDate", "onChange", "useTimeZone", "dateFormat", "showTimeZone", "timeInputLabel", "readOnly", "showTimeSelectOnly", "metadata", "timePickerTimeZone", "error"];
|
|
27
27
|
|
|
28
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
29
|
|
|
@@ -178,6 +178,8 @@ var WrappedDatePicker = function WrappedDatePicker(_ref) {
|
|
|
178
178
|
_ref$useDate = _ref.useDate,
|
|
179
179
|
useDate = _ref$useDate === void 0 ? true : _ref$useDate,
|
|
180
180
|
onChange = _ref.onChange,
|
|
181
|
+
_ref$useTimeZone = _ref.useTimeZone,
|
|
182
|
+
useTimeZone = _ref$useTimeZone === void 0 ? false : _ref$useTimeZone,
|
|
181
183
|
dateFormat = _ref.dateFormat,
|
|
182
184
|
showTimeZone = _ref.showTimeZone,
|
|
183
185
|
timeInputLabel = _ref.timeInputLabel,
|
|
@@ -192,13 +194,13 @@ var WrappedDatePicker = function WrappedDatePicker(_ref) {
|
|
|
192
194
|
readOnly: readOnly
|
|
193
195
|
});
|
|
194
196
|
var timeZoneName = (0, _timezoneHelper.getTimeZoneByName)(timePickerTimeZone);
|
|
195
|
-
var startDate = value ? timePickerTimeZone ? (0, _timezoneHelper.convertTimeToLocalTimeZone)(new Date(value), timeZoneName) : new Date(value) : null;
|
|
197
|
+
var startDate = value ? timePickerTimeZone && useTimeZone ? (0, _timezoneHelper.convertTimeToLocalTimeZone)(new Date(value), timeZoneName) : new Date(value) : null;
|
|
196
198
|
var disabledCls = (0, _classnames.default)(_defineProperty({}, classes.disabled, props.disabled));
|
|
197
199
|
var localizedTimeZoneName = (0, _reactRedux.useSelector)((0, _metadata.namedLookupLocalizedSelector)("customer", "TimeZone", timePickerTimeZone));
|
|
198
200
|
|
|
199
201
|
var updateDate = function updateDate(date, metadata) {
|
|
200
202
|
if (onChange) {
|
|
201
|
-
onChange(
|
|
203
|
+
onChange(useTimeZone && timePickerTimeZone ? (0, _timezoneHelper.convertTimeToOtherTimeZone)(date, timeZoneName) : date, metadata);
|
|
202
204
|
}
|
|
203
205
|
};
|
|
204
206
|
|
|
@@ -157,6 +157,10 @@ var InputBase = function InputBase(_ref) {
|
|
|
157
157
|
var metadata = inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.metadata);
|
|
158
158
|
var autoComplete = inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.autoComplete);
|
|
159
159
|
var timeoutDelay = (inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.timeoutDelay)) || 100;
|
|
160
|
+
var rowsProps = inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.rows);
|
|
161
|
+
var defaultRows = 4;
|
|
162
|
+
var rows = rowsProps;
|
|
163
|
+
if (rows === null || rows === undefined) rows = defaultRows;
|
|
160
164
|
var tooltipText = type === "text" ? value : "";
|
|
161
165
|
|
|
162
166
|
var onClick = function onClick(item) {
|
|
@@ -233,7 +237,7 @@ var InputBase = function InputBase(_ref) {
|
|
|
233
237
|
multiline: multiline,
|
|
234
238
|
startAdornment: startAdornment,
|
|
235
239
|
endAdornment: endAdornment,
|
|
236
|
-
rows:
|
|
240
|
+
rows: rows,
|
|
237
241
|
title: tooltipText,
|
|
238
242
|
autoComplete: autoComplete
|
|
239
243
|
})), error && /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -71,6 +71,8 @@ var InputBaseProps = /*#__PURE__*/function (_ComponentProps) {
|
|
|
71
71
|
|
|
72
72
|
_this.componentProps.set(_this.constructor.propNames.timeoutDelay, null);
|
|
73
73
|
|
|
74
|
+
_this.componentProps.set(_this.constructor.propNames.rows, null);
|
|
75
|
+
|
|
74
76
|
_this.componentClasses.set(_this.constructor.ruleNames.input, null);
|
|
75
77
|
|
|
76
78
|
_this.componentClasses.set(_this.constructor.ruleNames.errorText, null);
|
|
@@ -106,7 +108,8 @@ _defineProperty(InputBaseProps, "propNames", {
|
|
|
106
108
|
endAdornment: "endAdornment",
|
|
107
109
|
metadata: "metadata",
|
|
108
110
|
autoComplete: "autoComplete",
|
|
109
|
-
timeoutDelay: "timeoutDelay"
|
|
111
|
+
timeoutDelay: "timeoutDelay",
|
|
112
|
+
rows: "rows"
|
|
110
113
|
});
|
|
111
114
|
|
|
112
115
|
_defineProperty(InputBaseProps, "ruleNames", {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orc-shared",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0-dev.2",
|
|
4
4
|
"description": "Shared code for Orckestra applications",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
],
|
|
50
50
|
"devDependencies": {},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"orc-scripts": "1.
|
|
52
|
+
"orc-scripts": "1.5.0-dev.1"
|
|
53
53
|
},
|
|
54
54
|
"sideEffects": false,
|
|
55
55
|
"lint-staged": {
|
|
@@ -69,6 +69,6 @@
|
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"orc-scripts": "1.
|
|
72
|
+
"orc-scripts": "1.5.0-dev.1"
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -53,7 +53,7 @@ const useStyles = makeStyles(theme => ({
|
|
|
53
53
|
},
|
|
54
54
|
}));
|
|
55
55
|
|
|
56
|
-
const InformationItemChildren = ({ classes, children, showNotAvailable }) => {
|
|
56
|
+
const InformationItemChildren = ({ classes, children, showNotAvailable, isMaxLineCountEnabled = true }) => {
|
|
57
57
|
const { formatMessage } = useIntl();
|
|
58
58
|
|
|
59
59
|
if (isReactComponent(children)) {
|
|
@@ -61,7 +61,7 @@ const InformationItemChildren = ({ classes, children, showNotAvailable }) => {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
const multipleLinesTextProps = new TextProps();
|
|
64
|
-
multipleLinesTextProps.set(TextProps.propNames.lineCount, 2);
|
|
64
|
+
if (isMaxLineCountEnabled) multipleLinesTextProps.set(TextProps.propNames.lineCount, 2);
|
|
65
65
|
multipleLinesTextProps.set(TextProps.propNames.classes, classes.value);
|
|
66
66
|
|
|
67
67
|
const value = children ?? (showNotAvailable ? formatMessage(sharedMessages.notAvailable) : "");
|
|
@@ -93,13 +93,19 @@ const InformationItem = ({
|
|
|
93
93
|
headerIcon = undefined,
|
|
94
94
|
showNotAvailable = false,
|
|
95
95
|
marginTop = 0,
|
|
96
|
+
isMaxLineCountEnabled,
|
|
96
97
|
}) => {
|
|
97
98
|
const classes = useStyles({ required, error, marginTop });
|
|
98
99
|
|
|
99
100
|
return (
|
|
100
101
|
<div className={classes.container}>
|
|
101
102
|
<InformationItemHeader classes={classes} label={label} headerIcon={headerIcon} />
|
|
102
|
-
<InformationItemChildren
|
|
103
|
+
<InformationItemChildren
|
|
104
|
+
classes={classes}
|
|
105
|
+
children={children}
|
|
106
|
+
showNotAvailable={showNotAvailable}
|
|
107
|
+
isMaxLineCountEnabled={isMaxLineCountEnabled}
|
|
108
|
+
/>
|
|
103
109
|
</div>
|
|
104
110
|
);
|
|
105
111
|
};
|
|
@@ -7,6 +7,7 @@ import MultipleLinesText from "../TooltippedElements/MultipleLinesText";
|
|
|
7
7
|
import { stringifyWithoutQuotes } from "./../../../../utils/parseHelper";
|
|
8
8
|
import sharedMessages from "./../../../../sharedMessages";
|
|
9
9
|
import { extractMessages } from "./../../../../utils/testUtils";
|
|
10
|
+
import TextProps from "../../textProps";
|
|
10
11
|
|
|
11
12
|
const messages = extractMessages(sharedMessages);
|
|
12
13
|
|
|
@@ -51,6 +52,126 @@ describe("Information Item", () => {
|
|
|
51
52
|
expect(component, "when mounted", "to satisfy", expected);
|
|
52
53
|
});
|
|
53
54
|
|
|
55
|
+
it("Renders Information Item with max line count", () => {
|
|
56
|
+
const label = "label";
|
|
57
|
+
const value = "value";
|
|
58
|
+
|
|
59
|
+
const multipleLinesTextProps = new TextProps();
|
|
60
|
+
multipleLinesTextProps.set(TextProps.propNames.lineCount, 2);
|
|
61
|
+
|
|
62
|
+
const component = (
|
|
63
|
+
<IntlProvider locale="en-US">
|
|
64
|
+
<InformationItem label={label} isMaxLineCountEnabled={true}>
|
|
65
|
+
{value}
|
|
66
|
+
</InformationItem>
|
|
67
|
+
</IntlProvider>
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
const expected = (
|
|
71
|
+
<div>
|
|
72
|
+
<Typography children={label} />
|
|
73
|
+
<MultipleLinesText textProps={multipleLinesTextProps}>{value}</MultipleLinesText>
|
|
74
|
+
</div>
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
expect(component, "when mounted", "to satisfy", expected);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("Renders Information Item without max line count", () => {
|
|
81
|
+
const label = "label";
|
|
82
|
+
const value = "value";
|
|
83
|
+
|
|
84
|
+
const multipleLinesTextProps = new TextProps();
|
|
85
|
+
multipleLinesTextProps.set(TextProps.propNames.lineCount, 2);
|
|
86
|
+
|
|
87
|
+
const component = (
|
|
88
|
+
<IntlProvider locale="en-US">
|
|
89
|
+
<InformationItem label={label}>{value}</InformationItem>
|
|
90
|
+
</IntlProvider>
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const expected = (
|
|
94
|
+
<div>
|
|
95
|
+
<Typography children={label} />
|
|
96
|
+
<MultipleLinesText textProps={multipleLinesTextProps}>{value}</MultipleLinesText>
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
expect(component, "when mounted", "to satisfy", expected);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("Renders Information Item with max line count false", () => {
|
|
104
|
+
const label = "label";
|
|
105
|
+
const value = "value";
|
|
106
|
+
|
|
107
|
+
const component = (
|
|
108
|
+
<IntlProvider locale="en-US">
|
|
109
|
+
<InformationItem label={label} isMaxLineCountEnabled={false}>
|
|
110
|
+
{value}
|
|
111
|
+
</InformationItem>
|
|
112
|
+
</IntlProvider>
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
const expected = (
|
|
116
|
+
<div>
|
|
117
|
+
<Typography children={label} />
|
|
118
|
+
<MultipleLinesText>{value}</MultipleLinesText>
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
expect(component, "when mounted", "to satisfy", expected);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("Renders Information Item with null max line count", () => {
|
|
126
|
+
const label = "label";
|
|
127
|
+
const value = "value";
|
|
128
|
+
|
|
129
|
+
const multipleLinesTextProps = new TextProps();
|
|
130
|
+
multipleLinesTextProps.set(TextProps.propNames.lineCount, 2);
|
|
131
|
+
|
|
132
|
+
const component = (
|
|
133
|
+
<IntlProvider locale="en-US">
|
|
134
|
+
<InformationItem label={label} isMaxLineCountEnabled={null}>
|
|
135
|
+
{value}
|
|
136
|
+
</InformationItem>
|
|
137
|
+
</IntlProvider>
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
const expected = (
|
|
141
|
+
<div>
|
|
142
|
+
<Typography children={label} />
|
|
143
|
+
<MultipleLinesText textProps={multipleLinesTextProps}>{value}</MultipleLinesText>
|
|
144
|
+
</div>
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
expect(component, "when mounted", "to satisfy", expected);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it("Renders Information Item with undefined max line count", () => {
|
|
151
|
+
const label = "label";
|
|
152
|
+
const value = "value";
|
|
153
|
+
|
|
154
|
+
const multipleLinesTextProps = new TextProps();
|
|
155
|
+
multipleLinesTextProps.set(TextProps.propNames.lineCount, 2);
|
|
156
|
+
|
|
157
|
+
const component = (
|
|
158
|
+
<IntlProvider locale="en-US">
|
|
159
|
+
<InformationItem label={label} isMaxLineCountEnabled={undefined}>
|
|
160
|
+
{value}
|
|
161
|
+
</InformationItem>
|
|
162
|
+
</IntlProvider>
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
const expected = (
|
|
166
|
+
<div>
|
|
167
|
+
<Typography children={label} />
|
|
168
|
+
<MultipleLinesText textProps={multipleLinesTextProps}>{value}</MultipleLinesText>
|
|
169
|
+
</div>
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
expect(component, "when mounted", "to satisfy", expected);
|
|
173
|
+
});
|
|
174
|
+
|
|
54
175
|
it("Renders Information Item with null value and showNotAvailable property is true", () => {
|
|
55
176
|
const label = "label";
|
|
56
177
|
const value = null;
|
|
@@ -127,6 +127,7 @@ const WrappedDatePicker = ({
|
|
|
127
127
|
useTime,
|
|
128
128
|
useDate = true,
|
|
129
129
|
onChange,
|
|
130
|
+
useTimeZone = false,
|
|
130
131
|
dateFormat,
|
|
131
132
|
showTimeZone,
|
|
132
133
|
timeInputLabel,
|
|
@@ -140,7 +141,7 @@ const WrappedDatePicker = ({
|
|
|
140
141
|
const classes = useStyles({ readOnly });
|
|
141
142
|
const timeZoneName = getTimeZoneByName(timePickerTimeZone);
|
|
142
143
|
const startDate = value
|
|
143
|
-
? timePickerTimeZone
|
|
144
|
+
? timePickerTimeZone && useTimeZone
|
|
144
145
|
? convertTimeToLocalTimeZone(new Date(value), timeZoneName)
|
|
145
146
|
: new Date(value)
|
|
146
147
|
: null;
|
|
@@ -149,7 +150,7 @@ const WrappedDatePicker = ({
|
|
|
149
150
|
|
|
150
151
|
const updateDate = (date, metadata) => {
|
|
151
152
|
if (onChange) {
|
|
152
|
-
onChange(
|
|
153
|
+
onChange(useTimeZone && timePickerTimeZone ? convertTimeToOtherTimeZone(date, timeZoneName) : date, metadata);
|
|
153
154
|
}
|
|
154
155
|
};
|
|
155
156
|
|
|
@@ -425,6 +425,34 @@ describe("DatePicker", () => {
|
|
|
425
425
|
const input = mountedComponent.find("input");
|
|
426
426
|
input.at(0).simulate("change", event);
|
|
427
427
|
});
|
|
428
|
+
|
|
429
|
+
it("should call onChange prop with useTimeZone", () => {
|
|
430
|
+
const onChangeMock = jest.fn();
|
|
431
|
+
const date = new Date("2020-06-30T00:00:00");
|
|
432
|
+
const event = {
|
|
433
|
+
preventDefault() {},
|
|
434
|
+
target: { value: "" },
|
|
435
|
+
};
|
|
436
|
+
const requestTimeZone = "Eastern Standard Time";
|
|
437
|
+
const component = (
|
|
438
|
+
<TestWrapper provider={{ store }} intlProvider>
|
|
439
|
+
<DatePicker
|
|
440
|
+
onChange={onChangeMock}
|
|
441
|
+
value={date}
|
|
442
|
+
useTime={true}
|
|
443
|
+
useDate={false}
|
|
444
|
+
useTimeZone={true}
|
|
445
|
+
showTimeSelectOnly={true}
|
|
446
|
+
timePickerTimeZone={requestTimeZone}
|
|
447
|
+
/>
|
|
448
|
+
</TestWrapper>
|
|
449
|
+
);
|
|
450
|
+
const mountedComponent = mount(component);
|
|
451
|
+
|
|
452
|
+
const input = mountedComponent.find("input");
|
|
453
|
+
input.at(0).simulate("change", event);
|
|
454
|
+
expect(onChangeMock.mock.calls.length, "to equal", 1);
|
|
455
|
+
});
|
|
428
456
|
});
|
|
429
457
|
|
|
430
458
|
describe("createFormat", () => {
|
|
@@ -100,6 +100,11 @@ const InputBase = ({ inputProps }) => {
|
|
|
100
100
|
const metadata = inputProps?.get(InputBaseProps.propNames.metadata);
|
|
101
101
|
const autoComplete = inputProps?.get(InputBaseProps.propNames.autoComplete);
|
|
102
102
|
const timeoutDelay = inputProps?.get(InputBaseProps.propNames.timeoutDelay) || 100;
|
|
103
|
+
const rowsProps = inputProps?.get(InputBaseProps.propNames.rows);
|
|
104
|
+
|
|
105
|
+
const defaultRows = 4;
|
|
106
|
+
let rows = rowsProps;
|
|
107
|
+
if (rows === null || rows === undefined) rows = defaultRows;
|
|
103
108
|
|
|
104
109
|
const tooltipText = type === "text" ? value : "";
|
|
105
110
|
|
|
@@ -165,7 +170,7 @@ const InputBase = ({ inputProps }) => {
|
|
|
165
170
|
multiline={multiline}
|
|
166
171
|
startAdornment={startAdornment}
|
|
167
172
|
endAdornment={endAdornment}
|
|
168
|
-
rows={
|
|
173
|
+
rows={rows}
|
|
169
174
|
title={tooltipText}
|
|
170
175
|
autoComplete={autoComplete}
|
|
171
176
|
/>
|
|
@@ -57,6 +57,45 @@ describe("InputBase Component", () => {
|
|
|
57
57
|
expect(mountedComponent.prop("inputProps").get(InputBaseProps.propNames.value), "to equal", aValue + aValue);
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
+
it("Renders multiline InputBase component with default number of rows", () => {
|
|
61
|
+
const inputProps = new InputBaseProps();
|
|
62
|
+
const aLabel = "aLabel";
|
|
63
|
+
const aValue = "value";
|
|
64
|
+
const defaultRows = 4;
|
|
65
|
+
|
|
66
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
67
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
68
|
+
inputProps.set(InputBaseProps.propNames.type, "text");
|
|
69
|
+
inputProps.set(InputBaseProps.propNames.multiline, true);
|
|
70
|
+
|
|
71
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
72
|
+
|
|
73
|
+
const mountedComponent = mount(component);
|
|
74
|
+
const expected = <InputBaseMUI value={aValue} title={aValue} rows={defaultRows} />;
|
|
75
|
+
|
|
76
|
+
expect(mountedComponent.containsMatchingElement(expected), "to be truthy");
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("Renders multiline InputBase component with desired number of rows", () => {
|
|
80
|
+
const inputProps = new InputBaseProps();
|
|
81
|
+
const aLabel = "aLabel";
|
|
82
|
+
const aValue = "value";
|
|
83
|
+
const desiredNumberOfRows = 20;
|
|
84
|
+
|
|
85
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
86
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
87
|
+
inputProps.set(InputBaseProps.propNames.type, "text");
|
|
88
|
+
inputProps.set(InputBaseProps.propNames.multiline, true);
|
|
89
|
+
inputProps.set(InputBaseProps.propNames.rows, desiredNumberOfRows);
|
|
90
|
+
|
|
91
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
92
|
+
|
|
93
|
+
const mountedComponent = mount(component);
|
|
94
|
+
const expected = <InputBaseMUI value={aValue} title={aValue} rows={desiredNumberOfRows} />;
|
|
95
|
+
|
|
96
|
+
expect(mountedComponent.containsMatchingElement(expected), "to be truthy");
|
|
97
|
+
});
|
|
98
|
+
|
|
60
99
|
it("Renders InputBase component with title attribute for input of type text", () => {
|
|
61
100
|
const inputProps = new InputBaseProps();
|
|
62
101
|
const aLabel = "aLabel";
|
|
@@ -18,6 +18,7 @@ class InputBaseProps extends ComponentProps {
|
|
|
18
18
|
metadata: "metadata",
|
|
19
19
|
autoComplete: "autoComplete",
|
|
20
20
|
timeoutDelay: "timeoutDelay",
|
|
21
|
+
rows: "rows",
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
static ruleNames = {
|
|
@@ -43,6 +44,7 @@ class InputBaseProps extends ComponentProps {
|
|
|
43
44
|
this.componentProps.set(this.constructor.propNames.metadata, null);
|
|
44
45
|
this.componentProps.set(this.constructor.propNames.autoComplete, null);
|
|
45
46
|
this.componentProps.set(this.constructor.propNames.timeoutDelay, null);
|
|
47
|
+
this.componentProps.set(this.constructor.propNames.rows, null);
|
|
46
48
|
|
|
47
49
|
this.componentClasses.set(this.constructor.ruleNames.input, null);
|
|
48
50
|
this.componentClasses.set(this.constructor.ruleNames.errorText, null);
|
|
@@ -19,6 +19,7 @@ describe("InputBase Props", () => {
|
|
|
19
19
|
"metadata",
|
|
20
20
|
"autoComplete",
|
|
21
21
|
"timeoutDelay",
|
|
22
|
+
"rows",
|
|
22
23
|
];
|
|
23
24
|
|
|
24
25
|
expect(InputBaseProps.propNames, "to have keys", propNames);
|
|
@@ -42,6 +43,7 @@ describe("InputBase Props", () => {
|
|
|
42
43
|
"metadata",
|
|
43
44
|
"autoComplete",
|
|
44
45
|
"timeoutDelay",
|
|
46
|
+
"rows",
|
|
45
47
|
];
|
|
46
48
|
|
|
47
49
|
const ruleNames = ["input", "errorText"];
|
|
@@ -39,15 +39,15 @@ describe("Timezone Helper", () => {
|
|
|
39
39
|
|
|
40
40
|
it("Retrieves user local timezone date", () => {
|
|
41
41
|
const timezoneName = "America/New_York";
|
|
42
|
-
const date = "Mon Apr 04 2022 13:00:00
|
|
43
|
-
const expectedDate = new Date("2022-04-04T09:00:
|
|
42
|
+
const date = "Mon Apr 04 2022 13:00:00.000Z";
|
|
43
|
+
const expectedDate = new Date("2022-04-04T09:00:00.000Z");
|
|
44
44
|
expect(convertTimeToLocalTimeZone, "called with", [date, timezoneName], "to satisfy", expectedDate);
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
it("Retrieves user other timezone date", () => {
|
|
48
48
|
const timezoneName = "America/New_York";
|
|
49
|
-
const date = "Mon Apr 04 2022
|
|
50
|
-
const expectedDate = new Date("2022-04-
|
|
49
|
+
const date = "Mon Apr 04 2022 06:00:00.000Z";
|
|
50
|
+
const expectedDate = new Date("2022-04-04T10:00:00.000Z");
|
|
51
51
|
expect(convertTimeToOtherTimeZone, "called with", [date, timezoneName], "to satisfy", expectedDate);
|
|
52
52
|
});
|
|
53
53
|
});
|