orc-shared 5.10.0-dev.2 → 5.10.0-dev.21
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/actions/metadata.js +30 -11
- package/dist/actions/requestsApi.js +10 -1
- package/dist/components/AppFrame/About.js +136 -100
- package/dist/components/AppFrame/Anchor.js +45 -21
- package/dist/components/AppFrame/AppFrame.js +53 -31
- package/dist/components/AppFrame/Help.js +35 -15
- package/dist/components/AppFrame/MenuItem.js +148 -114
- package/dist/components/AppFrame/Preferences.js +136 -97
- package/dist/components/AppFrame/Sidebar.js +51 -28
- package/dist/components/AppFrame/Topbar.js +61 -36
- package/dist/components/ColumnWrapper.js +28 -5
- package/dist/components/Culture.js +33 -14
- package/dist/components/DropMenu/Menu.js +79 -45
- package/dist/components/DropMenu/index.js +34 -29
- package/dist/components/Form/Combination.js +45 -16
- package/dist/components/Form/Field.js +57 -38
- package/dist/components/Form/FieldElements.js +0 -11
- package/dist/components/Form/Fieldset.js +47 -19
- package/dist/components/Form/Form.js +22 -9
- package/dist/components/Form/FormElement.js +40 -7
- package/dist/components/Form/Inputs/Button.js +63 -18
- package/dist/components/Form/Inputs/ReadOnly.js +50 -27
- package/dist/components/{AppFrame/ApplicationSelector/Header.js → Form/Inputs/Selector.js} +30 -31
- package/dist/components/Form/Inputs/Text.js +20 -37
- package/dist/components/Form/Inputs/Toggles.js +39 -40
- package/dist/components/Form/Inputs/index.js +2 -13
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +31 -11
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/SectionToolbar.js +89 -0
- package/dist/components/MaterialUI/DataDisplay/Table.js +109 -18
- package/dist/components/MaterialUI/DataDisplay/TableProps.js +5 -1
- package/dist/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.js +198 -0
- package/dist/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +4 -1
- package/dist/components/MaterialUI/Inputs/DatePicker.js +14 -14
- package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -0
- package/dist/components/MaterialUI/Inputs/Select.js +2 -0
- package/dist/components/MaterialUI/Inputs/SelectProps.js +2 -0
- package/dist/components/MaterialUI/Inputs/Switch.js +17 -1
- package/dist/components/MaterialUI/Inputs/SwitchProps.js +2 -0
- package/dist/components/MaterialUI/Inputs/TimePicker.js +14 -21
- package/dist/components/MaterialUI/hocs/withDeferredTooltip.js +3 -1
- package/dist/components/MaterialUI/muiThemes.js +2 -1
- package/dist/components/Provision.js +1 -1
- package/dist/constants.js +2 -1
- package/dist/content/iconsSheet.svg +740 -116
- package/dist/hocs/withScrollBox.js +27 -12
- package/dist/hooks/useDaysAndMonthsLocalization.js +77 -0
- package/dist/hooks/useInMemoryPaging.js +135 -0
- package/dist/hooks/useMultipleFieldEditState.js +12 -3
- package/dist/reducers/metadata.js +6 -0
- package/dist/schemas/metadata.js +9 -1
- package/dist/selectors/locale.js +1 -0
- package/dist/selectors/metadata.js +14 -11
- package/dist/sharedMessages.js +184 -0
- package/dist/utils/ListHelper.js +271 -0
- package/dist/utils/comparisonHelper.js +185 -0
- package/dist/utils/propertyBagHelper.js +3 -1
- package/dist/utils/timezoneHelper.js +18 -31
- package/package.json +4 -3
- package/src/actions/metadata.js +11 -0
- package/src/actions/metadata.test.js +27 -0
- package/src/actions/requestsApi.js +6 -0
- package/src/components/AppFrame/About.js +97 -117
- package/src/components/AppFrame/About.test.js +128 -90
- package/src/components/AppFrame/Anchor.js +34 -36
- package/src/components/AppFrame/Anchor.test.js +5 -68
- package/src/components/AppFrame/AppFrame.js +31 -40
- package/src/components/AppFrame/AppFrame.test.js +424 -445
- package/src/components/AppFrame/Help.js +23 -20
- package/src/components/AppFrame/Help.test.js +3 -3
- package/src/components/AppFrame/MenuItem.js +106 -126
- package/src/components/AppFrame/MenuItem.test.js +78 -169
- package/src/components/AppFrame/Preferences.js +110 -98
- package/src/components/AppFrame/Preferences.test.js +115 -219
- package/src/components/AppFrame/Sidebar.js +39 -41
- package/src/components/AppFrame/Sidebar.test.js +88 -168
- package/src/components/AppFrame/Topbar.js +59 -52
- package/src/components/AppFrame/Topbar.test.js +31 -39
- package/src/components/ColumnWrapper.js +18 -9
- package/src/components/Culture.js +20 -10
- package/src/components/Culture.test.js +27 -16
- package/src/components/DropMenu/DropMenu.test.js +185 -224
- package/src/components/DropMenu/Menu.js +73 -80
- package/src/components/DropMenu/Menu.test.js +35 -86
- package/src/components/DropMenu/index.js +19 -15
- package/src/components/Form/Combination.js +35 -28
- package/src/components/Form/Combination.test.js +6 -19
- package/src/components/Form/Field.js +53 -66
- package/src/components/Form/Field.test.js +29 -51
- package/src/components/Form/FieldElements.js +0 -14
- package/src/components/Form/FieldElements.test.js +104 -111
- package/src/components/Form/Fieldset.js +42 -37
- package/src/components/Form/Fieldset.test.js +14 -7
- package/src/components/Form/Form.js +11 -7
- package/src/components/Form/Form.test.js +75 -56
- package/src/components/Form/FormElement.js +24 -16
- package/src/components/Form/InputField.test.js +24 -30
- package/src/components/Form/Inputs/Button.js +58 -14
- package/src/components/Form/Inputs/Button.test.js +32 -7
- package/src/components/Form/Inputs/Inputs.test.js +0 -7
- package/src/components/Form/Inputs/ReadOnly.js +34 -28
- package/src/components/Form/Inputs/ReadOnly.test.js +45 -7
- package/src/components/Form/Inputs/Selector.js +22 -0
- package/src/components/Form/Inputs/Selector.test.js +105 -0
- package/src/components/Form/Inputs/Text.js +15 -44
- package/src/components/Form/Inputs/Text.test.js +20 -29
- package/src/components/Form/Inputs/Toggles.js +27 -26
- package/src/components/Form/Inputs/Toggles.test.js +22 -28
- package/src/components/Form/Inputs/index.js +4 -15
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.test.js +1 -4
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +32 -6
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.test.js +3 -1
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/SectionToolbar.js +39 -0
- package/src/components/MaterialUI/DataDisplay/Table.js +190 -114
- package/src/components/MaterialUI/DataDisplay/Table.test.js +246 -1
- package/src/components/MaterialUI/DataDisplay/TableProps.js +4 -0
- package/src/components/MaterialUI/DataDisplay/TableProps.test.js +2 -0
- package/src/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.js +145 -0
- package/src/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.test.js +457 -0
- package/src/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +5 -1
- package/src/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.test.js +7 -1
- package/src/components/MaterialUI/Inputs/DatePicker.js +19 -20
- package/src/components/MaterialUI/Inputs/DatePicker.test.js +11 -6
- package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -0
- package/src/components/MaterialUI/Inputs/Select.js +2 -0
- package/src/components/MaterialUI/Inputs/SelectProps.js +2 -0
- package/src/components/MaterialUI/Inputs/SelectProps.test.js +2 -0
- package/src/components/MaterialUI/Inputs/Switch.js +22 -1
- package/src/components/MaterialUI/Inputs/Switch.test.js +23 -0
- package/src/components/MaterialUI/Inputs/SwitchProps.js +2 -0
- package/src/components/MaterialUI/Inputs/SwitchProps.test.js +2 -0
- package/src/components/MaterialUI/Inputs/TimePicker.js +10 -19
- package/src/components/MaterialUI/Inputs/TimePicker.test.js +278 -117
- package/src/components/MaterialUI/hocs/withDeferredTooltip.js +4 -1
- package/src/components/MaterialUI/hocs/withDeferredTooltip.test.js +27 -0
- package/src/components/MaterialUI/muiThemes.js +1 -0
- package/src/components/Navigation/Bar.test.js +92 -87
- package/src/components/Provision.js +1 -1
- package/src/components/TaskDetailsModal.test.js +1 -3
- package/src/constants.js +1 -0
- package/src/content/iconsSheet.svg +740 -116
- package/src/hocs/withScrollBox.js +32 -19
- package/src/hocs/withScrollBox.test.js +15 -3
- package/src/hooks/useDaysAndMonthsLocalization.js +79 -0
- package/src/hooks/useDaysAndMonthsLocalization.test.js +107 -0
- package/src/hooks/useInMemoryPaging.js +78 -0
- package/src/hooks/useInMemoryPaging.test.js +515 -0
- package/src/hooks/useMultipleFieldEditState.js +11 -4
- package/src/hooks/useMultipleFieldEditState.test.js +49 -1
- package/src/reducers/metadata.js +6 -1
- package/src/reducers/metadata.test.js +31 -0
- package/src/requests +1 -0
- package/src/schemas/metadata.js +3 -0
- package/src/selectors/locale.js +1 -1
- package/src/selectors/metadata.js +12 -9
- package/src/selectors/metadata.test.js +92 -11
- package/src/sharedMessages.js +184 -0
- package/src/timezones.json +883 -0
- package/src/translations/en-US.json +46 -0
- package/src/translations/fr-CA.json +46 -0
- package/src/utils/ListHelper.js +203 -0
- package/src/utils/ListHelper.test.js +710 -0
- package/src/utils/comparisonHelper.js +135 -0
- package/src/utils/comparisonHelper.test.js +334 -0
- package/src/utils/propertyBagHelper.js +2 -0
- package/src/utils/propertyBagHelper.test.js +6 -0
- package/src/utils/timezoneHelper.js +10 -135
- package/src/utils/timezoneHelper.test.js +7 -7
- package/dist/components/Form/FieldList.js +0 -270
- package/dist/components/Form/Inputs/FieldButtons.js +0 -66
- package/dist/components/Form/Inputs/Number.js +0 -117
- package/dist/components/Form/Inputs/SmallButton.js +0 -91
- package/dist/components/Form/Inputs/Time.js +0 -86
- package/dist/components/Form/Inputs/Translation.js +0 -169
- package/src/components/AppFrame/ApplicationSelector/Header.js +0 -34
- package/src/components/AppFrame/ApplicationSelector/Header.test.js +0 -23
- package/src/components/Form/FieldList.js +0 -210
- package/src/components/Form/FieldList.test.js +0 -558
- package/src/components/Form/Inputs/FieldButtons.js +0 -90
- package/src/components/Form/Inputs/Number.js +0 -60
- package/src/components/Form/Inputs/Number.test.js +0 -435
- package/src/components/Form/Inputs/SmallButton.js +0 -37
- package/src/components/Form/Inputs/SmallButton.test.js +0 -65
- package/src/components/Form/Inputs/Time.js +0 -32
- package/src/components/Form/Inputs/Time.test.js +0 -41
- package/src/components/Form/Inputs/Translation.js +0 -93
- package/src/components/Form/Inputs/Translation.test.js +0 -204
|
@@ -1,435 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { IntlProvider } from "react-intl";
|
|
3
|
-
import { Ignore } from "unexpected-reaction";
|
|
4
|
-
import sinon from "sinon";
|
|
5
|
-
import { FormInput } from "./Text";
|
|
6
|
-
import { ButtonWrapper, Spinners, InputButton } from "./FieldButtons";
|
|
7
|
-
import { NumberInput, roundToStep } from "./Number";
|
|
8
|
-
|
|
9
|
-
describe("NumberInput", () => {
|
|
10
|
-
let update;
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
update = sinon.spy().named("update");
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it("renders an input field with up/down spinner buttons", () =>
|
|
16
|
-
expect(
|
|
17
|
-
<IntlProvider locale="en-US">
|
|
18
|
-
<NumberInput value={103.271} />
|
|
19
|
-
</IntlProvider>,
|
|
20
|
-
"when mounted",
|
|
21
|
-
"to satisfy",
|
|
22
|
-
<ButtonWrapper>
|
|
23
|
-
<IntlProvider locale="en-US">
|
|
24
|
-
<FormInput type="number" value={103.271} onChange={() => {}} />
|
|
25
|
-
</IntlProvider>
|
|
26
|
-
<Spinners>
|
|
27
|
-
<InputButton>⮝</InputButton>
|
|
28
|
-
<InputButton>⮟</InputButton>
|
|
29
|
-
</Spinners>
|
|
30
|
-
</ButtonWrapper>,
|
|
31
|
-
));
|
|
32
|
-
|
|
33
|
-
it("renders a required input field with invalid value", () =>
|
|
34
|
-
expect(
|
|
35
|
-
<IntlProvider locale="en-US">
|
|
36
|
-
<NumberInput required value="" />
|
|
37
|
-
</IntlProvider>,
|
|
38
|
-
"when mounted",
|
|
39
|
-
"to satisfy",
|
|
40
|
-
<ButtonWrapper invalid>
|
|
41
|
-
<IntlProvider locale="en-US">
|
|
42
|
-
<FormInput type="number" value="" onChange={() => {}} />
|
|
43
|
-
</IntlProvider>
|
|
44
|
-
<Ignore />
|
|
45
|
-
</ButtonWrapper>,
|
|
46
|
-
));
|
|
47
|
-
|
|
48
|
-
it("rounds input value top the step size", () =>
|
|
49
|
-
expect(
|
|
50
|
-
<IntlProvider locale="en-US">
|
|
51
|
-
<NumberInput value={103.271} step={0.25} />
|
|
52
|
-
</IntlProvider>,
|
|
53
|
-
"when mounted",
|
|
54
|
-
"to satisfy",
|
|
55
|
-
<ButtonWrapper>
|
|
56
|
-
<IntlProvider locale="en-US">
|
|
57
|
-
<FormInput type="number" value={103.25} onChange={() => {}} />
|
|
58
|
-
</IntlProvider>
|
|
59
|
-
<Ignore />
|
|
60
|
-
</ButtonWrapper>,
|
|
61
|
-
));
|
|
62
|
-
|
|
63
|
-
it("renders a required input field with invalid value", () =>
|
|
64
|
-
expect(
|
|
65
|
-
<IntlProvider locale="en-US">
|
|
66
|
-
<NumberInput required step={0.1} value="" />
|
|
67
|
-
</IntlProvider>,
|
|
68
|
-
"when mounted",
|
|
69
|
-
"to satisfy",
|
|
70
|
-
<ButtonWrapper invalid>
|
|
71
|
-
<IntlProvider locale="en-US">
|
|
72
|
-
<FormInput type="number" value="" onChange={() => {}} />
|
|
73
|
-
</IntlProvider>
|
|
74
|
-
<Ignore />
|
|
75
|
-
</ButtonWrapper>,
|
|
76
|
-
));
|
|
77
|
-
|
|
78
|
-
it("sets a default value to ensure input is controlled", () =>
|
|
79
|
-
expect(
|
|
80
|
-
<IntlProvider locale="en-US">
|
|
81
|
-
<NumberInput onChange={() => {}} />
|
|
82
|
-
</IntlProvider>,
|
|
83
|
-
"when mounted",
|
|
84
|
-
"to satisfy",
|
|
85
|
-
<ButtonWrapper>
|
|
86
|
-
<IntlProvider locale="en-US">
|
|
87
|
-
<FormInput type="number" value="" onChange={() => {}} />
|
|
88
|
-
</IntlProvider>
|
|
89
|
-
<Ignore />
|
|
90
|
-
</ButtonWrapper>,
|
|
91
|
-
));
|
|
92
|
-
|
|
93
|
-
describe("with no control prop", () => {
|
|
94
|
-
it("onChange handler enforces numbers", () =>
|
|
95
|
-
expect(
|
|
96
|
-
<IntlProvider locale="en-US">
|
|
97
|
-
<NumberInput update={update} />
|
|
98
|
-
</IntlProvider>,
|
|
99
|
-
"when mounted",
|
|
100
|
-
"with event",
|
|
101
|
-
{ type: "change", target: "input", value: "foo" },
|
|
102
|
-
"with event",
|
|
103
|
-
{ type: "change", target: "input", value: "0" },
|
|
104
|
-
"with event",
|
|
105
|
-
{ type: "change", target: "input", value: "12.29" },
|
|
106
|
-
"with event",
|
|
107
|
-
{ type: "change", target: "input", value: "0.13" },
|
|
108
|
-
).then(() =>
|
|
109
|
-
expect(update, "to have calls satisfying", [
|
|
110
|
-
{ args: [""] },
|
|
111
|
-
{ args: [0] },
|
|
112
|
-
{ args: [12.29] },
|
|
113
|
-
{ args: [0.13] },
|
|
114
|
-
]),
|
|
115
|
-
));
|
|
116
|
-
|
|
117
|
-
it("increment handler raises value by 1", () =>
|
|
118
|
-
expect(
|
|
119
|
-
<IntlProvider locale="en-US">
|
|
120
|
-
<NumberInput update={update} value={3.545444} />
|
|
121
|
-
</IntlProvider>,
|
|
122
|
-
"when mounted",
|
|
123
|
-
"with event",
|
|
124
|
-
{ type: "click", target: '[data-test-id="up"]' },
|
|
125
|
-
).then(() => expect(update, "to have calls satisfying", [{ args: [4.545444] }])));
|
|
126
|
-
|
|
127
|
-
it("increments from zero", () =>
|
|
128
|
-
expect(
|
|
129
|
-
<IntlProvider locale="en-US">
|
|
130
|
-
<NumberInput update={update} value={0} />
|
|
131
|
-
</IntlProvider>,
|
|
132
|
-
"when mounted",
|
|
133
|
-
"with event",
|
|
134
|
-
{ type: "click", target: '[data-test-id="up"]' },
|
|
135
|
-
).then(() => expect(update, "to have calls satisfying", [{ args: [1] }])));
|
|
136
|
-
|
|
137
|
-
it("decrement handler lowers value by 1", () =>
|
|
138
|
-
expect(
|
|
139
|
-
<IntlProvider locale="en-US">
|
|
140
|
-
<NumberInput update={update} value={3.545444} />
|
|
141
|
-
</IntlProvider>,
|
|
142
|
-
"when mounted",
|
|
143
|
-
"with event",
|
|
144
|
-
{ type: "click", target: '[data-test-id="down"]' },
|
|
145
|
-
).then(() => expect(update, "to have calls satisfying", [{ args: [2.545444] }])));
|
|
146
|
-
|
|
147
|
-
it("decrements from zero", () =>
|
|
148
|
-
expect(
|
|
149
|
-
<IntlProvider locale="en-US">
|
|
150
|
-
<NumberInput update={update} value={0} />
|
|
151
|
-
</IntlProvider>,
|
|
152
|
-
"when mounted",
|
|
153
|
-
"with event",
|
|
154
|
-
{ type: "click", target: '[data-test-id="down"]' },
|
|
155
|
-
).then(() => expect(update, "to have calls satisfying", [{ args: [-1] }])));
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
describe("with step prop", () => {
|
|
159
|
-
it("onChange handler enforces numbers rounded to nearest step", () =>
|
|
160
|
-
expect(
|
|
161
|
-
<IntlProvider locale="en-US">
|
|
162
|
-
<NumberInput update={update} step={0.1} />
|
|
163
|
-
</IntlProvider>,
|
|
164
|
-
"when mounted",
|
|
165
|
-
"with event",
|
|
166
|
-
{ type: "change", target: "input", value: "foo" },
|
|
167
|
-
"with event",
|
|
168
|
-
{ type: "change", target: "input", value: "0" },
|
|
169
|
-
"with event",
|
|
170
|
-
{ type: "change", target: "input", value: "12.29" },
|
|
171
|
-
"with event",
|
|
172
|
-
{ type: "change", target: "input", value: "0.13" },
|
|
173
|
-
).then(() =>
|
|
174
|
-
expect(update, "to have calls satisfying", [{ args: [""] }, { args: [0] }, { args: [12.3] }, { args: [0.1] }]),
|
|
175
|
-
));
|
|
176
|
-
|
|
177
|
-
it("increment handler raises value by step size", () =>
|
|
178
|
-
expect(
|
|
179
|
-
<IntlProvider locale="en-US">
|
|
180
|
-
<NumberInput update={update} step={0.1} value={3.5} />
|
|
181
|
-
</IntlProvider>,
|
|
182
|
-
"when mounted",
|
|
183
|
-
"with event",
|
|
184
|
-
{ type: "click", target: '[data-test-id="up"]' },
|
|
185
|
-
).then(() => expect(update, "to have calls satisfying", [{ args: [3.6] }])));
|
|
186
|
-
|
|
187
|
-
it("increments from zero", () =>
|
|
188
|
-
expect(
|
|
189
|
-
<IntlProvider locale="en-US">
|
|
190
|
-
<NumberInput update={update} step={0.1} value={0} />
|
|
191
|
-
</IntlProvider>,
|
|
192
|
-
"when mounted",
|
|
193
|
-
"with event",
|
|
194
|
-
{ type: "click", target: '[data-test-id="up"]' },
|
|
195
|
-
).then(() => expect(update, "to have calls satisfying", [{ args: [0.1] }])));
|
|
196
|
-
|
|
197
|
-
it("decrement handler lowers value by step size", () =>
|
|
198
|
-
expect(
|
|
199
|
-
<IntlProvider locale="en-US">
|
|
200
|
-
<NumberInput update={update} step={0.1} value={3.5} />
|
|
201
|
-
</IntlProvider>,
|
|
202
|
-
"when mounted",
|
|
203
|
-
"with event",
|
|
204
|
-
{ type: "click", target: '[data-test-id="down"]' },
|
|
205
|
-
).then(() => expect(update, "to have calls satisfying", [{ args: [3.4] }])));
|
|
206
|
-
|
|
207
|
-
it("decrements from zero", () =>
|
|
208
|
-
expect(
|
|
209
|
-
<IntlProvider locale="en-US">
|
|
210
|
-
<NumberInput update={update} step={0.1} value={0} />
|
|
211
|
-
</IntlProvider>,
|
|
212
|
-
"when mounted",
|
|
213
|
-
"with event",
|
|
214
|
-
{ type: "click", target: '[data-test-id="down"]' },
|
|
215
|
-
).then(() => expect(update, "to have calls satisfying", [{ args: [-0.1] }])));
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
describe("with min prop", () => {
|
|
219
|
-
it("onChange handler enforces numbers", () =>
|
|
220
|
-
expect(
|
|
221
|
-
<IntlProvider locale="en-US">
|
|
222
|
-
<NumberInput min={3} update={update} />
|
|
223
|
-
</IntlProvider>,
|
|
224
|
-
"when mounted",
|
|
225
|
-
"with event",
|
|
226
|
-
{ type: "change", target: "input", value: "foo" },
|
|
227
|
-
"with event",
|
|
228
|
-
{ type: "change", target: "input", value: "0" },
|
|
229
|
-
"with event",
|
|
230
|
-
{ type: "change", target: "input", value: "12.29" },
|
|
231
|
-
"with event",
|
|
232
|
-
{ type: "change", target: "input", value: "0.13" },
|
|
233
|
-
).then(() =>
|
|
234
|
-
expect(update, "to have calls satisfying", [{ args: [""] }, { args: [3] }, { args: [12.29] }, { args: [3] }]),
|
|
235
|
-
));
|
|
236
|
-
|
|
237
|
-
it("increment handler raises value by 1", () =>
|
|
238
|
-
expect(
|
|
239
|
-
<IntlProvider locale="en-US">
|
|
240
|
-
<NumberInput min={3} update={update} value={3.545444} />
|
|
241
|
-
</IntlProvider>,
|
|
242
|
-
"when mounted",
|
|
243
|
-
"with event",
|
|
244
|
-
{ type: "click", target: '[data-test-id="up"]' },
|
|
245
|
-
).then(() => expect(update, "to have calls satisfying", [{ args: [4.545444] }])));
|
|
246
|
-
|
|
247
|
-
it("decrement handler lowers value by 1", () =>
|
|
248
|
-
expect(
|
|
249
|
-
<IntlProvider locale="en-US">
|
|
250
|
-
<NumberInput min={3} update={update} value={4.545444} />
|
|
251
|
-
</IntlProvider>,
|
|
252
|
-
"when mounted",
|
|
253
|
-
"with event",
|
|
254
|
-
{ type: "click", target: '[data-test-id="down"]' },
|
|
255
|
-
).then(() => expect(update, "to have calls satisfying", [{ args: [3.545444] }])));
|
|
256
|
-
|
|
257
|
-
it("respects minimum", () =>
|
|
258
|
-
expect(
|
|
259
|
-
<IntlProvider locale="en-US">
|
|
260
|
-
<NumberInput min={3} update={update} value={3.545444} />
|
|
261
|
-
</IntlProvider>,
|
|
262
|
-
"when mounted",
|
|
263
|
-
"with event",
|
|
264
|
-
{ type: "click", target: '[data-test-id="down"]' },
|
|
265
|
-
).then(() => expect(update, "to have calls satisfying", [{ args: [3] }])));
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
describe("with min and step prop", () => {
|
|
269
|
-
it("onChange handler enforces numbers rounded to nearest step", () =>
|
|
270
|
-
expect(
|
|
271
|
-
<IntlProvider locale="en-US">
|
|
272
|
-
<NumberInput step={0.1} min={3} update={update} />
|
|
273
|
-
</IntlProvider>,
|
|
274
|
-
"when mounted",
|
|
275
|
-
"with event",
|
|
276
|
-
{ type: "change", target: "input", value: "foo" },
|
|
277
|
-
"with event",
|
|
278
|
-
{ type: "change", target: "input", value: "0" },
|
|
279
|
-
"with event",
|
|
280
|
-
{ type: "change", target: "input", value: "12.29" },
|
|
281
|
-
"with event",
|
|
282
|
-
{ type: "change", target: "input", value: "0.13" },
|
|
283
|
-
).then(() =>
|
|
284
|
-
expect(update, "to have calls satisfying", [{ args: [""] }, { args: [3] }, { args: [12.3] }, { args: [3] }]),
|
|
285
|
-
));
|
|
286
|
-
|
|
287
|
-
it("increment handler raises value by 1", () =>
|
|
288
|
-
expect(
|
|
289
|
-
<IntlProvider locale="en-US">
|
|
290
|
-
<NumberInput step={0.1} min={3} update={update} value={3.545444} />
|
|
291
|
-
</IntlProvider>,
|
|
292
|
-
"when mounted",
|
|
293
|
-
"with event",
|
|
294
|
-
{ type: "click", target: '[data-test-id="up"]' },
|
|
295
|
-
).then(() => expect(update, "to have calls satisfying", [{ args: [3.6] }])));
|
|
296
|
-
|
|
297
|
-
it("decrement handler lowers value by 1", () =>
|
|
298
|
-
expect(
|
|
299
|
-
<IntlProvider locale="en-US">
|
|
300
|
-
<NumberInput step={0.1} min={3} update={update} value={3.555444} />
|
|
301
|
-
</IntlProvider>,
|
|
302
|
-
"when mounted",
|
|
303
|
-
"with event",
|
|
304
|
-
{ type: "click", target: '[data-test-id="down"]' },
|
|
305
|
-
).then(() => expect(update, "to have calls satisfying", [{ args: [3.5] }])));
|
|
306
|
-
|
|
307
|
-
it("respects minimum", () =>
|
|
308
|
-
expect(
|
|
309
|
-
<IntlProvider locale="en-US">
|
|
310
|
-
<NumberInput step={0.1} min={3} update={update} value={3.045444} />
|
|
311
|
-
</IntlProvider>,
|
|
312
|
-
"when mounted",
|
|
313
|
-
"with event",
|
|
314
|
-
{ type: "click", target: '[data-test-id="down"]' },
|
|
315
|
-
).then(() => expect(update, "to have calls satisfying", [{ args: [3] }])));
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
describe("with max prop", () => {
|
|
319
|
-
it("onChange handler enforces numbers", () =>
|
|
320
|
-
expect(
|
|
321
|
-
<IntlProvider locale="en-US">
|
|
322
|
-
<NumberInput max={3} update={update} />
|
|
323
|
-
</IntlProvider>,
|
|
324
|
-
"when mounted",
|
|
325
|
-
"with event",
|
|
326
|
-
{ type: "change", target: "input", value: "foo" },
|
|
327
|
-
"with event",
|
|
328
|
-
{ type: "change", target: "input", value: "0" },
|
|
329
|
-
"with event",
|
|
330
|
-
{ type: "change", target: "input", value: "12.29" },
|
|
331
|
-
"with event",
|
|
332
|
-
{ type: "change", target: "input", value: "0.13" },
|
|
333
|
-
).then(() =>
|
|
334
|
-
expect(update, "to have calls satisfying", [{ args: [""] }, { args: [0] }, { args: [3] }, { args: [0.13] }]),
|
|
335
|
-
));
|
|
336
|
-
|
|
337
|
-
it("increment handler raises value by 1", () =>
|
|
338
|
-
expect(
|
|
339
|
-
<IntlProvider locale="en-US">
|
|
340
|
-
<NumberInput max={3} update={update} value={1.545344} />
|
|
341
|
-
</IntlProvider>,
|
|
342
|
-
"when mounted",
|
|
343
|
-
"with event",
|
|
344
|
-
{ type: "click", target: '[data-test-id="up"]' },
|
|
345
|
-
).then(() => expect(update, "to have calls satisfying", [{ args: [2.545344] }])));
|
|
346
|
-
|
|
347
|
-
it("respects maximum", () =>
|
|
348
|
-
expect(
|
|
349
|
-
<IntlProvider locale="en-US">
|
|
350
|
-
<NumberInput max={3} update={update} value={2.5458} />
|
|
351
|
-
</IntlProvider>,
|
|
352
|
-
"when mounted",
|
|
353
|
-
"with event",
|
|
354
|
-
{ type: "click", target: '[data-test-id="up"]' },
|
|
355
|
-
).then(() => expect(update, "to have calls satisfying", [{ args: [3] }])));
|
|
356
|
-
|
|
357
|
-
it("decrement handler lowers value by 1", () =>
|
|
358
|
-
expect(
|
|
359
|
-
<IntlProvider locale="en-US">
|
|
360
|
-
<NumberInput max={3} update={update} value={2.545} />
|
|
361
|
-
</IntlProvider>,
|
|
362
|
-
"when mounted",
|
|
363
|
-
"with event",
|
|
364
|
-
{ type: "click", target: '[data-test-id="down"]' },
|
|
365
|
-
).then(() => expect(update, "to have calls satisfying", [{ args: [1.545] }])));
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
describe("with max and step prop", () => {
|
|
369
|
-
it("onChange handler enforces numbers rounded to nearest step", () =>
|
|
370
|
-
expect(
|
|
371
|
-
<IntlProvider locale="en-US">
|
|
372
|
-
<NumberInput step={0.1} max={3} update={update} />
|
|
373
|
-
</IntlProvider>,
|
|
374
|
-
"when mounted",
|
|
375
|
-
"with event",
|
|
376
|
-
{ type: "change", target: "input", value: "foo" },
|
|
377
|
-
"with event",
|
|
378
|
-
{ type: "change", target: "input", value: "0" },
|
|
379
|
-
"with event",
|
|
380
|
-
{ type: "change", target: "input", value: "12.29" },
|
|
381
|
-
"with event",
|
|
382
|
-
{ type: "change", target: "input", value: "0.13" },
|
|
383
|
-
).then(() =>
|
|
384
|
-
expect(update, "to have calls satisfying", [{ args: [""] }, { args: [0] }, { args: [3] }, { args: [0.1] }]),
|
|
385
|
-
));
|
|
386
|
-
|
|
387
|
-
it("increment handler raises value by 1", () =>
|
|
388
|
-
expect(
|
|
389
|
-
<IntlProvider locale="en-US">
|
|
390
|
-
<NumberInput step={0.1} max={3} update={update} value={1.545} />
|
|
391
|
-
</IntlProvider>,
|
|
392
|
-
"when mounted",
|
|
393
|
-
"with event",
|
|
394
|
-
{ type: "click", target: '[data-test-id="up"]' },
|
|
395
|
-
).then(() => expect(update, "to have calls satisfying", [{ args: [1.6] }])));
|
|
396
|
-
|
|
397
|
-
it("respects maximum", () =>
|
|
398
|
-
expect(
|
|
399
|
-
<IntlProvider locale="en-US">
|
|
400
|
-
<NumberInput step={0.1} max={3} update={update} value={2.9999} />
|
|
401
|
-
</IntlProvider>,
|
|
402
|
-
"when mounted",
|
|
403
|
-
"with event",
|
|
404
|
-
{ type: "click", target: '[data-test-id="up"]' },
|
|
405
|
-
).then(() => expect(update, "to have calls satisfying", [{ args: [3] }])));
|
|
406
|
-
|
|
407
|
-
it("decrement handler lowers value by 1", () =>
|
|
408
|
-
expect(
|
|
409
|
-
<IntlProvider locale="en-US">
|
|
410
|
-
<NumberInput step={0.1} max={3} update={update} value={3.555444} />
|
|
411
|
-
</IntlProvider>,
|
|
412
|
-
"when mounted",
|
|
413
|
-
"with event",
|
|
414
|
-
{ type: "click", target: '[data-test-id="down"]' },
|
|
415
|
-
).then(() => expect(update, "to have calls satisfying", [{ args: [3.5] }])));
|
|
416
|
-
});
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
describe("roundToStep", () => {
|
|
420
|
-
it("rounds a number up to the nearest step", () =>
|
|
421
|
-
expect(roundToStep, "when called with", [103.271, 0.1], "to equal", 103.3));
|
|
422
|
-
|
|
423
|
-
it("rounds a number down to the nearest step", () =>
|
|
424
|
-
expect(roundToStep, "when called with", [103.231, 0.1], "to equal", 103.2));
|
|
425
|
-
|
|
426
|
-
it("works for steps > 1", () => expect(roundToStep, "when called with", [12343, 10], "to equal", 12340));
|
|
427
|
-
|
|
428
|
-
it("can round off 0", () => expect(roundToStep, "when called with", [0, 0.1], "to equal", 0));
|
|
429
|
-
|
|
430
|
-
it("returns empty string if given not a number to round off", () =>
|
|
431
|
-
expect(roundToStep, "when called with", ["foo", 0.1], "to equal", ""));
|
|
432
|
-
|
|
433
|
-
it("returns empty string if given not a number as step", () =>
|
|
434
|
-
expect(roundToStep, "when called with", [10, "foo"], "to equal", ""));
|
|
435
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import styled from "styled-components";
|
|
3
|
-
import Button from "../../Button";
|
|
4
|
-
import Icon from "../../Icon";
|
|
5
|
-
import Tooltip from "../../Tooltip";
|
|
6
|
-
import withId from "../../../hocs/withId";
|
|
7
|
-
|
|
8
|
-
export const RoundButton = styled(Button)`
|
|
9
|
-
min-width: 0;
|
|
10
|
-
min-height: 0;
|
|
11
|
-
width: 30px;
|
|
12
|
-
height: 30px;
|
|
13
|
-
border-radius: 50%;
|
|
14
|
-
padding: 6px;
|
|
15
|
-
position: relative;
|
|
16
|
-
`;
|
|
17
|
-
|
|
18
|
-
export const ButtonIcon = styled(Icon)`
|
|
19
|
-
font-size: 16px;
|
|
20
|
-
`;
|
|
21
|
-
|
|
22
|
-
export const SmallButton = ({
|
|
23
|
-
id,
|
|
24
|
-
icon,
|
|
25
|
-
update,
|
|
26
|
-
"aria-labelledby": aria, // Not meaningful for buttons
|
|
27
|
-
altText = "[altText]", // If you do not provide alt-text, you will be hainted unto death.
|
|
28
|
-
...props
|
|
29
|
-
}) => (
|
|
30
|
-
<RoundButton id={id} {...props} onClick={update}>
|
|
31
|
-
<ButtonIcon id={icon} />
|
|
32
|
-
<Tooltip message={altText} />
|
|
33
|
-
</RoundButton>
|
|
34
|
-
);
|
|
35
|
-
SmallButton.displayName = "SmallButton";
|
|
36
|
-
|
|
37
|
-
export default withId("smallbutton")(SmallButton);
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Provider } from "react-redux";
|
|
3
|
-
import Tooltip from "../../Tooltip";
|
|
4
|
-
import { SmallButton, RoundButton, ButtonIcon } from "./SmallButton";
|
|
5
|
-
|
|
6
|
-
describe("SmallButton", () => {
|
|
7
|
-
let update;
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
update = () => {};
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("renders a small button showing an icon", () =>
|
|
13
|
-
expect(
|
|
14
|
-
<Provider
|
|
15
|
-
store={{
|
|
16
|
-
subscribe: () => {},
|
|
17
|
-
dispatch: () => {},
|
|
18
|
-
getState: () => ({}),
|
|
19
|
-
}}
|
|
20
|
-
>
|
|
21
|
-
<SmallButton id="testId" update={update} icon="test-icon" altText="Alternative" otherProp />
|
|
22
|
-
</Provider>,
|
|
23
|
-
"when mounted",
|
|
24
|
-
"to satisfy",
|
|
25
|
-
<Provider
|
|
26
|
-
store={{
|
|
27
|
-
subscribe: () => {},
|
|
28
|
-
dispatch: () => {},
|
|
29
|
-
getState: () => ({}),
|
|
30
|
-
}}
|
|
31
|
-
>
|
|
32
|
-
<RoundButton id="testId" otherProp onClick={update}>
|
|
33
|
-
<ButtonIcon id="test-icon" />
|
|
34
|
-
<Tooltip message="Alternative" />
|
|
35
|
-
</RoundButton>
|
|
36
|
-
</Provider>,
|
|
37
|
-
));
|
|
38
|
-
|
|
39
|
-
it("adds an ugly default alt text if none given, shaming the dev", () =>
|
|
40
|
-
expect(
|
|
41
|
-
<Provider
|
|
42
|
-
store={{
|
|
43
|
-
subscribe: () => {},
|
|
44
|
-
dispatch: () => {},
|
|
45
|
-
getState: () => ({}),
|
|
46
|
-
}}
|
|
47
|
-
>
|
|
48
|
-
<SmallButton id="testId" icon="test-icon" />
|
|
49
|
-
</Provider>,
|
|
50
|
-
"when mounted",
|
|
51
|
-
"to satisfy",
|
|
52
|
-
<Provider
|
|
53
|
-
store={{
|
|
54
|
-
subscribe: () => {},
|
|
55
|
-
dispatch: () => {},
|
|
56
|
-
getState: () => ({}),
|
|
57
|
-
}}
|
|
58
|
-
>
|
|
59
|
-
<RoundButton id="testId">
|
|
60
|
-
<ButtonIcon id="test-icon" />
|
|
61
|
-
<Tooltip message="[altText]" />
|
|
62
|
-
</RoundButton>
|
|
63
|
-
</Provider>,
|
|
64
|
-
));
|
|
65
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import styled from "styled-components";
|
|
3
|
-
import { getThemeProp } from "../../../utils";
|
|
4
|
-
import Icon from "../../Icon";
|
|
5
|
-
import { FormInput, getEventUpdater } from "./Text";
|
|
6
|
-
import { ButtonWrapper, InputButton } from "./FieldButtons";
|
|
7
|
-
|
|
8
|
-
// TODO: Time dialog on focus, prevent default behavior in Edge, Firefox
|
|
9
|
-
|
|
10
|
-
export const TimeIcon = styled(Icon).attrs(props => ({
|
|
11
|
-
id: getThemeProp(["icons", "time"], "clock")(props),
|
|
12
|
-
}))`
|
|
13
|
-
font-size: 20px;
|
|
14
|
-
`;
|
|
15
|
-
|
|
16
|
-
export const TimeButton = styled(InputButton)`
|
|
17
|
-
margin-top: -1px;
|
|
18
|
-
margin-right: -1px;
|
|
19
|
-
min-width: 36px;
|
|
20
|
-
padding: 4px 7px;
|
|
21
|
-
border-left-color: transparent;
|
|
22
|
-
background-color: #fff;
|
|
23
|
-
`;
|
|
24
|
-
|
|
25
|
-
export const TimeInput = ({ update, required, value, ...props }) => (
|
|
26
|
-
<ButtonWrapper invalid={required && !value}>
|
|
27
|
-
<FormInput type="time" onChange={getEventUpdater(update)} value={value} {...props} />
|
|
28
|
-
<TimeButton>
|
|
29
|
-
<TimeIcon />
|
|
30
|
-
</TimeButton>
|
|
31
|
-
</ButtonWrapper>
|
|
32
|
-
);
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { IntlProvider } from "react-intl";
|
|
3
|
-
import { ButtonWrapper } from "./FieldButtons";
|
|
4
|
-
import { FormInput } from "./Text";
|
|
5
|
-
import { TimeInput, TimeIcon, TimeButton } from "./Time";
|
|
6
|
-
|
|
7
|
-
describe("TimeInput", () => {
|
|
8
|
-
it("renders a basic time input, preliminary", () =>
|
|
9
|
-
expect(
|
|
10
|
-
<IntlProvider locale="en">
|
|
11
|
-
<TimeInput update={() => {}} otherProp />
|
|
12
|
-
</IntlProvider>,
|
|
13
|
-
"when mounted",
|
|
14
|
-
"to satisfy",
|
|
15
|
-
<ButtonWrapper>
|
|
16
|
-
<IntlProvider locale="en">
|
|
17
|
-
<FormInput type="time" onChange={expect.it("to be a function")} otherProp />
|
|
18
|
-
</IntlProvider>
|
|
19
|
-
<TimeButton>
|
|
20
|
-
<TimeIcon />
|
|
21
|
-
</TimeButton>
|
|
22
|
-
</ButtonWrapper>,
|
|
23
|
-
));
|
|
24
|
-
|
|
25
|
-
it("renders a required time input with invalid value", () =>
|
|
26
|
-
expect(
|
|
27
|
-
<IntlProvider locale="en">
|
|
28
|
-
<TimeInput update={() => {}} otherProp required />
|
|
29
|
-
</IntlProvider>,
|
|
30
|
-
"when mounted",
|
|
31
|
-
"to satisfy",
|
|
32
|
-
<ButtonWrapper invalid>
|
|
33
|
-
<IntlProvider locale="en">
|
|
34
|
-
<FormInput type="time" onChange={expect.it("to be a function")} otherProp />
|
|
35
|
-
</IntlProvider>
|
|
36
|
-
<TimeButton>
|
|
37
|
-
<TimeIcon />
|
|
38
|
-
</TimeButton>
|
|
39
|
-
</ButtonWrapper>,
|
|
40
|
-
));
|
|
41
|
-
});
|