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,21 +1,24 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import Immutable from "immutable";
|
|
3
|
-
import { Provider } from "react-redux";
|
|
4
3
|
import { getDefaultLocale } from "react-datepicker";
|
|
5
|
-
import Culture from "./Culture";
|
|
4
|
+
import Culture, { customFnsLocale } from "./Culture";
|
|
5
|
+
import { extractMessages, TestWrapper } from "../utils/testUtils";
|
|
6
|
+
import sharedMessages from "../sharedMessages";
|
|
7
|
+
import { mount } from "enzyme";
|
|
8
|
+
|
|
9
|
+
const messages = extractMessages(sharedMessages);
|
|
6
10
|
|
|
7
11
|
describe("Culture", () => {
|
|
8
|
-
let state, store
|
|
12
|
+
let state, store;
|
|
9
13
|
|
|
10
14
|
beforeEach(() => {
|
|
11
|
-
languageGetter = jest.spyOn(window.navigator, "language", "get");
|
|
12
|
-
|
|
13
15
|
state = Immutable.fromJS({
|
|
14
16
|
requests: {},
|
|
15
17
|
settings: {
|
|
16
18
|
defaultScope: "aDefaultScope",
|
|
17
19
|
},
|
|
18
20
|
locale: {
|
|
21
|
+
locale: "en-US",
|
|
19
22
|
supportedLocales: [
|
|
20
23
|
{ language: "English", cultureIso: "en" },
|
|
21
24
|
{ language: "Français", cultureIso: "fr" },
|
|
@@ -30,17 +33,14 @@ describe("Culture", () => {
|
|
|
30
33
|
});
|
|
31
34
|
|
|
32
35
|
afterEach(() => {
|
|
33
|
-
languageGetter.mockReset();
|
|
34
36
|
jest.clearAllMocks();
|
|
35
37
|
});
|
|
36
38
|
|
|
37
39
|
it("shows the wrapped component if authenticated and default scope is known", () => {
|
|
38
|
-
languageGetter.mockReturnValue(null);
|
|
39
|
-
|
|
40
40
|
const component = (
|
|
41
|
-
<
|
|
41
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages, locale: "zz-ZZ" }}>
|
|
42
42
|
<Culture />
|
|
43
|
-
</
|
|
43
|
+
</TestWrapper>
|
|
44
44
|
);
|
|
45
45
|
|
|
46
46
|
expect(component, "when mounted", "to satisfy", null);
|
|
@@ -50,12 +50,11 @@ describe("Culture", () => {
|
|
|
50
50
|
|
|
51
51
|
it("shows the wrapped component if authenticated and default scope is known 222", () => {
|
|
52
52
|
state = state.setIn(["locale", "supportedLocales"], [{ language: "English", cultureIso: "en" }]);
|
|
53
|
-
languageGetter.mockReturnValue("en-GB");
|
|
54
53
|
|
|
55
54
|
const component = (
|
|
56
|
-
<
|
|
55
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages, locale: "en-GB" }}>
|
|
57
56
|
<Culture />
|
|
58
|
-
</
|
|
57
|
+
</TestWrapper>
|
|
59
58
|
);
|
|
60
59
|
|
|
61
60
|
expect(component, "when mounted", "to satisfy", null);
|
|
@@ -71,16 +70,28 @@ describe("Culture", () => {
|
|
|
71
70
|
{ language: "EnglishMy", cultureIso: "enMy" },
|
|
72
71
|
],
|
|
73
72
|
);
|
|
74
|
-
languageGetter.mockReturnValue("fr-FR");
|
|
75
73
|
|
|
76
74
|
const component = (
|
|
77
|
-
<
|
|
75
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages, locale: "fr-FR" }}>
|
|
78
76
|
<Culture />
|
|
79
|
-
</
|
|
77
|
+
</TestWrapper>
|
|
80
78
|
);
|
|
81
79
|
|
|
82
80
|
expect(component, "when mounted", "to satisfy", null);
|
|
83
81
|
|
|
84
82
|
expect(getDefaultLocale(), "to equal", "fr-FR");
|
|
85
83
|
});
|
|
84
|
+
|
|
85
|
+
it("computes right localized day and month with Italian culture ", () => {
|
|
86
|
+
const component = (
|
|
87
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages, locale: "it-IT" }}>
|
|
88
|
+
<Culture />
|
|
89
|
+
</TestWrapper>
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
mount(component);
|
|
93
|
+
|
|
94
|
+
expect(customFnsLocale.localize.day(1), "to equal", "Mo");
|
|
95
|
+
expect(customFnsLocale.localize.month(6), "to equal", "July");
|
|
96
|
+
});
|
|
86
97
|
});
|
|
@@ -3,53 +3,59 @@ import ReactDOM from "react-dom";
|
|
|
3
3
|
import { Provider } from "react-redux";
|
|
4
4
|
import { act } from "react-dom/test-utils";
|
|
5
5
|
import sinon from "sinon";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<div id={id} data-open={open}>
|
|
12
|
-
Test anchor
|
|
13
|
-
</div>
|
|
14
|
-
);
|
|
6
|
+
import { StylesProvider } from "@material-ui/core";
|
|
7
|
+
import { generateClassName } from "../../utils/testUtils";
|
|
8
|
+
import DropMenu, { Wrapper } from "./index";
|
|
9
|
+
import Menu from "./Menu";
|
|
10
|
+
import Icon from "../MaterialUI/DataDisplay/Icon";
|
|
15
11
|
|
|
16
12
|
describe("DropMenu", () => {
|
|
17
13
|
it("renders an anchor and a menu", () =>
|
|
18
14
|
expect(
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
16
|
+
<DropMenu id="test" menuItems={[]} className="test-class">
|
|
17
|
+
TestLabel
|
|
18
|
+
</DropMenu>
|
|
19
|
+
</StylesProvider>,
|
|
22
20
|
"when mounted",
|
|
23
21
|
"to satisfy",
|
|
24
|
-
<
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
23
|
+
<Wrapper className="test-class">
|
|
24
|
+
<div id="testAnchor">TestLabel</div>
|
|
25
|
+
<Menu id="testDropdown" menuItems={[]} />
|
|
26
|
+
</Wrapper>
|
|
27
|
+
</StylesProvider>,
|
|
28
28
|
));
|
|
29
29
|
|
|
30
30
|
it("flags anchor and menu when open", () =>
|
|
31
31
|
expect(
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
33
|
+
<DropMenu id="test" initOpen menuItems={[]}>
|
|
34
|
+
TestLabel
|
|
35
|
+
</DropMenu>
|
|
36
|
+
</StylesProvider>,
|
|
35
37
|
"when mounted",
|
|
36
38
|
"to satisfy",
|
|
37
|
-
<
|
|
38
|
-
<
|
|
39
|
-
TestLabel
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
</
|
|
39
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
40
|
+
<Wrapper>
|
|
41
|
+
<div id="testAnchor">TestLabel</div>
|
|
42
|
+
<Menu id="testDropdown" menuItems={[]} open />
|
|
43
|
+
</Wrapper>
|
|
44
|
+
</StylesProvider>,
|
|
43
45
|
));
|
|
44
46
|
|
|
45
47
|
it("renders a right-aligned menu on demand", () =>
|
|
46
48
|
expect(
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
50
|
+
<DropMenu id="test" initOpen menuItems={[]} alignRight>
|
|
51
|
+
TestLabel
|
|
52
|
+
</DropMenu>
|
|
53
|
+
</StylesProvider>,
|
|
50
54
|
"when mounted",
|
|
51
55
|
"to contain",
|
|
52
|
-
<
|
|
56
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
57
|
+
<Menu id="testDropdown" open menuItems={[]} alignRight />
|
|
58
|
+
</StylesProvider>,
|
|
53
59
|
));
|
|
54
60
|
|
|
55
61
|
it("when clicked renders the menu", () =>
|
|
@@ -71,21 +77,19 @@ describe("DropMenu", () => {
|
|
|
71
77
|
{ type: "click", target: "#testAnchor" },
|
|
72
78
|
"to satisfy",
|
|
73
79
|
<Wrapper className="test-class">
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
<Item>
|
|
80
|
-
<ItemIcon id="one" />
|
|
80
|
+
<div id="testAnchor">TestLabel</div>
|
|
81
|
+
<div className="enter-active">
|
|
82
|
+
<ul id="testDropdown">
|
|
83
|
+
<li>
|
|
84
|
+
<Icon id="one" />
|
|
81
85
|
First
|
|
82
|
-
</
|
|
83
|
-
<
|
|
84
|
-
<
|
|
86
|
+
</li>
|
|
87
|
+
<li>
|
|
88
|
+
<Icon id="two" />
|
|
85
89
|
Second
|
|
86
|
-
</
|
|
87
|
-
</
|
|
88
|
-
</
|
|
90
|
+
</li>
|
|
91
|
+
</ul>
|
|
92
|
+
</div>
|
|
89
93
|
</Wrapper>,
|
|
90
94
|
));
|
|
91
95
|
|
|
@@ -94,7 +98,7 @@ describe("DropMenu", () => {
|
|
|
94
98
|
const menuNode = document.createElement("div");
|
|
95
99
|
document.body.appendChild(menuNode);
|
|
96
100
|
// eslint-disable-next-line react/no-render-return-value
|
|
97
|
-
|
|
101
|
+
ReactDOM.render(
|
|
98
102
|
<div>
|
|
99
103
|
<div id="outside" />
|
|
100
104
|
<Provider store={{ getState: () => ({}), subscribe: () => {}, dispatch: () => {} }}>
|
|
@@ -104,7 +108,6 @@ describe("DropMenu", () => {
|
|
|
104
108
|
{ label: "First", icon: "one", handler: () => {} },
|
|
105
109
|
{ label: "Second", icon: "two", handler: () => {} },
|
|
106
110
|
]}
|
|
107
|
-
className="test-class"
|
|
108
111
|
>
|
|
109
112
|
TestLabel
|
|
110
113
|
</DropMenu>
|
|
@@ -114,26 +117,25 @@ describe("DropMenu", () => {
|
|
|
114
117
|
);
|
|
115
118
|
const anchor = menuNode.querySelector("#testAnchor");
|
|
116
119
|
const outside = menuNode.querySelector("div#outside");
|
|
120
|
+
const menuWrapper = menuNode.querySelector("div.exit-active");
|
|
117
121
|
try {
|
|
118
|
-
expect(
|
|
122
|
+
expect(menuWrapper, "to have attributes", {
|
|
123
|
+
class: expect.it("to contain", "exit-active"),
|
|
124
|
+
});
|
|
119
125
|
act(() => {
|
|
120
126
|
anchor.click();
|
|
127
|
+
clock.tick(1000);
|
|
128
|
+
});
|
|
129
|
+
expect(menuWrapper, "to have attributes", {
|
|
130
|
+
class: expect.it("to contain", "enter-active"),
|
|
121
131
|
});
|
|
122
|
-
expect(menu, "to contain elements matching", getStyledClassSelector(List));
|
|
123
132
|
act(() => {
|
|
124
133
|
outside.click();
|
|
134
|
+
clock.tick(1000);
|
|
125
135
|
});
|
|
126
|
-
expect(
|
|
127
|
-
|
|
128
|
-
"to contain",
|
|
129
|
-
<AnchorWrapper id="testAnchor" open={false}>
|
|
130
|
-
TestLabel
|
|
131
|
-
</AnchorWrapper>,
|
|
132
|
-
);
|
|
133
|
-
act(() => {
|
|
134
|
-
clock.tick(1000); // Wait for the menu to unrender
|
|
136
|
+
expect(menuWrapper, "to have attributes", {
|
|
137
|
+
class: expect.it("to contain", "exit-active"),
|
|
135
138
|
});
|
|
136
|
-
expect(menu, "not to contain elements matching", getStyledClassSelector(List));
|
|
137
139
|
} finally {
|
|
138
140
|
ReactDOM.unmountComponentAtNode(menuNode);
|
|
139
141
|
document.body.removeChild(menuNode);
|
|
@@ -141,121 +143,6 @@ describe("DropMenu", () => {
|
|
|
141
143
|
}
|
|
142
144
|
});
|
|
143
145
|
|
|
144
|
-
describe("component child", () => {
|
|
145
|
-
it("renders an anchor and a menu", () =>
|
|
146
|
-
expect(
|
|
147
|
-
<DropMenu id="test" menuItems={[]} className="test-class">
|
|
148
|
-
<TestAnchor />
|
|
149
|
-
</DropMenu>,
|
|
150
|
-
"when mounted",
|
|
151
|
-
"to satisfy",
|
|
152
|
-
<Wrapper className="test-class">
|
|
153
|
-
<AnchorWrapper id="testAnchor">
|
|
154
|
-
<TestAnchor open={false} />
|
|
155
|
-
</AnchorWrapper>
|
|
156
|
-
<Menu id="testDropdown" menuItems={[]} />
|
|
157
|
-
</Wrapper>,
|
|
158
|
-
));
|
|
159
|
-
|
|
160
|
-
it("flags children when open", () =>
|
|
161
|
-
expect(
|
|
162
|
-
<DropMenu id="test" initOpen menuItems={[]}>
|
|
163
|
-
<TestAnchor />
|
|
164
|
-
</DropMenu>,
|
|
165
|
-
"when mounted",
|
|
166
|
-
"to satisfy",
|
|
167
|
-
<Wrapper>
|
|
168
|
-
<AnchorWrapper id="testAnchor" open>
|
|
169
|
-
<TestAnchor open />
|
|
170
|
-
</AnchorWrapper>
|
|
171
|
-
<Menu id="testDropdown" open menuItems={[]} />
|
|
172
|
-
</Wrapper>,
|
|
173
|
-
));
|
|
174
|
-
|
|
175
|
-
it("when clicked renders the menu", () =>
|
|
176
|
-
expect(
|
|
177
|
-
<Provider store={{ getState: () => ({}), subscribe: () => {}, dispatch: () => {} }}>
|
|
178
|
-
<DropMenu
|
|
179
|
-
id="test"
|
|
180
|
-
menuItems={[
|
|
181
|
-
{ label: "First", icon: "one", handler: () => {} },
|
|
182
|
-
{ label: "Second", icon: "two", handler: () => {} },
|
|
183
|
-
]}
|
|
184
|
-
className="test-class"
|
|
185
|
-
>
|
|
186
|
-
<TestAnchor />
|
|
187
|
-
</DropMenu>
|
|
188
|
-
</Provider>,
|
|
189
|
-
"when mounted",
|
|
190
|
-
"with event",
|
|
191
|
-
{ type: "click", target: "#testAnchor" },
|
|
192
|
-
"to satisfy",
|
|
193
|
-
<Wrapper>
|
|
194
|
-
<AnchorWrapper id="testAnchor" open>
|
|
195
|
-
<TestAnchor open />
|
|
196
|
-
</AnchorWrapper>
|
|
197
|
-
<Drawer in>
|
|
198
|
-
<List id="testDropdown">
|
|
199
|
-
<Item>
|
|
200
|
-
<ItemIcon id="one" />
|
|
201
|
-
First
|
|
202
|
-
</Item>
|
|
203
|
-
<Item>
|
|
204
|
-
<ItemIcon id="two" />
|
|
205
|
-
Second
|
|
206
|
-
</Item>
|
|
207
|
-
</List>
|
|
208
|
-
</Drawer>
|
|
209
|
-
</Wrapper>,
|
|
210
|
-
));
|
|
211
|
-
|
|
212
|
-
it("closes the menu if clicked outside", () => {
|
|
213
|
-
const clock = sinon.useFakeTimers();
|
|
214
|
-
const menuNode = document.createElement("div");
|
|
215
|
-
document.body.appendChild(menuNode);
|
|
216
|
-
// eslint-disable-next-line react/no-render-return-value
|
|
217
|
-
const menu = ReactDOM.render(
|
|
218
|
-
<div>
|
|
219
|
-
<div id="outside" />
|
|
220
|
-
<Provider store={{ getState: () => ({}), subscribe: () => {}, dispatch: () => {} }}>
|
|
221
|
-
<DropMenu
|
|
222
|
-
id="test"
|
|
223
|
-
menuItems={[
|
|
224
|
-
{ label: "First", icon: "one", handler: () => {} },
|
|
225
|
-
{ label: "Second", icon: "two", handler: () => {} },
|
|
226
|
-
]}
|
|
227
|
-
className="test-class"
|
|
228
|
-
>
|
|
229
|
-
<TestAnchor />
|
|
230
|
-
</DropMenu>
|
|
231
|
-
</Provider>
|
|
232
|
-
</div>,
|
|
233
|
-
menuNode,
|
|
234
|
-
);
|
|
235
|
-
const anchor = menuNode.querySelector("#testAnchor");
|
|
236
|
-
const outside = menuNode.querySelector("div#outside");
|
|
237
|
-
try {
|
|
238
|
-
expect(menu, "not to contain elements matching", getStyledClassSelector(List));
|
|
239
|
-
act(() => {
|
|
240
|
-
anchor.click();
|
|
241
|
-
});
|
|
242
|
-
expect(menu, "to contain elements matching", getStyledClassSelector(List));
|
|
243
|
-
act(() => {
|
|
244
|
-
outside.click();
|
|
245
|
-
});
|
|
246
|
-
expect(menu, "to contain", <TestAnchor />);
|
|
247
|
-
act(() => {
|
|
248
|
-
clock.tick(1000); // Wait for the menu to unrender
|
|
249
|
-
});
|
|
250
|
-
expect(menu, "not to contain elements matching", getStyledClassSelector(List));
|
|
251
|
-
} finally {
|
|
252
|
-
ReactDOM.unmountComponentAtNode(menuNode);
|
|
253
|
-
document.body.removeChild(menuNode);
|
|
254
|
-
clock.restore();
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
|
|
259
146
|
describe("two adjacent, independent menus", () => {
|
|
260
147
|
const MakeMenu = ({ num }) => (
|
|
261
148
|
<DropMenu
|
|
@@ -272,20 +159,48 @@ describe("DropMenu", () => {
|
|
|
272
159
|
|
|
273
160
|
it("renders the anchors", () =>
|
|
274
161
|
expect(
|
|
275
|
-
<
|
|
276
|
-
<
|
|
277
|
-
|
|
278
|
-
|
|
162
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
163
|
+
<div>
|
|
164
|
+
<MakeMenu num="1" />
|
|
165
|
+
<MakeMenu num="2" />
|
|
166
|
+
</div>
|
|
167
|
+
</StylesProvider>,
|
|
279
168
|
"when mounted",
|
|
280
169
|
"to satisfy",
|
|
281
|
-
<
|
|
282
|
-
<
|
|
283
|
-
<
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
170
|
+
<StylesProvider generateClassName={generateClassName}>
|
|
171
|
+
<div>
|
|
172
|
+
<div>
|
|
173
|
+
<div id="menu1Anchor">TestLabel 1</div>
|
|
174
|
+
<div className="exit-active">
|
|
175
|
+
<ul>
|
|
176
|
+
<li>
|
|
177
|
+
<Icon id="one" />
|
|
178
|
+
First
|
|
179
|
+
</li>
|
|
180
|
+
<li>
|
|
181
|
+
<Icon id="two" />
|
|
182
|
+
Second
|
|
183
|
+
</li>
|
|
184
|
+
</ul>
|
|
185
|
+
</div>
|
|
186
|
+
</div>
|
|
187
|
+
<div>
|
|
188
|
+
<div id="menu2Anchor">TestLabel 2</div>
|
|
189
|
+
<div className="exit-active">
|
|
190
|
+
<ul>
|
|
191
|
+
<li>
|
|
192
|
+
<Icon id="one" />
|
|
193
|
+
First
|
|
194
|
+
</li>
|
|
195
|
+
<li>
|
|
196
|
+
<Icon id="two" />
|
|
197
|
+
Second
|
|
198
|
+
</li>
|
|
199
|
+
</ul>
|
|
200
|
+
</div>
|
|
201
|
+
</div>
|
|
202
|
+
</div>
|
|
203
|
+
</StylesProvider>,
|
|
289
204
|
));
|
|
290
205
|
|
|
291
206
|
it("when clicked renders only the clicked menu", () => {
|
|
@@ -307,12 +222,36 @@ describe("DropMenu", () => {
|
|
|
307
222
|
menuNode,
|
|
308
223
|
"to satisfy",
|
|
309
224
|
<div>
|
|
310
|
-
<
|
|
311
|
-
<
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
225
|
+
<div>
|
|
226
|
+
<div id="menu1Anchor">TestLabel 1</div>
|
|
227
|
+
<div className="exit-active">
|
|
228
|
+
<ul>
|
|
229
|
+
<li>
|
|
230
|
+
<Icon id="one" />
|
|
231
|
+
First
|
|
232
|
+
</li>
|
|
233
|
+
<li>
|
|
234
|
+
<Icon id="two" />
|
|
235
|
+
Second
|
|
236
|
+
</li>
|
|
237
|
+
</ul>
|
|
238
|
+
</div>
|
|
239
|
+
</div>
|
|
240
|
+
<div>
|
|
241
|
+
<div id="menu2Anchor">TestLabel 2</div>
|
|
242
|
+
<div className="exit-active">
|
|
243
|
+
<ul>
|
|
244
|
+
<li>
|
|
245
|
+
<Icon id="one" />
|
|
246
|
+
First
|
|
247
|
+
</li>
|
|
248
|
+
<li>
|
|
249
|
+
<Icon id="two" />
|
|
250
|
+
Second
|
|
251
|
+
</li>
|
|
252
|
+
</ul>
|
|
253
|
+
</div>
|
|
254
|
+
</div>
|
|
316
255
|
</div>,
|
|
317
256
|
);
|
|
318
257
|
act(() => {
|
|
@@ -322,54 +261,76 @@ describe("DropMenu", () => {
|
|
|
322
261
|
menuNode,
|
|
323
262
|
"to satisfy",
|
|
324
263
|
<div>
|
|
325
|
-
<
|
|
326
|
-
<
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
264
|
+
<div>
|
|
265
|
+
<div id="menu1Anchor">TestLabel 1</div>
|
|
266
|
+
<div className="exit-active">
|
|
267
|
+
<ul>
|
|
268
|
+
<li>
|
|
269
|
+
<Icon id="one" />
|
|
270
|
+
First
|
|
271
|
+
</li>
|
|
272
|
+
<li>
|
|
273
|
+
<Icon id="two" />
|
|
274
|
+
Second
|
|
275
|
+
</li>
|
|
276
|
+
</ul>
|
|
277
|
+
</div>
|
|
278
|
+
</div>
|
|
279
|
+
<div>
|
|
280
|
+
<div id="menu2Anchor">TestLabel 2</div>
|
|
281
|
+
<div className="enter-active">
|
|
282
|
+
<ul>
|
|
283
|
+
<li>
|
|
284
|
+
<Icon id="one" />
|
|
334
285
|
First
|
|
335
|
-
</
|
|
336
|
-
<
|
|
337
|
-
<
|
|
286
|
+
</li>
|
|
287
|
+
<li>
|
|
288
|
+
<Icon id="two" />
|
|
338
289
|
Second
|
|
339
|
-
</
|
|
340
|
-
</
|
|
341
|
-
</
|
|
342
|
-
</
|
|
290
|
+
</li>
|
|
291
|
+
</ul>
|
|
292
|
+
</div>
|
|
293
|
+
</div>
|
|
343
294
|
</div>,
|
|
344
295
|
);
|
|
345
296
|
act(() => {
|
|
346
297
|
anchor1.click();
|
|
347
|
-
|
|
348
|
-
act(() => {
|
|
349
|
-
clock.tick(1000); // Wait for the previous menu to unrender
|
|
298
|
+
clock.tick(1000);
|
|
350
299
|
});
|
|
351
300
|
expect(
|
|
352
301
|
menuNode,
|
|
353
302
|
"to satisfy",
|
|
354
303
|
<div>
|
|
355
|
-
<
|
|
356
|
-
<
|
|
357
|
-
<
|
|
358
|
-
<
|
|
359
|
-
<
|
|
360
|
-
<
|
|
304
|
+
<div>
|
|
305
|
+
<div id="menu1Anchor">TestLabel 1</div>
|
|
306
|
+
<div className="enter-active">
|
|
307
|
+
<ul>
|
|
308
|
+
<li>
|
|
309
|
+
<Icon id="one" />
|
|
310
|
+
First
|
|
311
|
+
</li>
|
|
312
|
+
<li>
|
|
313
|
+
<Icon id="two" />
|
|
314
|
+
Second
|
|
315
|
+
</li>
|
|
316
|
+
</ul>
|
|
317
|
+
</div>
|
|
318
|
+
</div>
|
|
319
|
+
<div>
|
|
320
|
+
<div id="menu2Anchor">TestLabel 2</div>
|
|
321
|
+
<div className="exit-active">
|
|
322
|
+
<ul>
|
|
323
|
+
<li>
|
|
324
|
+
<Icon id="one" />
|
|
361
325
|
First
|
|
362
|
-
</
|
|
363
|
-
<
|
|
364
|
-
<
|
|
326
|
+
</li>
|
|
327
|
+
<li>
|
|
328
|
+
<Icon id="two" />
|
|
365
329
|
Second
|
|
366
|
-
</
|
|
367
|
-
</
|
|
368
|
-
</
|
|
369
|
-
</
|
|
370
|
-
<Wrapper className="test-class-2">
|
|
371
|
-
<AnchorWrapper>TestLabel 2</AnchorWrapper>
|
|
372
|
-
</Wrapper>
|
|
330
|
+
</li>
|
|
331
|
+
</ul>
|
|
332
|
+
</div>
|
|
333
|
+
</div>
|
|
373
334
|
</div>,
|
|
374
335
|
);
|
|
375
336
|
});
|