orc-shared 5.99.0-dev.3 → 5.99.0-dev.5
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/StepperModal.js +3 -3
- package/dist/components/MaterialUI/Inputs/InputBase.js +209 -24
- package/dist/hocs/withScrollBox.js +3 -8
- package/package.json +1 -1
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.js +2 -2
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/StepperModal.test.js +74 -0
- package/src/components/MaterialUI/Inputs/InputBase.js +209 -8
- package/src/components/MaterialUI/Inputs/InputBase.test.js +481 -3
- package/src/hocs/withScrollBox.js +2 -8
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { mount } from "enzyme";
|
|
3
|
-
import InputBase, { AdvancedNumericInput } from "./InputBase";
|
|
3
|
+
import InputBase, { AdvancedIntegerInput, AdvancedNumericInput } from "./InputBase";
|
|
4
4
|
import InputBaseMUI from "@material-ui/core/InputBase";
|
|
5
5
|
import sinon from "sinon";
|
|
6
6
|
import { ignoreConsoleError } from "../../../utils/testUtils";
|
|
@@ -317,7 +317,7 @@ describe("InputBase Component", () => {
|
|
|
317
317
|
});
|
|
318
318
|
});
|
|
319
319
|
|
|
320
|
-
describe("InputBase component
|
|
320
|
+
describe("InputBase component debounce", () => {
|
|
321
321
|
const clock = sinon.useFakeTimers();
|
|
322
322
|
let update, container;
|
|
323
323
|
|
|
@@ -399,7 +399,7 @@ describe("AdvancedNumericInput", () => {
|
|
|
399
399
|
container = null;
|
|
400
400
|
});
|
|
401
401
|
|
|
402
|
-
it("Renders InputBase component as advanced numeric input", () => {
|
|
402
|
+
it("Renders InputBase component as advanced numeric input with decimals", () => {
|
|
403
403
|
const inputProps = new InputBaseProps();
|
|
404
404
|
const aLabel = "aLabel";
|
|
405
405
|
const aValue = "value";
|
|
@@ -408,6 +408,7 @@ describe("AdvancedNumericInput", () => {
|
|
|
408
408
|
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
409
409
|
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
410
410
|
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
411
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 2 });
|
|
411
412
|
|
|
412
413
|
const component = <InputBase inputProps={inputProps} />;
|
|
413
414
|
|
|
@@ -417,6 +418,24 @@ describe("AdvancedNumericInput", () => {
|
|
|
417
418
|
expect(mountedComponent.containsMatchingElement(expected), "to be truthy");
|
|
418
419
|
});
|
|
419
420
|
|
|
421
|
+
it("Renders InputBase component as advanced numeric input without decimals", () => {
|
|
422
|
+
const inputProps = new InputBaseProps();
|
|
423
|
+
const aLabel = "aLabel";
|
|
424
|
+
const aValue = "value";
|
|
425
|
+
|
|
426
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
427
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
428
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
429
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
430
|
+
|
|
431
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
432
|
+
|
|
433
|
+
const mountedComponent = mount(component);
|
|
434
|
+
const expected = <InputBaseMUI value={aValue} title="" inputComponent={AdvancedIntegerInput} />;
|
|
435
|
+
|
|
436
|
+
expect(mountedComponent.containsMatchingElement(expected), "to be truthy");
|
|
437
|
+
});
|
|
438
|
+
|
|
420
439
|
it("Renders InputBase component as advanced numeric input with custom numeric props", () => {
|
|
421
440
|
const inputProps = new InputBaseProps();
|
|
422
441
|
const aLabel = "aLabel";
|
|
@@ -946,4 +965,463 @@ describe("AdvancedNumericInput", () => {
|
|
|
946
965
|
|
|
947
966
|
expect(update, "to have calls satisfying", [{ args: ["", metadata] }]);
|
|
948
967
|
});
|
|
968
|
+
|
|
969
|
+
it("Change advanced numeric input value with decimal does not have the spinner buttons", () => {
|
|
970
|
+
const inputProps = new InputBaseProps();
|
|
971
|
+
const aLabel = "aLabel";
|
|
972
|
+
const aValue = "";
|
|
973
|
+
|
|
974
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
975
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
976
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
977
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
978
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 2 });
|
|
979
|
+
|
|
980
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
981
|
+
const mountedComponent = mount(component);
|
|
982
|
+
const btn = mountedComponent.find("[data-qa='increase']");
|
|
983
|
+
expect(btn.length, "to be", 0);
|
|
984
|
+
});
|
|
985
|
+
|
|
986
|
+
it("Disabled advanced numeric input value without decimals should not have the increase/decrease buttons", () => {
|
|
987
|
+
const inputProps = new InputBaseProps();
|
|
988
|
+
const aLabel = "aLabel";
|
|
989
|
+
const aValue = "";
|
|
990
|
+
|
|
991
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
992
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
993
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
994
|
+
inputProps.set(InputBaseProps.propNames.disabled, true);
|
|
995
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
996
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
997
|
+
|
|
998
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
999
|
+
const mountedComponent = mount(component);
|
|
1000
|
+
const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
|
|
1001
|
+
expect(btn.length, "to equal", 0);
|
|
1002
|
+
});
|
|
1003
|
+
|
|
1004
|
+
it("Advanced numeric input value without decimals, simulate onMouseDown to make code coverage happy", () => {
|
|
1005
|
+
const inputProps = new InputBaseProps();
|
|
1006
|
+
const aLabel = "aLabel";
|
|
1007
|
+
const aValue = "";
|
|
1008
|
+
|
|
1009
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1010
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1011
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1012
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1013
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1014
|
+
|
|
1015
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1016
|
+
const mountedComponent = mount(component);
|
|
1017
|
+
const btnIncrease = mountedComponent.find("[data-qa='increase']").hostNodes();
|
|
1018
|
+
const btnDecrease = mountedComponent.find("[data-qa='decrease']").hostNodes();
|
|
1019
|
+
|
|
1020
|
+
btnIncrease.simulate("mouseDown");
|
|
1021
|
+
btnDecrease.simulate("mouseDown");
|
|
1022
|
+
});
|
|
1023
|
+
|
|
1024
|
+
it("Advanced numeric input value without decimals but with custom onKeyDown with prevent default", () => {
|
|
1025
|
+
const keydownSpy = sinon.stub().callsFake(e => {
|
|
1026
|
+
e.preventDefault();
|
|
1027
|
+
});
|
|
1028
|
+
|
|
1029
|
+
const inputProps = new InputBaseProps();
|
|
1030
|
+
const aLabel = "aLabel";
|
|
1031
|
+
const aValue = "";
|
|
1032
|
+
|
|
1033
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1034
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1035
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1036
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1037
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1038
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { onKeyDown: keydownSpy });
|
|
1039
|
+
|
|
1040
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1041
|
+
const mountedComponent = mount(component);
|
|
1042
|
+
const input = mountedComponent.find("input");
|
|
1043
|
+
input.simulate("keydown", { key: "ArrowUp" });
|
|
1044
|
+
|
|
1045
|
+
expect(keydownSpy, "was called once");
|
|
1046
|
+
expect(update, "was not called");
|
|
1047
|
+
});
|
|
1048
|
+
|
|
1049
|
+
it("Advanced numeric input value without decimals but with custom onKeyDown without prevent default", () => {
|
|
1050
|
+
const keydownSpy = sinon.stub().callsFake(e => {});
|
|
1051
|
+
|
|
1052
|
+
const inputProps = new InputBaseProps();
|
|
1053
|
+
const aLabel = "aLabel";
|
|
1054
|
+
const aValue = "";
|
|
1055
|
+
|
|
1056
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1057
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1058
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1059
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1060
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1061
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { onKeyDown: keydownSpy });
|
|
1062
|
+
|
|
1063
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1064
|
+
const mountedComponent = mount(component);
|
|
1065
|
+
const input = mountedComponent.find("input");
|
|
1066
|
+
input.simulate("keydown", { key: "ArrowUp" });
|
|
1067
|
+
|
|
1068
|
+
expect(keydownSpy, "was called once");
|
|
1069
|
+
expect(update, "to have calls satisfying", [{ args: ["1", null] }]);
|
|
1070
|
+
});
|
|
1071
|
+
|
|
1072
|
+
it("Change advanced numeric input value, empty initial value with increase button", () => {
|
|
1073
|
+
const inputProps = new InputBaseProps();
|
|
1074
|
+
const aLabel = "aLabel";
|
|
1075
|
+
const aValue = "";
|
|
1076
|
+
|
|
1077
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1078
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1079
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1080
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1081
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1082
|
+
|
|
1083
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1084
|
+
const mountedComponent = mount(component);
|
|
1085
|
+
const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
|
|
1086
|
+
btn.simulate("click");
|
|
1087
|
+
|
|
1088
|
+
expect(update, "to have calls satisfying", [{ args: ["1", null] }]);
|
|
1089
|
+
});
|
|
1090
|
+
|
|
1091
|
+
it("Change advanced numeric input value, 1 initial value with increase button", () => {
|
|
1092
|
+
const inputProps = new InputBaseProps();
|
|
1093
|
+
const aLabel = "aLabel";
|
|
1094
|
+
const aValue = "1";
|
|
1095
|
+
|
|
1096
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1097
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1098
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1099
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1100
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1101
|
+
|
|
1102
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1103
|
+
const mountedComponent = mount(component);
|
|
1104
|
+
const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
|
|
1105
|
+
btn.simulate("click");
|
|
1106
|
+
|
|
1107
|
+
expect(update, "to have calls satisfying", [{ args: ["2", null] }]);
|
|
1108
|
+
});
|
|
1109
|
+
|
|
1110
|
+
it("Change advanced numeric input value, 10 initial value with max 11 with increase button", () => {
|
|
1111
|
+
const inputProps = new InputBaseProps();
|
|
1112
|
+
const aLabel = "aLabel";
|
|
1113
|
+
const aValue = "10";
|
|
1114
|
+
|
|
1115
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1116
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1117
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1118
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1119
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1120
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -11, max: 11 });
|
|
1121
|
+
|
|
1122
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1123
|
+
const mountedComponent = mount(component);
|
|
1124
|
+
const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
|
|
1125
|
+
btn.simulate("click");
|
|
1126
|
+
|
|
1127
|
+
expect(update, "to have calls satisfying", [{ args: ["11", null] }]);
|
|
1128
|
+
});
|
|
1129
|
+
|
|
1130
|
+
it("Change advanced numeric input value, 11 initial value with max 11 with increase button stays at 11", () => {
|
|
1131
|
+
const inputProps = new InputBaseProps();
|
|
1132
|
+
const aLabel = "aLabel";
|
|
1133
|
+
const aValue = "11";
|
|
1134
|
+
|
|
1135
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1136
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1137
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1138
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1139
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1140
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -11, max: 11 });
|
|
1141
|
+
|
|
1142
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1143
|
+
const mountedComponent = mount(component);
|
|
1144
|
+
const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
|
|
1145
|
+
btn.simulate("click");
|
|
1146
|
+
|
|
1147
|
+
expect(update, "was not called");
|
|
1148
|
+
});
|
|
1149
|
+
|
|
1150
|
+
it("Change advanced numeric input value, empty initial value, min=5, max=15, increase button set value to 5", () => {
|
|
1151
|
+
const inputProps = new InputBaseProps();
|
|
1152
|
+
const aLabel = "aLabel";
|
|
1153
|
+
const aValue = "";
|
|
1154
|
+
|
|
1155
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1156
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1157
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1158
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1159
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1160
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: 5, max: 15 });
|
|
1161
|
+
|
|
1162
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1163
|
+
const mountedComponent = mount(component);
|
|
1164
|
+
const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
|
|
1165
|
+
btn.simulate("click");
|
|
1166
|
+
|
|
1167
|
+
expect(update, "to have calls satisfying", [{ args: ["5", null] }]);
|
|
1168
|
+
});
|
|
1169
|
+
|
|
1170
|
+
it("Change advanced numeric input value, empty initial value, min=-15, max=-5, increase button set value to -5", () => {
|
|
1171
|
+
const inputProps = new InputBaseProps();
|
|
1172
|
+
const aLabel = "aLabel";
|
|
1173
|
+
const aValue = "";
|
|
1174
|
+
|
|
1175
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1176
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1177
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1178
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1179
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1180
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -15, max: -5 });
|
|
1181
|
+
|
|
1182
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1183
|
+
const mountedComponent = mount(component);
|
|
1184
|
+
const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
|
|
1185
|
+
btn.simulate("click");
|
|
1186
|
+
|
|
1187
|
+
expect(update, "to have calls satisfying", [{ args: ["-5", null] }]);
|
|
1188
|
+
});
|
|
1189
|
+
|
|
1190
|
+
it("Change advanced numeric input value, empty initial value, min=5, max=15, increase button set value to 5", () => {
|
|
1191
|
+
const inputProps = new InputBaseProps();
|
|
1192
|
+
const aLabel = "aLabel";
|
|
1193
|
+
const aValue = "";
|
|
1194
|
+
|
|
1195
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1196
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1197
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1198
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1199
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1200
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: 5, max: 15 });
|
|
1201
|
+
|
|
1202
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1203
|
+
const mountedComponent = mount(component);
|
|
1204
|
+
const btn = mountedComponent.find("[data-qa='increase']").hostNodes();
|
|
1205
|
+
btn.simulate("click");
|
|
1206
|
+
|
|
1207
|
+
expect(update, "to have calls satisfying", [{ args: ["5", null] }]);
|
|
1208
|
+
});
|
|
1209
|
+
|
|
1210
|
+
it("Change advanced numeric input value, empty initial value, min=5, max=15, key up set value to 1", () => {
|
|
1211
|
+
const inputProps = new InputBaseProps();
|
|
1212
|
+
const aLabel = "aLabel";
|
|
1213
|
+
const aValue = "";
|
|
1214
|
+
|
|
1215
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1216
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1217
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1218
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1219
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1220
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -5, max: 15 });
|
|
1221
|
+
|
|
1222
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1223
|
+
const mountedComponent = mount(component);
|
|
1224
|
+
const input = mountedComponent.find("input");
|
|
1225
|
+
input.simulate("keydown", { key: "ArrowUp" });
|
|
1226
|
+
|
|
1227
|
+
expect(update, "to have calls satisfying", [{ args: ["1", null] }]);
|
|
1228
|
+
});
|
|
1229
|
+
|
|
1230
|
+
it("Change advanced numeric input value, empty initial value, min=5, max=15, scroll up set value to 1", () => {
|
|
1231
|
+
const inputProps = new InputBaseProps();
|
|
1232
|
+
const aLabel = "aLabel";
|
|
1233
|
+
const aValue = "";
|
|
1234
|
+
|
|
1235
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1236
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1237
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1238
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1239
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1240
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -5, max: 15 });
|
|
1241
|
+
|
|
1242
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1243
|
+
const mountedComponent = mount(component);
|
|
1244
|
+
const input = mountedComponent.find("input");
|
|
1245
|
+
input.simulate("wheel", { deltaY: -100 });
|
|
1246
|
+
|
|
1247
|
+
expect(update, "to have calls satisfying", [{ args: ["1", null] }]);
|
|
1248
|
+
});
|
|
1249
|
+
|
|
1250
|
+
it("Change advanced numeric input value, empty initial value with decrease button", () => {
|
|
1251
|
+
const inputProps = new InputBaseProps();
|
|
1252
|
+
const aLabel = "aLabel";
|
|
1253
|
+
const aValue = "";
|
|
1254
|
+
|
|
1255
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1256
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1257
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1258
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1259
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1260
|
+
|
|
1261
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1262
|
+
const mountedComponent = mount(component);
|
|
1263
|
+
const btn = mountedComponent.find("[data-qa='decrease']").hostNodes();
|
|
1264
|
+
btn.simulate("click");
|
|
1265
|
+
|
|
1266
|
+
expect(update, "to have calls satisfying", [{ args: ["-1", null] }]);
|
|
1267
|
+
});
|
|
1268
|
+
|
|
1269
|
+
it("Change advanced numeric input value, -1 initial value with decrease button", () => {
|
|
1270
|
+
const inputProps = new InputBaseProps();
|
|
1271
|
+
const aLabel = "aLabel";
|
|
1272
|
+
const aValue = "-1";
|
|
1273
|
+
|
|
1274
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1275
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1276
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1277
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1278
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1279
|
+
|
|
1280
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1281
|
+
const mountedComponent = mount(component);
|
|
1282
|
+
const btn = mountedComponent.find("[data-qa='decrease']").hostNodes();
|
|
1283
|
+
btn.simulate("click");
|
|
1284
|
+
|
|
1285
|
+
expect(update, "to have calls satisfying", [{ args: ["-2", null] }]);
|
|
1286
|
+
});
|
|
1287
|
+
|
|
1288
|
+
it("Change advanced numeric input value, -10 initial value with min 11 with decrease button", () => {
|
|
1289
|
+
const inputProps = new InputBaseProps();
|
|
1290
|
+
const aLabel = "aLabel";
|
|
1291
|
+
const aValue = "-10";
|
|
1292
|
+
|
|
1293
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1294
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1295
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1296
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1297
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1298
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -11, max: 11 });
|
|
1299
|
+
|
|
1300
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1301
|
+
const mountedComponent = mount(component);
|
|
1302
|
+
const btn = mountedComponent.find("[data-qa='decrease']").hostNodes();
|
|
1303
|
+
btn.simulate("click");
|
|
1304
|
+
|
|
1305
|
+
expect(update, "to have calls satisfying", [{ args: ["-11", null] }]);
|
|
1306
|
+
});
|
|
1307
|
+
|
|
1308
|
+
it("Change advanced numeric input value, -11 initial value with min -11 with decrease button stays at -11", () => {
|
|
1309
|
+
const inputProps = new InputBaseProps();
|
|
1310
|
+
const aLabel = "aLabel";
|
|
1311
|
+
const aValue = "-11";
|
|
1312
|
+
|
|
1313
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1314
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1315
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1316
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1317
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1318
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -11, max: 11 });
|
|
1319
|
+
|
|
1320
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1321
|
+
const mountedComponent = mount(component);
|
|
1322
|
+
const btn = mountedComponent.find("[data-qa='decrease']").hostNodes();
|
|
1323
|
+
btn.simulate("click");
|
|
1324
|
+
|
|
1325
|
+
expect(update, "was not called");
|
|
1326
|
+
});
|
|
1327
|
+
|
|
1328
|
+
it("Change advanced numeric input value, empty initial value, min=5, max=15, decrease button should set to 5", () => {
|
|
1329
|
+
const inputProps = new InputBaseProps();
|
|
1330
|
+
const aLabel = "aLabel";
|
|
1331
|
+
const aValue = "";
|
|
1332
|
+
|
|
1333
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1334
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1335
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1336
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1337
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1338
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: 5, max: 15 });
|
|
1339
|
+
|
|
1340
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1341
|
+
const mountedComponent = mount(component);
|
|
1342
|
+
const btn = mountedComponent.find("[data-qa='decrease']").hostNodes();
|
|
1343
|
+
btn.simulate("click");
|
|
1344
|
+
|
|
1345
|
+
expect(update, "to have calls satisfying", [{ args: ["5", null] }]);
|
|
1346
|
+
});
|
|
1347
|
+
|
|
1348
|
+
it("Change advanced numeric input value, empty initial value, min=-15, max=-5, decrease button set value to -5", () => {
|
|
1349
|
+
const inputProps = new InputBaseProps();
|
|
1350
|
+
const aLabel = "aLabel";
|
|
1351
|
+
const aValue = "";
|
|
1352
|
+
|
|
1353
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1354
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1355
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1356
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1357
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1358
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -15, max: -5 });
|
|
1359
|
+
|
|
1360
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1361
|
+
const mountedComponent = mount(component);
|
|
1362
|
+
const btn = mountedComponent.find("[data-qa='decrease']").hostNodes();
|
|
1363
|
+
btn.simulate("click");
|
|
1364
|
+
|
|
1365
|
+
expect(update, "to have calls satisfying", [{ args: ["-5", null] }]);
|
|
1366
|
+
});
|
|
1367
|
+
|
|
1368
|
+
it("Change advanced numeric input value, empty initial value, min=5, max=15, decrease button set value to 5", () => {
|
|
1369
|
+
const inputProps = new InputBaseProps();
|
|
1370
|
+
const aLabel = "aLabel";
|
|
1371
|
+
const aValue = "";
|
|
1372
|
+
|
|
1373
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1374
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1375
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1376
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1377
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1378
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: 5, max: 15 });
|
|
1379
|
+
|
|
1380
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1381
|
+
const mountedComponent = mount(component);
|
|
1382
|
+
const btn = mountedComponent.find("[data-qa='decrease']").hostNodes();
|
|
1383
|
+
btn.simulate("click");
|
|
1384
|
+
|
|
1385
|
+
expect(update, "to have calls satisfying", [{ args: ["5", null] }]);
|
|
1386
|
+
});
|
|
1387
|
+
|
|
1388
|
+
it("Change advanced numeric input value, empty initial value, min=5, max=15, key down set value to 1", () => {
|
|
1389
|
+
const inputProps = new InputBaseProps();
|
|
1390
|
+
const aLabel = "aLabel";
|
|
1391
|
+
const aValue = "";
|
|
1392
|
+
|
|
1393
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1394
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1395
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1396
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1397
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1398
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -5, max: 15 });
|
|
1399
|
+
|
|
1400
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1401
|
+
const mountedComponent = mount(component);
|
|
1402
|
+
const input = mountedComponent.find("input");
|
|
1403
|
+
input.simulate("keydown", { key: "ArrowDown" });
|
|
1404
|
+
|
|
1405
|
+
expect(update, "to have calls satisfying", [{ args: ["-1", null] }]);
|
|
1406
|
+
});
|
|
1407
|
+
|
|
1408
|
+
it("Change advanced numeric input value, empty initial value, min=5, max=15, scroll down set value to 1", () => {
|
|
1409
|
+
const inputProps = new InputBaseProps();
|
|
1410
|
+
const aLabel = "aLabel";
|
|
1411
|
+
const aValue = "";
|
|
1412
|
+
|
|
1413
|
+
inputProps.set(InputBaseProps.propNames.update, update);
|
|
1414
|
+
inputProps.set(InputBaseProps.propNames.value, aValue);
|
|
1415
|
+
inputProps.set(InputBaseProps.propNames.label, aLabel);
|
|
1416
|
+
inputProps.set(InputBaseProps.propNames.type, "AdvancedNumericInput");
|
|
1417
|
+
inputProps.set(InputBaseProps.propNames.numericInputProps, { decimalScale: 0 });
|
|
1418
|
+
inputProps.set(InputBaseProps.propNames.inputAttributes, { min: -5, max: 15 });
|
|
1419
|
+
|
|
1420
|
+
const component = <InputBase inputProps={inputProps} />;
|
|
1421
|
+
const mountedComponent = mount(component);
|
|
1422
|
+
const input = mountedComponent.find("input");
|
|
1423
|
+
input.simulate("wheel", { deltaY: 100 });
|
|
1424
|
+
|
|
1425
|
+
expect(update, "to have calls satisfying", [{ args: ["-1", null] }]);
|
|
1426
|
+
});
|
|
949
1427
|
});
|
|
@@ -15,16 +15,10 @@ const withScrollBox = WrappedComp =>
|
|
|
15
15
|
React.forwardRef(({ onScroll, ...otherProps }, externalRef) => {
|
|
16
16
|
const classes = useStyles();
|
|
17
17
|
|
|
18
|
-
const mergeRef = (node, measureRef) => {
|
|
19
|
-
measureRef(node);
|
|
20
|
-
|
|
21
|
-
if (externalRef) externalRef.current = node;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
18
|
return (
|
|
25
|
-
<Measure bounds>
|
|
19
|
+
<Measure bounds innerRef={externalRef}>
|
|
26
20
|
{({ measureRef, contentRect }) => (
|
|
27
|
-
<div className={classes.scrollbox} onScroll={onScroll} ref={
|
|
21
|
+
<div className={classes.scrollbox} onScroll={onScroll} ref={measureRef}>
|
|
28
22
|
<WrappedComp
|
|
29
23
|
{...otherProps}
|
|
30
24
|
height={safeGet(contentRect, "bounds", "height")}
|