orc-shared 5.10.1-dev.7 → 5.10.1-dev.9

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.
Files changed (133) hide show
  1. package/dist/components/Authenticate.js +41 -17
  2. package/dist/components/ErrorPlaceholder.js +8 -24
  3. package/dist/components/{Icon.js → Form/Inputs/MultiSelector.js} +33 -20
  4. package/dist/components/Form/Inputs/index.js +1 -1
  5. package/dist/components/LoadingIcon.js +6 -16
  6. package/dist/components/MaterialUI/Inputs/Select.js +10 -0
  7. package/dist/components/MaterialUI/Inputs/SelectProps.js +3 -1
  8. package/dist/components/MaterialUI/Navigation/DropDownMenu.js +2 -4
  9. package/dist/components/Provision.js +30 -13
  10. package/dist/components/Routing/SegmentPage.js +115 -56
  11. package/dist/components/Scope/ScopeNode.js +68 -45
  12. package/dist/components/Sidepanel.js +57 -23
  13. package/dist/components/Spritesheet.js +33 -17
  14. package/dist/components/Text.js +1 -60
  15. package/dist/components/Treeview/Branch.js +82 -20
  16. package/dist/components/Treeview/Label.js +108 -31
  17. package/dist/components/Treeview/Leaf.js +56 -12
  18. package/dist/components/Treeview/Node.js +22 -9
  19. package/dist/components/Treeview/index.js +7 -1
  20. package/dist/components/Treeview/settings.js +7 -5
  21. package/dist/utils/index.js +0 -4
  22. package/dist/utils/testUtils.js +1 -12
  23. package/package.json +1 -1
  24. package/src/components/ApplicationModuleLoader.test.js +14 -27
  25. package/src/components/Authenticate.js +29 -21
  26. package/src/components/Authenticate.test.js +18 -27
  27. package/src/components/ErrorPlaceholder.js +4 -21
  28. package/src/components/ErrorPlaceholder.test.js +7 -14
  29. package/src/components/Form/InputField.test.js +2 -1
  30. package/src/components/Form/Inputs/MultiSelector.js +23 -0
  31. package/src/components/Form/Inputs/MultiSelector.test.js +112 -0
  32. package/src/components/Form/Inputs/index.js +1 -1
  33. package/src/components/Loader.test.js +21 -33
  34. package/src/components/LoadingIcon.js +2 -15
  35. package/src/components/LoadingIcon.test.js +2 -20
  36. package/src/components/MaterialUI/DataDisplay/Table.test.js +1 -1
  37. package/src/components/MaterialUI/Inputs/Select.js +7 -0
  38. package/src/components/MaterialUI/Inputs/Select.test.js +45 -0
  39. package/src/components/MaterialUI/Inputs/SelectProps.js +2 -0
  40. package/src/components/MaterialUI/Inputs/SelectProps.test.js +2 -0
  41. package/src/components/MaterialUI/Navigation/DropDownMenu.js +2 -2
  42. package/src/components/MaterialUI/Navigation/DropDownMenu.test.js +5 -6
  43. package/src/components/Navigation/Navigation.test.js +0 -5
  44. package/src/components/Navigation/useNavigationState.test.js +79 -222
  45. package/src/components/Provision.js +36 -42
  46. package/src/components/Provision.test.js +10 -26
  47. package/src/components/Routing/SegmentPage.js +68 -52
  48. package/src/components/Routing/SegmentPage.test.js +4 -12
  49. package/src/components/Scope/ScopeNode.js +61 -54
  50. package/src/components/Scope/ScopeNode.test.js +61 -154
  51. package/src/components/ScopeExtendedConfigurationLoader.test.js +1 -4
  52. package/src/components/Sidepanel.js +38 -32
  53. package/src/components/Sidepanel.test.js +49 -27
  54. package/src/components/Spritesheet.js +23 -21
  55. package/src/components/Spritesheet.test.js +10 -10
  56. package/src/components/Text.js +0 -49
  57. package/src/components/Treeview/Branch.js +63 -45
  58. package/src/components/Treeview/Branch.test.js +21 -24
  59. package/src/components/Treeview/Label.js +66 -52
  60. package/src/components/Treeview/Label.test.js +42 -60
  61. package/src/components/Treeview/Leaf.js +41 -22
  62. package/src/components/Treeview/Leaf.test.js +15 -10
  63. package/src/components/Treeview/Node.js +16 -9
  64. package/src/components/Treeview/Node.test.js +269 -200
  65. package/src/components/Treeview/Treeview.test.js +248 -248
  66. package/src/components/Treeview/index.js +6 -0
  67. package/src/components/Treeview/settings.js +7 -6
  68. package/src/utils/index.js +0 -4
  69. package/src/utils/testUtils.js +0 -10
  70. package/src/utils/testUtils.test.js +0 -68
  71. package/dist/components/Button.js +0 -70
  72. package/dist/components/Checkbox.js +0 -103
  73. package/dist/components/IconButton.js +0 -80
  74. package/dist/components/Input.js +0 -101
  75. package/dist/components/Modal/Background.js +0 -55
  76. package/dist/components/Modal/Dialog.js +0 -75
  77. package/dist/components/Modal/Wrapper.js +0 -69
  78. package/dist/components/Modal/index.js +0 -86
  79. package/dist/components/MultiSelector.js +0 -187
  80. package/dist/components/Navigation/Bar.js +0 -293
  81. package/dist/components/Navigation/Tab.js +0 -182
  82. package/dist/components/Placeholder.js +0 -114
  83. package/dist/components/Scope/Selector.js +0 -123
  84. package/dist/components/Selector.js +0 -185
  85. package/dist/components/Switch.js +0 -128
  86. package/dist/components/Toolbar.js +0 -227
  87. package/dist/components/Tooltip.js +0 -66
  88. package/dist/getTheme.js +0 -153
  89. package/dist/getThemeOverrides.js +0 -93
  90. package/dist/hocs/withAuthentication.js +0 -72
  91. package/dist/utils/styledPropFuncs.js +0 -88
  92. package/src/components/Button.js +0 -90
  93. package/src/components/Button.test.js +0 -49
  94. package/src/components/Checkbox.js +0 -63
  95. package/src/components/Checkbox.test.js +0 -122
  96. package/src/components/Icon.js +0 -18
  97. package/src/components/IconButton.js +0 -30
  98. package/src/components/IconButton.test.js +0 -61
  99. package/src/components/Input.js +0 -35
  100. package/src/components/Input.test.js +0 -34
  101. package/src/components/Modal/Background.js +0 -10
  102. package/src/components/Modal/Dialog.js +0 -27
  103. package/src/components/Modal/Dialog.test.js +0 -20
  104. package/src/components/Modal/Modal.test.js +0 -52
  105. package/src/components/Modal/Wrapper.js +0 -32
  106. package/src/components/Modal/Wrapper.test.js +0 -55
  107. package/src/components/Modal/index.js +0 -22
  108. package/src/components/MultiSelector.js +0 -104
  109. package/src/components/MultiSelector.test.js +0 -348
  110. package/src/components/Navigation/Bar.js +0 -212
  111. package/src/components/Navigation/Bar.test.js +0 -552
  112. package/src/components/Navigation/Tab.js +0 -156
  113. package/src/components/Navigation/Tab.test.js +0 -404
  114. package/src/components/Placeholder.js +0 -61
  115. package/src/components/Placeholder.test.js +0 -106
  116. package/src/components/Scope/Selector.js +0 -70
  117. package/src/components/Scope/Selector.test.js +0 -138
  118. package/src/components/Selector.js +0 -191
  119. package/src/components/Selector.test.js +0 -157
  120. package/src/components/Switch.js +0 -112
  121. package/src/components/Switch.test.js +0 -130
  122. package/src/components/Text.test.js +0 -132
  123. package/src/components/Toolbar.js +0 -178
  124. package/src/components/Toolbar.test.js +0 -478
  125. package/src/components/Tooltip.js +0 -51
  126. package/src/components/Tooltip.test.js +0 -21
  127. package/src/getTheme.js +0 -98
  128. package/src/getTheme.test.js +0 -92
  129. package/src/getThemeOverrides.js +0 -27
  130. package/src/hocs/withAuthentication.js +0 -18
  131. package/src/hocs/withAuthentication.test.js +0 -120
  132. package/src/utils/styledPropFuncs.js +0 -20
  133. package/src/utils/styledPropFuncs.test.js +0 -166
@@ -1,52 +0,0 @@
1
- import React, { Fragment } from "react";
2
- import ReactDOM from "react-dom";
3
- import { Modal } from "./index";
4
- import Wrapper from "./Wrapper";
5
- import Background from "./Background";
6
- import Dialog from "./Dialog";
7
-
8
- const TestComp1 = () => <div />;
9
- const TestComp2 = () => <div />;
10
-
11
- describe("Modal", () => {
12
- let appRoot, modalRoot, toggle;
13
- beforeEach(() => {
14
- appRoot = document.createElement("div");
15
- appRoot.id = "app";
16
- document.body.appendChild(appRoot);
17
- modalRoot = document.createElement("div");
18
- modalRoot.id = "modal";
19
- document.body.appendChild(modalRoot);
20
- toggle = () => {};
21
- });
22
- afterEach(() => {
23
- try {
24
- ReactDOM.unmountComponentAtNode(appRoot);
25
- } catch {
26
- // don't do anything
27
- }
28
- document.body.removeChild(appRoot);
29
- document.body.removeChild(modalRoot);
30
- });
31
-
32
- it("renders the structure of a modal dialog", () =>
33
- expect(
34
- <Modal
35
- initShow={true}
36
- anchor={toggle => <TestComp1 toggle={toggle} />}
37
- content={toggle => <TestComp2 toggle={toggle} />}
38
- look="dark"
39
- />,
40
- "when mounted",
41
- "to satisfy",
42
- <Fragment>
43
- <TestComp1 toggle={toggle} />
44
- <Wrapper timeout={300}>
45
- <Background />
46
- <Dialog look="dark" onClickOutside={toggle}>
47
- <TestComp2 toggle={toggle} />
48
- </Dialog>
49
- </Wrapper>
50
- </Fragment>,
51
- ));
52
- });
@@ -1,32 +0,0 @@
1
- import React from "react";
2
- import ReactDOM from "react-dom";
3
- import transition from "styled-transition-group";
4
-
5
- const getModalRoot = () => document.getElementById("modal");
6
-
7
- export const Wrapper = transition.div`
8
- z-index: 9999;
9
- display: flex;
10
- position: absolute;
11
- top: 0;
12
- left: 0;
13
- bottom: 0;
14
- right: 0;
15
- transition: opacity ${props => props.timeout}ms ease-out;
16
-
17
- &:enter {
18
- opacity: 0.01;
19
- }
20
- &:enter-active {
21
- opacity: 1;
22
- }
23
- &:exit {
24
- opacity: 1;
25
- }
26
- &:exit-active {
27
- opacity: 0.01;
28
- }
29
- `;
30
- Wrapper.defaultProps = { timeout: 300, unmountOnExit: true };
31
-
32
- export default props => ReactDOM.createPortal(<Wrapper {...props} />, getModalRoot());
@@ -1,55 +0,0 @@
1
- import React from "react";
2
- import ReactDOM from "react-dom";
3
- import PortalWrapper, { Wrapper } from "./Wrapper";
4
-
5
- class RenderWrapper extends React.Component {
6
- render() {
7
- return (
8
- <div id="outer">
9
- <PortalWrapper {...this.props} />
10
- </div>
11
- );
12
- }
13
- }
14
-
15
- describe("Wrapper", () => {
16
- it("sets transition time according to its timeout", () =>
17
- expect(
18
- <Wrapper in timeout={500} />,
19
- "when mounted",
20
- "to have style rules satisfying",
21
- "to contain",
22
- "transition: opacity 500ms ease-out;",
23
- ));
24
-
25
- describe("rendered in portal", () => {
26
- let appRoot, modalRoot;
27
- beforeEach(() => {
28
- appRoot = document.createElement("div");
29
- appRoot.id = "app";
30
- document.body.appendChild(appRoot);
31
- modalRoot = document.createElement("div");
32
- modalRoot.id = "modal";
33
- document.body.appendChild(modalRoot);
34
- });
35
- afterEach(() => {
36
- try {
37
- ReactDOM.unmountComponentAtNode(appRoot);
38
- } catch {
39
- // don't do anything
40
- }
41
- document.body.removeChild(appRoot);
42
- document.body.removeChild(modalRoot);
43
- });
44
-
45
- it("renders a Wrapper in a portal", () => {
46
- ReactDOM.render(
47
- <RenderWrapper in>
48
- <div id="inner">Foo</div>
49
- </RenderWrapper>,
50
- appRoot,
51
- );
52
- return expect(modalRoot, "queried for first", "#inner", "to satisfy", <div>Foo</div>);
53
- });
54
- });
55
- });
@@ -1,22 +0,0 @@
1
- import React, { Fragment } from "react";
2
- import Wrapper from "./Wrapper";
3
- import Background from "./Background";
4
- import Dialog from "./Dialog";
5
- import useToggle from "../../hooks/useToggle";
6
-
7
- export const Modal = ({ initShow, anchor, content, look }) => {
8
- const [show, toggle] = useToggle(initShow);
9
- return (
10
- <Fragment>
11
- {anchor(toggle)}
12
- <Wrapper in={show} timeout={300}>
13
- <Background />
14
- <Dialog look={look} onClickOutside={toggle}>
15
- {content(toggle)}
16
- </Dialog>
17
- </Wrapper>
18
- </Fragment>
19
- );
20
- };
21
-
22
- export default Modal;
@@ -1,104 +0,0 @@
1
- import React, { useCallback, useState } from "react";
2
- import styled from "styled-components";
3
- import { memoize } from "../utils";
4
- import withId from "../hocs/withId";
5
- import Text from "./Text";
6
- import ClickAwayListener from "@material-ui/core/ClickAwayListener";
7
- import { InnerSelect, Wrapper, SelectBox, Dropdown, Option, Placeholder } from "./Selector";
8
-
9
- export const SelectedValue = styled.span`
10
- display: inline-block;
11
- width: calc(100% - 20px);
12
- white-space: pre;
13
- overflow: hidden;
14
- `;
15
-
16
- const arrayToggle = (arr, item) => {
17
- const output = arr.filter(val => val !== item);
18
- if (output.length < arr.length) {
19
- return output;
20
- }
21
- output.push(item);
22
- return output;
23
- };
24
-
25
- const labelFromOptions = options => options.map(option => option.label).join(", ");
26
-
27
- export const MultiSelector = ({
28
- id,
29
- value = [],
30
- options,
31
- update,
32
- selectAllMessage = "[Select all]",
33
- clearMessage = "[Clear]",
34
- placeholder = "",
35
- required,
36
- ...props
37
- }) => {
38
- const selectAll = useCallback(() => update(options.map(opt => opt.value)), [update, options]);
39
- const clearValue = useCallback(() => update([]), [update]);
40
- // eslint-disable-next-line react-hooks/exhaustive-deps
41
- const clickOption = useCallback(
42
- memoize(clickValue => () => update(arrayToggle(value, clickValue))),
43
- [update, value],
44
- );
45
- const onChange = useCallback(e => update(arrayToggle(value, e.target.value)), [update, value]);
46
- const [isVisible, setIsVisible] = useState(false);
47
- /* istanbul ignore next */
48
- const toggleVisibility = () => {
49
- setIsVisible(!isVisible);
50
- };
51
-
52
- /* istanbul ignore next */
53
- const handlerClickAway = () => {
54
- setIsVisible(false);
55
- };
56
-
57
- /* istanbul ignore next */
58
- return (
59
- <ClickAwayListener onClickAway={() => handlerClickAway()}>
60
- <Wrapper>
61
- <InnerSelect id={id} onChange={onChange} value={value} multiple required={required} {...props}>
62
- {options.map(option => (
63
- <option key={option.value} value={option.value}>
64
- {option.label}
65
- </option>
66
- ))}
67
- </InnerSelect>
68
- <SelectBox htmlFor={id} onClick={() => toggleVisibility()}>
69
- {value.length ? (
70
- <SelectedValue>
71
- {labelFromOptions(options.filter(option => value.indexOf(option.value) !== -1))}
72
- </SelectedValue>
73
- ) : (
74
- <Placeholder>{placeholder}</Placeholder>
75
- )}
76
- </SelectBox>
77
- <Dropdown isVisible={isVisible}>
78
- {value.length ? (
79
- <Option key="multiselect_clear" onClick={clearValue} data-test-id="multiselect_clear">
80
- <Text message={clearMessage} />
81
- </Option>
82
- ) : null}
83
- {value.length === options.length ? null : (
84
- <Option key="multiselect_selectAll" onClick={selectAll} data-test-id="multiselect_selectAll">
85
- <Text message={selectAllMessage} />
86
- </Option>
87
- )}
88
- {options.map(option => (
89
- <Option
90
- key={option.value}
91
- active={value.indexOf(option.value) !== -1}
92
- onClick={clickOption(option.value)}
93
- data-test-id={option.value}
94
- >
95
- {option.label}
96
- </Option>
97
- ))}
98
- </Dropdown>
99
- </Wrapper>
100
- </ClickAwayListener>
101
- );
102
- };
103
-
104
- export default withId("selector")(MultiSelector);
@@ -1,348 +0,0 @@
1
- import React from "react";
2
- import { Provider } from "react-redux";
3
- import sinon from "sinon";
4
- import { getStyledClassSelector } from "../utils/testUtils";
5
- import { InnerSelect, Wrapper, SelectBox, Dropdown, Option, Placeholder } from "./Selector";
6
- import MultiSelector, { SelectedValue } from "./MultiSelector";
7
-
8
- describe("MultiSelector", () => {
9
- let updater;
10
- beforeEach(() => {
11
- updater = sinon.spy().named("updater");
12
- });
13
-
14
- it("renders a wrapped, hidden multiple select element, and visual cover elements", () =>
15
- expect(
16
- <Provider
17
- store={{
18
- subscribe: () => {},
19
- dispatch: () => {},
20
- getState: () => ({}),
21
- }}
22
- >
23
- <MultiSelector
24
- id="test"
25
- update={updater}
26
- options={[
27
- { value: "1", label: "Opt 1" },
28
- { value: "2", label: "Opt 2" },
29
- { value: "3", label: "Opt 3" },
30
- { value: "4", label: "Opt 4" },
31
- ]}
32
- value={["1", "3"]}
33
- />
34
- </Provider>,
35
- "when mounted",
36
- "to satisfy",
37
- <Wrapper>
38
- <InnerSelect id="test" multiple>
39
- <option key={1} value={1}>
40
- Opt 1
41
- </option>
42
- <option key={2} value={2}>
43
- Opt 2
44
- </option>
45
- <option key={3} value={3}>
46
- Opt 3
47
- </option>
48
- <option key={4} value={4}>
49
- Opt 4
50
- </option>
51
- </InnerSelect>
52
- <SelectBox htmlFor="test">
53
- <SelectedValue>Opt 1, Opt 3</SelectedValue>
54
- </SelectBox>
55
- <Dropdown>
56
- <Option key="multiselect_clear">[Clear]</Option>
57
- <Option key="multiselect_selectAll">[Select all]</Option>
58
- <Option key={1} active>
59
- Opt 1
60
- </Option>
61
- <Option key={2}>Opt 2</Option>
62
- <Option key={3} active>
63
- Opt 3
64
- </Option>
65
- <Option key={4}>Opt 4</Option>
66
- </Dropdown>
67
- </Wrapper>,
68
- ));
69
-
70
- it("only renders 'Clear' if value not empty", () =>
71
- expect(
72
- <Provider
73
- store={{
74
- subscribe: () => {},
75
- dispatch: () => {},
76
- getState: () => ({}),
77
- }}
78
- >
79
- <MultiSelector
80
- id="test"
81
- update={updater}
82
- options={[
83
- { value: "1", label: "Opt 1" },
84
- { value: "2", label: "Opt 2" },
85
- { value: "3", label: "Opt 3" },
86
- { value: "4", label: "Opt 4" },
87
- ]}
88
- value={[]}
89
- />
90
- </Provider>,
91
- "when mounted",
92
- "not to contain",
93
- <Option key="multiselect_clear">[Clear]</Option>,
94
- ));
95
-
96
- it("only renders 'Select all' if value not full", () =>
97
- expect(
98
- <Provider
99
- store={{
100
- subscribe: () => {},
101
- dispatch: () => {},
102
- getState: () => ({}),
103
- }}
104
- >
105
- <MultiSelector
106
- id="test"
107
- update={updater}
108
- options={[
109
- { value: "1", label: "Opt 1" },
110
- { value: "2", label: "Opt 2" },
111
- { value: "3", label: "Opt 3" },
112
- { value: "4", label: "Opt 4" },
113
- ]}
114
- value={["1", "2", "3", "4"]}
115
- />
116
- </Provider>,
117
- "when mounted",
118
- "not to contain",
119
- <Option key="multiselect_selectAll">[Select all]</Option>,
120
- ));
121
-
122
- it("renders a placeholder if no value set", () =>
123
- expect(
124
- <Provider
125
- store={{
126
- subscribe: () => {},
127
- dispatch: () => {},
128
- getState: () => ({}),
129
- }}
130
- >
131
- <MultiSelector
132
- id="test"
133
- placeholder="This space for rent"
134
- update={updater}
135
- required
136
- options={[
137
- { value: "1", label: "Opt 1" },
138
- { value: "2", label: "Opt 2" },
139
- { value: "3", label: "Opt 3" },
140
- { value: "4", label: "Opt 4" },
141
- ]}
142
- />
143
- </Provider>,
144
- "when mounted",
145
- "queried for first",
146
- getStyledClassSelector(Placeholder),
147
- "to satisfy",
148
- <Placeholder>This space for rent</Placeholder>,
149
- ));
150
-
151
- it("can add value when inner selector changes", () =>
152
- expect(
153
- <Provider
154
- store={{
155
- subscribe: () => {},
156
- dispatch: () => {},
157
- getState: () => ({}),
158
- }}
159
- >
160
- <MultiSelector
161
- update={updater}
162
- options={[
163
- { value: "1", label: "Opt 1" },
164
- { value: "2", label: "Opt 2" },
165
- { value: "3", label: "Opt 3" },
166
- { value: "4", label: "Opt 4" },
167
- ]}
168
- value={["3"]}
169
- />
170
- </Provider>,
171
- "when mounted",
172
- "with event",
173
- { type: "change", value: "2", target: "select" },
174
- ).then(() => expect(updater, "to have calls satisfying", [{ args: [["3", "2"]] }])));
175
-
176
- it("can remove value when inner selector changes", () =>
177
- expect(
178
- <Provider
179
- store={{
180
- subscribe: () => {},
181
- dispatch: () => {},
182
- getState: () => ({}),
183
- }}
184
- >
185
- <MultiSelector
186
- update={updater}
187
- options={[
188
- { value: "1", label: "Opt 1" },
189
- { value: "2", label: "Opt 2" },
190
- { value: "3", label: "Opt 3" },
191
- { value: "4", label: "Opt 4" },
192
- ]}
193
- value={["2", "3"]}
194
- />
195
- </Provider>,
196
- "when mounted",
197
- "with event",
198
- { type: "change", value: "3", target: "select" },
199
- ).then(() => expect(updater, "to have calls satisfying", [{ args: [["2"]] }])));
200
-
201
- it("can add value when clicking a visual option", () =>
202
- expect(
203
- <Provider
204
- store={{
205
- subscribe: () => {},
206
- dispatch: () => {},
207
- getState: () => ({}),
208
- }}
209
- >
210
- <MultiSelector
211
- update={updater}
212
- options={[
213
- { value: "1", label: "Opt 1" },
214
- { value: "2", label: "Opt 2" },
215
- { value: "3", label: "Opt 3" },
216
- { value: "4", label: "Opt 4" },
217
- ]}
218
- value={["3"]}
219
- />
220
- </Provider>,
221
- "when mounted",
222
- "with event",
223
- { type: "click", target: '[data-test-id="4"]' },
224
- ).then(() => expect(updater, "to have calls satisfying", [{ args: [["3", "4"]] }])));
225
-
226
- it("can remove value when clicking a visual option", () =>
227
- expect(
228
- <Provider
229
- store={{
230
- subscribe: () => {},
231
- dispatch: () => {},
232
- getState: () => ({}),
233
- }}
234
- >
235
- <MultiSelector
236
- update={updater}
237
- options={[
238
- { value: "1", label: "Opt 1" },
239
- { value: "2", label: "Opt 2" },
240
- { value: "3", label: "Opt 3" },
241
- { value: "4", label: "Opt 4" },
242
- ]}
243
- value={["4", "3"]}
244
- />
245
- </Provider>,
246
- "when mounted",
247
- "with event",
248
- { type: "click", target: '[data-test-id="4"]' },
249
- ).then(() => expect(updater, "to have calls satisfying", [{ args: [["3"]] }])));
250
-
251
- it("sets empty value when cleared", () =>
252
- expect(
253
- <Provider
254
- store={{
255
- subscribe: () => {},
256
- dispatch: () => {},
257
- getState: () => ({}),
258
- }}
259
- >
260
- <MultiSelector
261
- update={updater}
262
- options={[
263
- { value: "1", label: "Opt 1" },
264
- { value: "2", label: "Opt 2" },
265
- { value: "3", label: "Opt 3" },
266
- { value: "4", label: "Opt 4" },
267
- ]}
268
- value={["4", "3"]}
269
- />
270
- </Provider>,
271
- "when mounted",
272
- "with event",
273
- { type: "click", target: '[data-test-id="multiselect_clear"]' },
274
- ).then(() => expect(updater, "to have calls satisfying", [{ args: [[]] }])));
275
-
276
- it("sets full value when select all chosen", () =>
277
- expect(
278
- <Provider
279
- store={{
280
- subscribe: () => {},
281
- dispatch: () => {},
282
- getState: () => ({}),
283
- }}
284
- >
285
- <MultiSelector
286
- update={updater}
287
- options={[
288
- { value: "1", label: "Opt 1" },
289
- { value: "2", label: "Opt 2" },
290
- { value: "3", label: "Opt 3" },
291
- { value: "4", label: "Opt 4" },
292
- ]}
293
- value={[4, 3]}
294
- />
295
- </Provider>,
296
- "when mounted",
297
- "with event",
298
- { type: "click", target: '[data-test-id="multiselect_selectAll"]' },
299
- ).then(() => expect(updater, "to have calls satisfying", [{ args: [["1", "2", "3", "4"]] }])));
300
-
301
- it("deals with an empty value prop change", () =>
302
- expect(
303
- <Provider
304
- store={{
305
- subscribe: () => {},
306
- dispatch: () => {},
307
- getState: () => ({}),
308
- }}
309
- >
310
- <MultiSelector
311
- update={updater}
312
- options={[
313
- { value: "1", label: "Opt 1" },
314
- { value: "2", label: "Opt 2" },
315
- { value: "3", label: "Opt 3" },
316
- { value: "4", label: "Opt 4" },
317
- ]}
318
- />
319
- </Provider>,
320
- "when mounted",
321
- "with event",
322
- { type: "change", value: "2", target: "select" },
323
- ).then(() => expect(updater, "to have calls satisfying", [{ args: [["2"]] }])));
324
-
325
- it("deals with an empty value prop click", () =>
326
- expect(
327
- <Provider
328
- store={{
329
- subscribe: () => {},
330
- dispatch: () => {},
331
- getState: () => ({}),
332
- }}
333
- >
334
- <MultiSelector
335
- update={updater}
336
- options={[
337
- { value: "1", label: "Opt 1" },
338
- { value: "2", label: "Opt 2" },
339
- { value: "3", label: "Opt 3" },
340
- { value: "4", label: "Opt 4" },
341
- ]}
342
- />
343
- </Provider>,
344
- "when mounted",
345
- "with event",
346
- { type: "click", target: '[data-test-id="2"]' },
347
- ).then(() => expect(updater, "to have calls satisfying", [{ args: [["2"]] }])));
348
- });