@decisiv/ui-components 2.0.1-alpha.8 → 2.0.1-alpha.82
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/lib/atoms/BaseButton/index.d.ts.map +1 -1
- package/lib/atoms/BaseButton/index.js +1 -1
- package/lib/atoms/BooleanInput/index.d.ts.map +1 -1
- package/lib/atoms/BooleanInput/index.js +19 -2
- package/lib/atoms/BooleanInput/index.test.js +17 -6
- package/lib/atoms/BooleanInput/types.d.ts +2 -0
- package/lib/atoms/BooleanInput/types.d.ts.map +1 -1
- package/lib/atoms/Calendar/hooks/useCalendar/index.d.ts.map +1 -1
- package/lib/atoms/Calendar/hooks/useCalendar/index.js +2 -1
- package/lib/atoms/Calendar/hooks/useCalendar/index.test.js +5 -6
- package/lib/atoms/Calendar/index.d.ts.map +1 -1
- package/lib/atoms/Calendar/index.js +8 -1
- package/lib/atoms/Calendar/index.test.js +70 -40
- package/lib/atoms/InputField/Containers.d.ts +10 -6
- package/lib/atoms/InputField/Containers.d.ts.map +1 -1
- package/lib/atoms/InputField/Containers.js +6 -6
- package/lib/atoms/InputField/InputLabel.d.ts +1 -0
- package/lib/atoms/InputField/InputLabel.d.ts.map +1 -1
- package/lib/atoms/InputField/InputLabel.js +2 -1
- package/lib/atoms/InputField/index.d.ts +4 -0
- package/lib/atoms/InputField/index.d.ts.map +1 -1
- package/lib/atoms/InputField/index.js +18 -7
- package/lib/atoms/InputField/index.test.js +91 -0
- package/lib/atoms/InputField/schema.d.ts.map +1 -1
- package/lib/atoms/InputField/schema.js +1 -0
- package/lib/atoms/OptionsList/Category.d.ts +1 -1
- package/lib/atoms/OptionsList/Category.d.ts.map +1 -1
- package/lib/atoms/OptionsList/Category.js +4 -2
- package/lib/atoms/OptionsList/Footer.d.ts +8 -0
- package/lib/atoms/OptionsList/Footer.d.ts.map +1 -0
- package/lib/atoms/OptionsList/Footer.js +72 -0
- package/lib/atoms/OptionsList/Option.d.ts.map +1 -1
- package/lib/atoms/OptionsList/Option.js +8 -5
- package/lib/atoms/OptionsList/index.d.ts.map +1 -1
- package/lib/atoms/OptionsList/index.js +43 -16
- package/lib/atoms/OptionsList/index.test.js +107 -11
- package/lib/atoms/OptionsList/schema.d.ts.map +1 -1
- package/lib/atoms/OptionsList/schema.js +4 -0
- package/lib/atoms/OptionsList/types.d.ts +14 -0
- package/lib/atoms/OptionsList/types.d.ts.map +1 -1
- package/lib/atoms/RequiredIcon.d.ts +9 -0
- package/lib/atoms/RequiredIcon.d.ts.map +1 -0
- package/lib/atoms/{InputField/RequiredIcon.js → RequiredIcon.js} +7 -3
- package/lib/components/Button/schema.d.ts +6 -1
- package/lib/components/Button/schema.d.ts.map +1 -1
- package/lib/components/Button/schema.js +9 -4
- package/lib/components/Checkbox/index.d.ts.map +1 -1
- package/lib/components/Checkbox/index.js +3 -1
- package/lib/components/Checkbox/schema.d.ts.map +1 -1
- package/lib/components/Checkbox/schema.js +2 -0
- package/lib/components/Combobox/Target.d.ts.map +1 -1
- package/lib/components/Combobox/Target.js +45 -14
- package/lib/components/Combobox/index.d.ts.map +1 -1
- package/lib/components/Combobox/index.js +182 -64
- package/lib/components/Combobox/index.test.js +358 -135
- package/lib/components/Combobox/schema.d.ts.map +1 -1
- package/lib/components/Combobox/schema.js +9 -2
- package/lib/components/Combobox/types.d.ts +12 -3
- package/lib/components/Combobox/types.d.ts.map +1 -1
- package/lib/components/DropdownList/index.d.ts +4 -0
- package/lib/components/DropdownList/index.d.ts.map +1 -1
- package/lib/components/DropdownList/index.js +76 -11
- package/lib/components/DropdownList/propTypes.d.ts +4 -0
- package/lib/components/DropdownList/propTypes.d.ts.map +1 -0
- package/lib/components/DropdownList/propTypes.js +42 -0
- package/lib/components/DropdownList/schema.d.ts.map +1 -1
- package/lib/components/DropdownList/schema.js +5 -0
- package/lib/components/DropdownList/types.d.ts +4 -1
- package/lib/components/DropdownList/types.d.ts.map +1 -1
- package/lib/components/Filter/IconWrapper/index.d.ts +197 -0
- package/lib/components/Filter/IconWrapper/index.d.ts.map +1 -0
- package/lib/components/Filter/IconWrapper/index.js +35 -0
- package/lib/components/Filter/SimplePrimary/index.d.ts +31 -0
- package/lib/components/Filter/SimplePrimary/index.d.ts.map +1 -0
- package/lib/components/Filter/SimplePrimary/index.js +58 -0
- package/lib/components/Filter/SimplePrimary/index.test.js +34 -0
- package/lib/components/Filter/StyledFilter.d.ts +4 -0
- package/lib/components/Filter/StyledFilter.d.ts.map +1 -0
- package/lib/components/Filter/StyledFilter.js +39 -0
- package/lib/components/Filter/StyledLabel/index.d.ts +8 -0
- package/lib/components/Filter/StyledLabel/index.d.ts.map +1 -0
- package/lib/components/Filter/StyledLabel/index.js +30 -0
- package/lib/components/Filter/index.d.ts +27 -0
- package/lib/components/Filter/index.d.ts.map +1 -0
- package/lib/components/Filter/index.js +95 -0
- package/lib/components/Filter/index.test.js +41 -0
- package/lib/components/Filter/kind.d.ts +6 -0
- package/lib/components/Filter/kind.d.ts.map +1 -0
- package/lib/components/Filter/kind.js +45 -0
- package/lib/components/Filter/schema.d.ts +9 -0
- package/lib/components/Filter/schema.d.ts.map +1 -0
- package/lib/components/Filter/schema.js +32 -0
- package/lib/components/Filter/types.d.ts +17 -0
- package/lib/components/Filter/types.d.ts.map +1 -0
- package/lib/components/Filter/types.js +1 -0
- package/lib/components/LeftNav/Item/ClickArea.d.ts.map +1 -1
- package/lib/components/LeftNav/Item/ClickArea.js +2 -2
- package/lib/components/LeftNav/Item/ItemWrapper.d.ts.map +1 -1
- package/lib/components/LeftNav/Item/ItemWrapper.js +3 -3
- package/lib/components/LeftNav/Item/MenuItemWrapper.d.ts +7 -0
- package/lib/components/LeftNav/Item/MenuItemWrapper.d.ts.map +1 -0
- package/lib/components/LeftNav/Item/MenuItemWrapper.js +20 -0
- package/lib/components/LeftNav/Item/NavCollapsedXItem/index.d.ts.map +1 -1
- package/lib/components/LeftNav/Item/NavCollapsedXItem/index.js +7 -5
- package/lib/components/LeftNav/Item/NavExpandedItem/index.d.ts.map +1 -1
- package/lib/components/LeftNav/Item/NavExpandedItem/index.js +24 -13
- package/lib/components/LeftNav/Item/types.d.ts +1 -1
- package/lib/components/LeftNav/Item/types.d.ts.map +1 -1
- package/lib/components/LeftNav/index.test.js +13 -3
- package/lib/components/LeftNav/schema.d.ts.map +1 -1
- package/lib/components/LeftNav/schema.js +2 -0
- package/lib/components/LeftNav/types.d.ts +1 -0
- package/lib/components/LeftNav/types.d.ts.map +1 -1
- package/lib/components/Menu/index.d.ts.map +1 -1
- package/lib/components/Menu/index.js +3 -1
- package/lib/components/Menu/types.d.ts +2 -0
- package/lib/components/Menu/types.d.ts.map +1 -1
- package/lib/components/Modal/components.d.ts +2 -2
- package/lib/components/Modal/index.d.ts.map +1 -1
- package/lib/components/Modal/index.js +5 -5
- package/lib/components/Modal/index.test.js +32 -0
- package/lib/components/Modal/schema.d.ts.map +1 -1
- package/lib/components/Modal/schema.js +2 -2
- package/lib/components/Modal/types.d.ts +2 -2
- package/lib/components/Modal/types.d.ts.map +1 -1
- package/lib/components/Notifications/Notification/components.d.ts +3 -3
- package/lib/components/Notifications/Notification/components.d.ts.map +1 -1
- package/lib/components/Notifications/Notification/components.js +12 -6
- package/lib/components/Notifications/Notification/index.d.ts +3 -6
- package/lib/components/Notifications/Notification/index.d.ts.map +1 -1
- package/lib/components/Notifications/Notification/index.js +19 -12
- package/lib/components/Notifications/Notification/index.test.js +38 -19
- package/lib/components/Notifications/NotificationsPanel/index.d.ts +2 -1
- package/lib/components/Notifications/NotificationsPanel/index.d.ts.map +1 -1
- package/lib/components/Notifications/NotificationsPanel/index.js +44 -21
- package/lib/components/Notifications/NotificationsPanel/schema.js +1 -1
- package/lib/components/Notifications/Notifier.test.js +79 -10
- package/lib/components/Notifications/constants.d.ts +2 -0
- package/lib/components/Notifications/constants.d.ts.map +1 -0
- package/lib/components/Notifications/constants.js +16 -0
- package/lib/components/Notifications/schema.d.ts.map +1 -1
- package/lib/components/Notifications/schema.js +2 -1
- package/lib/components/Notifications/useNotifications.d.ts +1 -0
- package/lib/components/Notifications/useNotifications.d.ts.map +1 -1
- package/lib/components/Notifications/useNotifications.js +3 -3
- package/lib/components/Notifications/useNotifications.test.js +7 -4
- package/lib/components/Pagination/Pagination.d.ts +1 -1
- package/lib/components/Pagination/Pagination.d.ts.map +1 -1
- package/lib/components/Pagination/Pagination.js +1 -0
- package/lib/components/Pagination/Pagination.test.js +9 -0
- package/lib/components/Popover/utils.d.ts +1 -1
- package/lib/components/Select/Target.js +1 -1
- package/lib/components/Select/index.d.ts.map +1 -1
- package/lib/components/Select/index.js +20 -1
- package/lib/components/Select/index.test.js +31 -9
- package/lib/components/Select/schema.d.ts.map +1 -1
- package/lib/components/Select/schema.js +5 -0
- package/lib/components/Select/types.d.ts +2 -1
- package/lib/components/Select/types.d.ts.map +1 -1
- package/lib/components/SelectDate/Target.js +1 -1
- package/lib/components/SelectDate/index.test.js +71 -51
- package/lib/components/SelectDateRange/index.test.js +78 -58
- package/lib/components/SelectMenu/index.d.ts +5 -0
- package/lib/components/SelectMenu/index.d.ts.map +1 -1
- package/lib/components/SelectMenu/index.js +27 -3
- package/lib/components/SelectMenu/schema.d.ts.map +1 -1
- package/lib/components/SelectMenu/schema.js +4 -0
- package/lib/components/Table/Body.d.ts.map +1 -1
- package/lib/components/Table/Body.js +182 -38
- package/lib/components/Table/Container.d.ts.map +1 -1
- package/lib/components/Table/Container.js +2 -2
- package/lib/components/Table/DataRow.d.ts.map +1 -1
- package/lib/components/Table/DataRow.js +43 -16
- package/lib/components/Table/DraggableWrapper.d.ts +5 -0
- package/lib/components/Table/DraggableWrapper.d.ts.map +1 -0
- package/lib/components/Table/DraggableWrapper.js +38 -0
- package/lib/components/Table/Grip.d.ts +4 -0
- package/lib/components/Table/Grip.d.ts.map +1 -0
- package/lib/components/Table/Grip.js +30 -0
- package/lib/components/Table/Head.d.ts +1 -1
- package/lib/components/Table/Head.d.ts.map +1 -1
- package/lib/components/Table/Head.js +11 -5
- package/lib/components/Table/HeaderCell/index.d.ts.map +1 -1
- package/lib/components/Table/HeaderCell/index.js +22 -8
- package/lib/components/Table/HeaderCell/types.d.ts +6 -1
- package/lib/components/Table/HeaderCell/types.d.ts.map +1 -1
- package/lib/components/Table/Provider.d.ts +13 -4
- package/lib/components/Table/Provider.d.ts.map +1 -1
- package/lib/components/Table/Provider.js +45 -5
- package/lib/components/Table/index.d.ts.map +1 -1
- package/lib/components/Table/index.js +112 -18
- package/lib/components/Table/index.test.js +330 -84
- package/lib/components/Table/schema.columns.d.ts.map +1 -1
- package/lib/components/Table/schema.columns.js +6 -4
- package/lib/components/Table/schema.d.ts.map +1 -1
- package/lib/components/Table/schema.js +8 -6
- package/lib/components/Table/types.d.ts +34 -4
- package/lib/components/Table/types.d.ts.map +1 -1
- package/lib/components/Table/utils.d.ts +2 -8
- package/lib/components/Table/utils.d.ts.map +1 -1
- package/lib/components/Table/utils.js +21 -20
- package/lib/components/Tag/types.d.ts +1 -1
- package/lib/components/Tag/types.d.ts.map +1 -1
- package/lib/components/TextArea/TextArea.d.ts.map +1 -1
- package/lib/components/TextArea/TextArea.js +1 -1
- package/lib/components/TextArea/index.js +1 -0
- package/lib/components/TextArea/index.test.js +5 -0
- package/lib/components/TextField/Input.js +1 -1
- package/lib/components/TextField/index.test.js +5 -0
- package/lib/components/Toggle/index.d.ts.map +1 -1
- package/lib/components/Toggle/index.js +4 -0
- package/lib/components/Toggle/index.test.js +39 -10
- package/lib/components/TopNav/BrandInfo/index.d.ts +2 -1
- package/lib/components/TopNav/BrandInfo/index.d.ts.map +1 -1
- package/lib/components/TopNav/BrandInfo/index.js +9 -1
- package/lib/components/TopNav/BrandInfo/schema.d.ts.map +1 -1
- package/lib/components/TopNav/BrandInfo/schema.js +4 -1
- package/lib/components/TopNav/index.test.js +28 -0
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.d.ts.map +1 -1
- package/lib/components/index.js +9 -0
- package/lib/providers/ConfigProvider/index.d.ts.map +1 -1
- package/lib/providers/ConfigProvider/index.js +5 -1
- package/lib/providers/ConfigProvider/utils/context.d.ts +1 -1
- package/lib/providers/ConfigProvider/utils/context.d.ts.map +1 -1
- package/lib/providers/ConfigProvider/utils/normalizer.d.ts.map +1 -1
- package/lib/providers/ConfigProvider/utils/normalizer.js +1 -1
- package/lib/providers/ConfigProvider/utils/translations.d.ts +1 -1
- package/lib/providers/ConfigProvider/utils/translations.js +1 -1
- package/lib/providers/NotificationsProvider/index.d.ts +6 -5
- package/lib/providers/NotificationsProvider/index.d.ts.map +1 -1
- package/lib/providers/NotificationsProvider/index.js +47 -28
- package/lib/providers/NotificationsProvider/types.d.ts +4 -1
- package/lib/providers/NotificationsProvider/types.d.ts.map +1 -1
- package/lib/utils/joinClassnames.d.ts +3 -0
- package/lib/utils/joinClassnames.d.ts.map +1 -0
- package/lib/utils/joinClassnames.js +26 -0
- package/package.json +4 -2
- package/lib/atoms/InputField/RequiredIcon.d.ts +0 -4
- package/lib/atoms/InputField/RequiredIcon.d.ts.map +0 -1
|
@@ -20,6 +20,10 @@ var _ = _interopRequireDefault(require("."));
|
|
|
20
20
|
|
|
21
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
22
|
|
|
23
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
24
|
+
|
|
25
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
26
|
+
|
|
23
27
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { keys.push.apply(keys, Object.getOwnPropertySymbols(object)); } if (enumerableOnly) keys = keys.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); return keys; }
|
|
24
28
|
|
|
25
29
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
@@ -82,14 +86,38 @@ describe('Combobox', function () {
|
|
|
82
86
|
expect(queryByLabelText('test')).toHaveFocus();
|
|
83
87
|
});
|
|
84
88
|
});
|
|
89
|
+
describe('when the label is hidden', function () {
|
|
90
|
+
it('does not display the label element', function () {
|
|
91
|
+
var _render2 = render(_react.default.createElement(_.default, {
|
|
92
|
+
label: "test",
|
|
93
|
+
options: defaultOptions,
|
|
94
|
+
hideLabel: true
|
|
95
|
+
})),
|
|
96
|
+
getByText = _render2.getByText;
|
|
97
|
+
|
|
98
|
+
expect(getByText('test', {
|
|
99
|
+
selector: 'span'
|
|
100
|
+
})).not.toBeVisible();
|
|
101
|
+
});
|
|
102
|
+
it('does display the input related to the label', function () {
|
|
103
|
+
var _render3 = render(_react.default.createElement(_.default, {
|
|
104
|
+
label: "test",
|
|
105
|
+
options: defaultOptions,
|
|
106
|
+
hideLabel: true
|
|
107
|
+
})),
|
|
108
|
+
getByLabelText = _render3.getByLabelText;
|
|
109
|
+
|
|
110
|
+
expect(getByLabelText('test')).toBeVisible();
|
|
111
|
+
});
|
|
112
|
+
});
|
|
85
113
|
describe('when the input field has focus', function () {
|
|
86
114
|
it('displays the list of options', function () {
|
|
87
|
-
var
|
|
115
|
+
var _render4 = render(_react.default.createElement(_.default, {
|
|
88
116
|
label: "test",
|
|
89
117
|
options: defaultOptions
|
|
90
118
|
})),
|
|
91
|
-
baseElement =
|
|
92
|
-
queryByLabelText =
|
|
119
|
+
baseElement = _render4.baseElement,
|
|
120
|
+
queryByLabelText = _render4.queryByLabelText;
|
|
93
121
|
|
|
94
122
|
defaultOptions.forEach(function (_ref2) {
|
|
95
123
|
var label = _ref2.label;
|
|
@@ -104,12 +132,12 @@ describe('Combobox', function () {
|
|
|
104
132
|
});
|
|
105
133
|
});
|
|
106
134
|
it('renders the first item in the options list as "active"', function () {
|
|
107
|
-
var
|
|
135
|
+
var _render5 = render(_react.default.createElement(_.default, {
|
|
108
136
|
label: "test",
|
|
109
137
|
options: defaultOptions
|
|
110
138
|
})),
|
|
111
|
-
baseElement =
|
|
112
|
-
queryByText =
|
|
139
|
+
baseElement = _render5.baseElement,
|
|
140
|
+
queryByText = _render5.queryByText;
|
|
113
141
|
|
|
114
142
|
_react2.fireEvent.click(queryByText('test')); // The structure would match the querySelector `li label span`. `queryByText`
|
|
115
143
|
// returns the <span>, but we need the `<li>`
|
|
@@ -130,41 +158,44 @@ describe('Combobox', function () {
|
|
|
130
158
|
chevronUpContainer = _rtlRender2.container;
|
|
131
159
|
|
|
132
160
|
var chevronUpPathD = chevronUpContainer.querySelector('svg path').getAttribute('d');
|
|
161
|
+
var onShow = jest.fn();
|
|
133
162
|
|
|
134
|
-
var
|
|
163
|
+
var _render6 = render(_react.default.createElement(_.default, {
|
|
135
164
|
label: "test",
|
|
136
165
|
options: defaultOptions,
|
|
137
|
-
variant: "sync"
|
|
166
|
+
variant: "sync",
|
|
167
|
+
onShow: onShow
|
|
138
168
|
})),
|
|
139
|
-
container =
|
|
140
|
-
queryByLabelText =
|
|
169
|
+
container = _render6.container,
|
|
170
|
+
queryByLabelText = _render6.queryByLabelText;
|
|
141
171
|
|
|
142
172
|
expect(container.querySelector('svg path').getAttribute('d')).toEqual(chevronDownPathD);
|
|
143
173
|
|
|
144
174
|
_react2.fireEvent.click(queryByLabelText('test'));
|
|
145
175
|
|
|
176
|
+
expect(onShow).toHaveBeenCalledTimes(1);
|
|
146
177
|
expect(container.querySelector('svg path').getAttribute('d')).toEqual(chevronUpPathD);
|
|
147
178
|
});
|
|
148
179
|
});
|
|
149
180
|
describe('when variant="async"', function () {
|
|
150
181
|
it('does NOT render a chevron, even when it has options', function () {
|
|
151
|
-
var
|
|
182
|
+
var _render7 = render(_react.default.createElement(_.default, {
|
|
152
183
|
label: "test",
|
|
153
184
|
options: defaultOptions,
|
|
154
185
|
variant: "async"
|
|
155
186
|
})),
|
|
156
|
-
container =
|
|
187
|
+
container = _render7.container;
|
|
157
188
|
|
|
158
189
|
expect(container.querySelector('svg')).not.toBeInTheDocument();
|
|
159
190
|
});
|
|
160
191
|
});
|
|
161
192
|
describe('when typing', function () {
|
|
162
193
|
it('updates the input value as a stateful component', function () {
|
|
163
|
-
var
|
|
194
|
+
var _render8 = render(_react.default.createElement(_.default, {
|
|
164
195
|
label: "test",
|
|
165
196
|
options: defaultOptions
|
|
166
197
|
})),
|
|
167
|
-
queryByLabelText =
|
|
198
|
+
queryByLabelText = _render8.queryByLabelText;
|
|
168
199
|
|
|
169
200
|
var value = 'value';
|
|
170
201
|
|
|
@@ -187,12 +218,12 @@ describe('Combobox', function () {
|
|
|
187
218
|
eventTargetValue = event.target.value;
|
|
188
219
|
});
|
|
189
220
|
|
|
190
|
-
var
|
|
221
|
+
var _render9 = render(_react.default.createElement(_.default, {
|
|
191
222
|
label: "test",
|
|
192
223
|
options: defaultOptions,
|
|
193
224
|
onChangeInputValue: onChangeInputValue
|
|
194
225
|
})),
|
|
195
|
-
queryByLabelText =
|
|
226
|
+
queryByLabelText = _render9.queryByLabelText;
|
|
196
227
|
|
|
197
228
|
var value = 'value';
|
|
198
229
|
|
|
@@ -206,13 +237,13 @@ describe('Combobox', function () {
|
|
|
206
237
|
expect(eventTargetValue).toEqual(value);
|
|
207
238
|
});
|
|
208
239
|
it('renders new options without losing focus on input or closing dropdown', function () {
|
|
209
|
-
var
|
|
240
|
+
var _render10 = render(_react.default.createElement(_.default, {
|
|
210
241
|
label: "test",
|
|
211
242
|
options: defaultOptions
|
|
212
243
|
})),
|
|
213
|
-
baseElement =
|
|
214
|
-
queryByLabelText =
|
|
215
|
-
rerender =
|
|
244
|
+
baseElement = _render10.baseElement,
|
|
245
|
+
queryByLabelText = _render10.queryByLabelText,
|
|
246
|
+
rerender = _render10.rerender;
|
|
216
247
|
|
|
217
248
|
_react2.fireEvent.click(queryByLabelText('test'));
|
|
218
249
|
|
|
@@ -232,15 +263,15 @@ describe('Combobox', function () {
|
|
|
232
263
|
describe('when variant="async"', function () {
|
|
233
264
|
describe('when loading', function () {
|
|
234
265
|
it('renders the loading message, then options', function () {
|
|
235
|
-
var
|
|
266
|
+
var _render11 = render(_react.default.createElement(_.default, {
|
|
236
267
|
label: "test",
|
|
237
268
|
options: defaultOptions,
|
|
238
269
|
defaultInputValue: "option",
|
|
239
270
|
variant: "async"
|
|
240
271
|
})),
|
|
241
|
-
baseElement =
|
|
242
|
-
queryByLabelText =
|
|
243
|
-
rerender =
|
|
272
|
+
baseElement = _render11.baseElement,
|
|
273
|
+
queryByLabelText = _render11.queryByLabelText,
|
|
274
|
+
rerender = _render11.rerender;
|
|
244
275
|
|
|
245
276
|
_react2.fireEvent.click(queryByLabelText('test'));
|
|
246
277
|
|
|
@@ -269,16 +300,16 @@ describe('Combobox', function () {
|
|
|
269
300
|
describe('when variant="async"', function () {
|
|
270
301
|
describe('when loading={true} then toggles to loading={false}', function () {
|
|
271
302
|
it('renders the no matches found message', function () {
|
|
272
|
-
var
|
|
303
|
+
var _render12 = render(_react.default.createElement(_.default, {
|
|
273
304
|
label: "test",
|
|
274
305
|
loading: false,
|
|
275
306
|
options: [],
|
|
276
307
|
variant: "async"
|
|
277
308
|
})),
|
|
278
|
-
baseElement =
|
|
279
|
-
queryByLabelText =
|
|
280
|
-
queryByText =
|
|
281
|
-
rerender =
|
|
309
|
+
baseElement = _render12.baseElement,
|
|
310
|
+
queryByLabelText = _render12.queryByLabelText,
|
|
311
|
+
queryByText = _render12.queryByText,
|
|
312
|
+
rerender = _render12.rerender;
|
|
282
313
|
|
|
283
314
|
_react2.fireEvent.click(queryByText('test')); // at this stage, the dropdown shouldn't be open.
|
|
284
315
|
|
|
@@ -315,13 +346,13 @@ describe('Combobox', function () {
|
|
|
315
346
|
});
|
|
316
347
|
describe('when variant="sync"', function () {
|
|
317
348
|
it('renders the no matches found message', function () {
|
|
318
|
-
var
|
|
349
|
+
var _render13 = render(_react.default.createElement(_.default, {
|
|
319
350
|
label: "test",
|
|
320
351
|
options: defaultOptions
|
|
321
352
|
})),
|
|
322
|
-
baseElement =
|
|
323
|
-
queryByLabelText =
|
|
324
|
-
rerender =
|
|
353
|
+
baseElement = _render13.baseElement,
|
|
354
|
+
queryByLabelText = _render13.queryByLabelText,
|
|
355
|
+
rerender = _render13.rerender;
|
|
325
356
|
|
|
326
357
|
_react2.fireEvent.click(queryByLabelText('test')); // at this stage, the dropdown should be open with all of the available options.
|
|
327
358
|
|
|
@@ -353,17 +384,24 @@ describe('Combobox', function () {
|
|
|
353
384
|
chevronDownContainer = _rtlRender3.container;
|
|
354
385
|
|
|
355
386
|
var chevronDownPathD = chevronDownContainer.querySelector('svg path').getAttribute('d');
|
|
387
|
+
var onShow = jest.fn();
|
|
388
|
+
var onHide = jest.fn();
|
|
356
389
|
|
|
357
|
-
var
|
|
390
|
+
var _render14 = render(_react.default.createElement(_.default, {
|
|
358
391
|
label: "test",
|
|
359
|
-
options: defaultOptions
|
|
392
|
+
options: defaultOptions,
|
|
393
|
+
onShow: onShow,
|
|
394
|
+
onHide: onHide
|
|
360
395
|
})),
|
|
361
|
-
baseElement =
|
|
362
|
-
container =
|
|
363
|
-
queryByLabelText =
|
|
396
|
+
baseElement = _render14.baseElement,
|
|
397
|
+
container = _render14.container,
|
|
398
|
+
queryByLabelText = _render14.queryByLabelText;
|
|
364
399
|
|
|
365
400
|
_react2.fireEvent.click(queryByLabelText('test'));
|
|
366
401
|
|
|
402
|
+
expect(onShow).toHaveBeenCalledTimes(1);
|
|
403
|
+
expect(onHide).not.toHaveBeenCalled();
|
|
404
|
+
|
|
367
405
|
_react2.fireEvent.change(queryByLabelText('test'), {
|
|
368
406
|
target: {
|
|
369
407
|
value: 'value'
|
|
@@ -377,6 +415,8 @@ describe('Combobox', function () {
|
|
|
377
415
|
keyCode: 13
|
|
378
416
|
});
|
|
379
417
|
|
|
418
|
+
expect(onShow).toHaveBeenCalledTimes(1);
|
|
419
|
+
expect(onHide).toHaveBeenCalledTimes(1);
|
|
380
420
|
expect((0, _react2.queryByText)(baseElement, defaultOptions[1].label)).not.toBeInTheDocument();
|
|
381
421
|
expect( // The svg path [0] is the "X" in the clear button
|
|
382
422
|
container.querySelectorAll('svg path')[1].getAttribute('d')).toEqual(chevronDownPathD);
|
|
@@ -384,14 +424,14 @@ describe('Combobox', function () {
|
|
|
384
424
|
it('selects the active (first) item in the dropdown list', function () {
|
|
385
425
|
var onChangeValue = jest.fn();
|
|
386
426
|
|
|
387
|
-
var
|
|
427
|
+
var _render15 = render(_react.default.createElement(_.default, {
|
|
388
428
|
label: "test",
|
|
389
429
|
onChangeValue: onChangeValue,
|
|
390
430
|
options: defaultOptions
|
|
391
431
|
})),
|
|
392
|
-
baseElement =
|
|
393
|
-
queryByText =
|
|
394
|
-
queryByLabelText =
|
|
432
|
+
baseElement = _render15.baseElement,
|
|
433
|
+
queryByText = _render15.queryByText,
|
|
434
|
+
queryByLabelText = _render15.queryByLabelText;
|
|
395
435
|
|
|
396
436
|
_react2.fireEvent.click(queryByText('test'));
|
|
397
437
|
|
|
@@ -408,9 +448,59 @@ describe('Combobox', function () {
|
|
|
408
448
|
keyCode: 13
|
|
409
449
|
});
|
|
410
450
|
|
|
411
|
-
expect(onChangeValue).toHaveBeenCalledWith(defaultOptions[0].id
|
|
451
|
+
expect(onChangeValue).toHaveBeenCalledWith(defaultOptions[0].id, expect.objectContaining({
|
|
452
|
+
removed: false
|
|
453
|
+
}));
|
|
412
454
|
expect(queryByLabelText('test')).toHaveValue(defaultOptions[0].label);
|
|
413
455
|
});
|
|
456
|
+
describe('with first element disabled', function () {
|
|
457
|
+
it('selects the first element that is not disabled', function () {
|
|
458
|
+
var onChangeValue = jest.fn();
|
|
459
|
+
var options = [{
|
|
460
|
+
id: '0',
|
|
461
|
+
label: 'option 0',
|
|
462
|
+
value: 'option 0',
|
|
463
|
+
disabled: true
|
|
464
|
+
}, {
|
|
465
|
+
id: '1',
|
|
466
|
+
label: 'option 1',
|
|
467
|
+
value: 'option 1'
|
|
468
|
+
}, {
|
|
469
|
+
id: '2',
|
|
470
|
+
label: 'option 2',
|
|
471
|
+
value: 'option 2'
|
|
472
|
+
}];
|
|
473
|
+
|
|
474
|
+
var _render16 = render(_react.default.createElement(_.default, {
|
|
475
|
+
label: "test",
|
|
476
|
+
onChangeValue: onChangeValue,
|
|
477
|
+
options: options
|
|
478
|
+
})),
|
|
479
|
+
baseElement = _render16.baseElement,
|
|
480
|
+
queryByText = _render16.queryByText,
|
|
481
|
+
queryByLabelText = _render16.queryByLabelText;
|
|
482
|
+
|
|
483
|
+
_react2.fireEvent.click(queryByText('test'));
|
|
484
|
+
|
|
485
|
+
_react2.fireEvent.change(queryByLabelText('test'), {
|
|
486
|
+
target: {
|
|
487
|
+
value: 'value'
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
expect((0, _react2.queryByText)(baseElement, options[1].label)).toBeInTheDocument();
|
|
492
|
+
|
|
493
|
+
_react2.fireEvent.keyDown(queryByLabelText('test'), {
|
|
494
|
+
key: 'Enter',
|
|
495
|
+
keyCode: 13
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
expect(onChangeValue).toHaveBeenCalledWith(options[1].id, expect.objectContaining({
|
|
499
|
+
removed: false
|
|
500
|
+
}));
|
|
501
|
+
expect(queryByLabelText('test')).toHaveValue(options[1].label);
|
|
502
|
+
});
|
|
503
|
+
});
|
|
414
504
|
});
|
|
415
505
|
describe('when pressing the TAB key', function () {
|
|
416
506
|
it('closes the dropdown, advances focus', function () {
|
|
@@ -419,14 +509,14 @@ describe('Combobox', function () {
|
|
|
419
509
|
|
|
420
510
|
var chevronDownPathD = chevronDownContainer.querySelector('svg path').getAttribute('d');
|
|
421
511
|
|
|
422
|
-
var
|
|
512
|
+
var _render17 = render(_react.default.createElement(_.default, {
|
|
423
513
|
label: "test",
|
|
424
514
|
options: defaultOptions
|
|
425
515
|
})),
|
|
426
|
-
baseElement =
|
|
427
|
-
container =
|
|
428
|
-
queryByText =
|
|
429
|
-
queryByLabelText =
|
|
516
|
+
baseElement = _render17.baseElement,
|
|
517
|
+
container = _render17.container,
|
|
518
|
+
queryByText = _render17.queryByText,
|
|
519
|
+
queryByLabelText = _render17.queryByLabelText;
|
|
430
520
|
|
|
431
521
|
_react2.fireEvent.click(queryByText('test'));
|
|
432
522
|
|
|
@@ -455,12 +545,12 @@ describe('Combobox', function () {
|
|
|
455
545
|
it('preserves the typed text, does NOT make a selection', function () {
|
|
456
546
|
var onChangeValue = jest.fn();
|
|
457
547
|
|
|
458
|
-
var
|
|
548
|
+
var _render18 = render(_react.default.createElement(_.default, {
|
|
459
549
|
label: "test",
|
|
460
550
|
onChangeValue: onChangeValue,
|
|
461
551
|
options: defaultOptions
|
|
462
552
|
})),
|
|
463
|
-
queryByLabelText =
|
|
553
|
+
queryByLabelText = _render18.queryByLabelText;
|
|
464
554
|
|
|
465
555
|
var value = 'value';
|
|
466
556
|
|
|
@@ -488,20 +578,20 @@ describe('Combobox', function () {
|
|
|
488
578
|
var onChangeInputValue = jest.fn();
|
|
489
579
|
var onChangeValue = jest.fn();
|
|
490
580
|
|
|
491
|
-
var
|
|
581
|
+
var _render19 = render(_react.default.createElement(_.default, {
|
|
492
582
|
label: "test",
|
|
493
583
|
onChangeInputValue: onChangeInputValue,
|
|
494
584
|
onChangeValue: onChangeValue,
|
|
495
585
|
options: defaultOptions
|
|
496
586
|
})),
|
|
497
|
-
baseElement =
|
|
498
|
-
queryByLabelText =
|
|
587
|
+
baseElement = _render19.baseElement,
|
|
588
|
+
queryByLabelText = _render19.queryByLabelText; // You can not fire an event on the input in the UI unless you are already focused on it.
|
|
499
589
|
// This click focuses on the input.
|
|
500
590
|
|
|
501
591
|
|
|
502
592
|
_react2.fireEvent.click(queryByLabelText('test'));
|
|
503
593
|
|
|
504
|
-
expect((0, _react2.queryByText)(baseElement, defaultOptions[0].label)).toBeInTheDocument(); // The first element should be "active" by default.
|
|
594
|
+
expect((0, _react2.queryByText)(baseElement, defaultOptions[0].label)).toBeInTheDocument(); // The first element should be "active" by default if it's not disabled.
|
|
505
595
|
|
|
506
596
|
expect((0, _react2.queryByText)(baseElement, defaultOptions[0].label).parentElement.parentElement).toHaveStyle("\n background: ".concat((0, _toColorString.default)(_color.default.interaction.pacificOcean15), ";\n color: ").concat((0, _toColorString.default)(_color.default.interaction.pacificOcean), ";\n ")); // The focus should always remain on the input. The "active" item is kind of a fake.
|
|
507
597
|
|
|
@@ -527,16 +617,88 @@ describe('Combobox', function () {
|
|
|
527
617
|
expect(onChangeInputValue).not.toHaveBeenCalled();
|
|
528
618
|
expect(onChangeValue).not.toHaveBeenCalled();
|
|
529
619
|
});
|
|
620
|
+
describe('with a disabled option', function () {
|
|
621
|
+
it('expands and navigates through the dropdown list, keeps focus on the input', function () {
|
|
622
|
+
var onChangeInputValue = jest.fn();
|
|
623
|
+
var onChangeValue = jest.fn();
|
|
624
|
+
var enabledElements = ['enabled 1', 'enabled 2'];
|
|
625
|
+
var options = [{
|
|
626
|
+
id: enabledElements[0],
|
|
627
|
+
label: enabledElements[0],
|
|
628
|
+
value: 'option 0'
|
|
629
|
+
}, {
|
|
630
|
+
id: '1',
|
|
631
|
+
label: 'option 1',
|
|
632
|
+
value: 'option 1',
|
|
633
|
+
disabled: true
|
|
634
|
+
}, {
|
|
635
|
+
label: 'category 0',
|
|
636
|
+
items: [{
|
|
637
|
+
id: 'cat0Opt0',
|
|
638
|
+
label: 'category 0 option 0',
|
|
639
|
+
value: 'category 0 option 0',
|
|
640
|
+
disabled: true
|
|
641
|
+
}, {
|
|
642
|
+
id: enabledElements[1],
|
|
643
|
+
label: enabledElements[1],
|
|
644
|
+
value: 'category 0 option 1'
|
|
645
|
+
}]
|
|
646
|
+
}];
|
|
647
|
+
|
|
648
|
+
var _render20 = render(_react.default.createElement(_.default, {
|
|
649
|
+
label: "test",
|
|
650
|
+
onChangeInputValue: onChangeInputValue,
|
|
651
|
+
onChangeValue: onChangeValue,
|
|
652
|
+
options: options
|
|
653
|
+
})),
|
|
654
|
+
baseElement = _render20.baseElement,
|
|
655
|
+
queryByLabelText = _render20.queryByLabelText; // You can not fire an event on the input in the UI unless you are already focused on it.
|
|
656
|
+
// This click focuses on the input.
|
|
657
|
+
|
|
658
|
+
|
|
659
|
+
_react2.fireEvent.click(queryByLabelText('test'));
|
|
660
|
+
|
|
661
|
+
expect((0, _react2.queryByText)(baseElement, enabledElements[0])).toBeInTheDocument(); // The first element should be "active" by default if it's not disabled.
|
|
662
|
+
|
|
663
|
+
expect((0, _react2.queryByText)(baseElement, enabledElements[0]).parentElement.parentElement).toHaveStyle("\n background: ".concat((0, _toColorString.default)(_color.default.interaction.pacificOcean15), ";\n color: ").concat((0, _toColorString.default)(_color.default.interaction.pacificOcean), ";\n ")); // The focus should always remain on the input. The "active" item is kind of a fake.
|
|
664
|
+
|
|
665
|
+
expect(queryByLabelText('test')).toHaveFocus();
|
|
666
|
+
|
|
667
|
+
_react2.fireEvent.keyDown(queryByLabelText('test'), {
|
|
668
|
+
key: 'ArrowDown',
|
|
669
|
+
keyCode: 40
|
|
670
|
+
});
|
|
671
|
+
|
|
672
|
+
expect((0, _react2.queryByText)(baseElement, enabledElements[0]).parentElement.parentElement).not.toHaveStyle("\n background: ".concat((0, _toColorString.default)(_color.default.interaction.pacificOcean15), ";\n color: ").concat((0, _toColorString.default)(_color.default.interaction.pacificOcean), ";\n ")); // The next active element should be the next element in the list
|
|
673
|
+
// that is not marked as disabled
|
|
674
|
+
|
|
675
|
+
expect((0, _react2.queryByText)(baseElement, enabledElements[1]).parentElement.parentElement).toHaveStyle("\n background: ".concat((0, _toColorString.default)(_color.default.interaction.pacificOcean15), ";\n color: ").concat((0, _toColorString.default)(_color.default.interaction.pacificOcean), ";\n "));
|
|
676
|
+
expect(queryByLabelText('test')).toHaveFocus();
|
|
677
|
+
|
|
678
|
+
_react2.fireEvent.keyDown(queryByLabelText('test'), {
|
|
679
|
+
key: 'ArrowUp',
|
|
680
|
+
keyCode: 38
|
|
681
|
+
});
|
|
682
|
+
|
|
683
|
+
expect((0, _react2.queryByText)(baseElement, enabledElements[1]).parentElement.parentElement).not.toHaveStyle("\n background: ".concat((0, _toColorString.default)(_color.default.interaction.pacificOcean15), ";\n color: ").concat((0, _toColorString.default)(_color.default.interaction.pacificOcean), ";\n ")); // The next active element should be the previous element in the list
|
|
684
|
+
// that is not marked as disabled
|
|
685
|
+
|
|
686
|
+
expect((0, _react2.queryByText)(baseElement, enabledElements[0]).parentElement.parentElement).toHaveStyle("\n background: ".concat((0, _toColorString.default)(_color.default.interaction.pacificOcean15), ";\n color: ").concat((0, _toColorString.default)(_color.default.interaction.pacificOcean), ";\n "));
|
|
687
|
+
expect(queryByLabelText('test')).toHaveFocus();
|
|
688
|
+
expect(onChangeInputValue).not.toHaveBeenCalled();
|
|
689
|
+
expect(onChangeValue).not.toHaveBeenCalled();
|
|
690
|
+
});
|
|
691
|
+
});
|
|
530
692
|
});
|
|
531
693
|
describe('when pressing the ESCAPE key', function () {
|
|
532
694
|
it('closes the dropdown, keeps focus on input', function () {
|
|
533
|
-
var
|
|
695
|
+
var _render21 = render(_react.default.createElement(_.default, {
|
|
534
696
|
label: "test",
|
|
535
697
|
options: defaultOptions
|
|
536
698
|
})),
|
|
537
|
-
baseElement =
|
|
538
|
-
queryByLabelText =
|
|
539
|
-
queryByText =
|
|
699
|
+
baseElement = _render21.baseElement,
|
|
700
|
+
queryByLabelText = _render21.queryByLabelText,
|
|
701
|
+
queryByText = _render21.queryByText;
|
|
540
702
|
|
|
541
703
|
_react2.fireEvent.click(queryByText('test'));
|
|
542
704
|
|
|
@@ -554,13 +716,13 @@ describe('Combobox', function () {
|
|
|
554
716
|
it('preserves the typed text, does NOT make a selection', function () {
|
|
555
717
|
var onChangeValue = jest.fn();
|
|
556
718
|
|
|
557
|
-
var
|
|
719
|
+
var _render22 = render(_react.default.createElement(_.default, {
|
|
558
720
|
label: "test",
|
|
559
721
|
options: defaultOptions,
|
|
560
722
|
onChangeValue: onChangeValue
|
|
561
723
|
})),
|
|
562
|
-
queryByLabelText =
|
|
563
|
-
queryByText =
|
|
724
|
+
queryByLabelText = _render22.queryByLabelText,
|
|
725
|
+
queryByText = _render22.queryByText;
|
|
564
726
|
|
|
565
727
|
var value = 'value';
|
|
566
728
|
|
|
@@ -586,18 +748,18 @@ describe('Combobox', function () {
|
|
|
586
748
|
});
|
|
587
749
|
describe('when the input field has text', function () {
|
|
588
750
|
it('renders the "clear" button', function () {
|
|
589
|
-
var
|
|
590
|
-
timesContainer =
|
|
751
|
+
var _render23 = render(_react.default.createElement(_Times.default, null)),
|
|
752
|
+
timesContainer = _render23.container;
|
|
591
753
|
|
|
592
754
|
var timesPathD = timesContainer.querySelector('svg path').getAttribute('d');
|
|
593
755
|
|
|
594
|
-
var
|
|
756
|
+
var _render24 = render(_react.default.createElement(_.default, {
|
|
595
757
|
defaultInputValue: "value",
|
|
596
758
|
label: "test",
|
|
597
759
|
options: defaultOptions
|
|
598
760
|
})),
|
|
599
|
-
container =
|
|
600
|
-
queryByLabelText =
|
|
761
|
+
container = _render24.container,
|
|
762
|
+
queryByLabelText = _render24.queryByLabelText;
|
|
601
763
|
|
|
602
764
|
expect(queryByLabelText('test')).toHaveValue('value');
|
|
603
765
|
expect(container.querySelectorAll('svg path')[0]).toHaveAttribute('d', timesPathD);
|
|
@@ -609,12 +771,12 @@ describe('Combobox', function () {
|
|
|
609
771
|
inputValue = event ? event.target.value : '';
|
|
610
772
|
});
|
|
611
773
|
|
|
612
|
-
var
|
|
774
|
+
var _render25 = render(_react.default.createElement(_.default, {
|
|
613
775
|
label: "test",
|
|
614
776
|
onChangeInputValue: onChangeInputValue
|
|
615
777
|
})),
|
|
616
|
-
container =
|
|
617
|
-
queryByLabelText =
|
|
778
|
+
container = _render25.container,
|
|
779
|
+
queryByLabelText = _render25.queryByLabelText;
|
|
618
780
|
|
|
619
781
|
var value = 'value';
|
|
620
782
|
|
|
@@ -640,30 +802,47 @@ describe('Combobox', function () {
|
|
|
640
802
|
it('updates the input value with the label of the selection', function () {
|
|
641
803
|
var onChangeValue = jest.fn();
|
|
642
804
|
|
|
643
|
-
var
|
|
805
|
+
var _render26 = render(_react.default.createElement(_.default, {
|
|
644
806
|
label: "test",
|
|
645
807
|
options: defaultOptions,
|
|
646
808
|
onChangeValue: onChangeValue
|
|
647
809
|
})),
|
|
648
|
-
baseElement =
|
|
649
|
-
queryByLabelText =
|
|
810
|
+
baseElement = _render26.baseElement,
|
|
811
|
+
queryByLabelText = _render26.queryByLabelText;
|
|
650
812
|
|
|
651
813
|
_react2.fireEvent.click(queryByLabelText('test'));
|
|
652
814
|
|
|
653
815
|
_react2.fireEvent.click((0, _react2.queryByText)(baseElement, defaultOptions[1].label));
|
|
654
816
|
|
|
655
|
-
expect(onChangeValue).toHaveBeenCalledWith(defaultOptions[1].id
|
|
817
|
+
expect(onChangeValue).toHaveBeenCalledWith(defaultOptions[1].id, expect.objectContaining({
|
|
818
|
+
removed: false
|
|
819
|
+
}));
|
|
656
820
|
expect(queryByLabelText('test')).toHaveValue(defaultOptions[1].label); // selecting an option should close the dropdown list
|
|
657
821
|
|
|
658
822
|
expect((0, _react2.queryByText)(baseElement, defaultOptions[0].label)).not.toBeInTheDocument();
|
|
659
823
|
});
|
|
824
|
+
it('shows the selected tag when multiple select is enabled', function () {
|
|
825
|
+
var _render27 = render(_react.default.createElement(_.default, {
|
|
826
|
+
label: "test",
|
|
827
|
+
multiple: true,
|
|
828
|
+
options: defaultOptions
|
|
829
|
+
})),
|
|
830
|
+
baseElement = _render27.baseElement,
|
|
831
|
+
queryByLabelText = _render27.queryByLabelText;
|
|
832
|
+
|
|
833
|
+
_react2.fireEvent.click(queryByLabelText('test'));
|
|
834
|
+
|
|
835
|
+
_react2.fireEvent.click((0, _react2.queryByText)(baseElement, defaultOptions[1].label));
|
|
836
|
+
|
|
837
|
+
expect((0, _react2.queryByText)(baseElement, defaultOptions[1].label)).toBeInTheDocument();
|
|
838
|
+
});
|
|
660
839
|
it('renders as "selected" in the dropdown list', function () {
|
|
661
|
-
var
|
|
840
|
+
var _render28 = render(_react.default.createElement(_.default, {
|
|
662
841
|
label: "test",
|
|
663
842
|
options: defaultOptions
|
|
664
843
|
})),
|
|
665
|
-
baseElement =
|
|
666
|
-
queryByLabelText =
|
|
844
|
+
baseElement = _render28.baseElement,
|
|
845
|
+
queryByLabelText = _render28.queryByLabelText;
|
|
667
846
|
|
|
668
847
|
_react2.fireEvent.click(queryByLabelText('test'));
|
|
669
848
|
|
|
@@ -681,14 +860,14 @@ describe('Combobox', function () {
|
|
|
681
860
|
it('does NOT update the selection automatically', function () {
|
|
682
861
|
var onChangeValue = jest.fn();
|
|
683
862
|
|
|
684
|
-
var
|
|
863
|
+
var _render29 = render(_react.default.createElement(_.default, {
|
|
685
864
|
label: "test",
|
|
686
865
|
options: defaultOptions,
|
|
687
866
|
onChangeValue: onChangeValue
|
|
688
867
|
})),
|
|
689
|
-
baseElement =
|
|
690
|
-
queryByLabelText =
|
|
691
|
-
queryByText =
|
|
868
|
+
baseElement = _render29.baseElement,
|
|
869
|
+
queryByLabelText = _render29.queryByLabelText,
|
|
870
|
+
queryByText = _render29.queryByText;
|
|
692
871
|
|
|
693
872
|
_react2.fireEvent.click(queryByText('test'));
|
|
694
873
|
|
|
@@ -715,13 +894,13 @@ describe('Combobox', function () {
|
|
|
715
894
|
it('clears the selection', function () {
|
|
716
895
|
var onChangeValue = jest.fn();
|
|
717
896
|
|
|
718
|
-
var
|
|
897
|
+
var _render30 = render(_react.default.createElement(_.default, {
|
|
719
898
|
label: "test",
|
|
720
899
|
options: defaultOptions,
|
|
721
900
|
onChangeValue: onChangeValue
|
|
722
901
|
})),
|
|
723
|
-
baseElement =
|
|
724
|
-
queryByLabelText =
|
|
902
|
+
baseElement = _render30.baseElement,
|
|
903
|
+
queryByLabelText = _render30.queryByLabelText;
|
|
725
904
|
|
|
726
905
|
_react2.fireEvent.click(queryByLabelText('test'));
|
|
727
906
|
|
|
@@ -734,7 +913,9 @@ describe('Combobox', function () {
|
|
|
734
913
|
_react2.fireEvent.click(queryByLabelText('test'));
|
|
735
914
|
|
|
736
915
|
expect(onChangeValue).toHaveBeenCalledTimes(2);
|
|
737
|
-
expect(onChangeValue).toHaveBeenCalledWith(
|
|
916
|
+
expect(onChangeValue).toHaveBeenCalledWith(null, {
|
|
917
|
+
removed: true
|
|
918
|
+
});
|
|
738
919
|
expect((0, _react2.queryByText)(baseElement, defaultOptions[1].label).parentElement).not.toHaveStyle("\n background: ".concat((0, _toColorString.default)(_color.default.interaction.pacificOcean), ";\n color: ").concat((0, _toColorString.default)(_color.default.base.snowWhite), ";\n "));
|
|
739
920
|
});
|
|
740
921
|
});
|
|
@@ -744,7 +925,7 @@ describe('Combobox', function () {
|
|
|
744
925
|
var onChangeInputValue = jest.fn();
|
|
745
926
|
var onChangeValue = jest.fn();
|
|
746
927
|
|
|
747
|
-
var
|
|
928
|
+
var _render31 = render(_react.default.createElement(_.default, {
|
|
748
929
|
label: "test",
|
|
749
930
|
options: defaultOptions,
|
|
750
931
|
defaultInputValue: "value",
|
|
@@ -752,9 +933,9 @@ describe('Combobox', function () {
|
|
|
752
933
|
onChangeInputValue: onChangeInputValue,
|
|
753
934
|
onChangeValue: onChangeValue
|
|
754
935
|
})),
|
|
755
|
-
baseElement =
|
|
756
|
-
queryByLabelText =
|
|
757
|
-
rerender =
|
|
936
|
+
baseElement = _render31.baseElement,
|
|
937
|
+
queryByLabelText = _render31.queryByLabelText,
|
|
938
|
+
rerender = _render31.rerender;
|
|
758
939
|
|
|
759
940
|
_react2.fireEvent.click(queryByLabelText('test'));
|
|
760
941
|
|
|
@@ -776,63 +957,105 @@ describe('Combobox', function () {
|
|
|
776
957
|
});
|
|
777
958
|
});
|
|
778
959
|
describe('when a controlled component', function () {
|
|
779
|
-
it('initializes with and prefers prop values', function () {
|
|
780
|
-
var newInputValue;
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
960
|
+
it('initializes with and prefers prop values', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
961
|
+
var newInputValue, onChangeInputValue, onChangeValue, _render32, baseElement, queryByLabelText, rerender;
|
|
962
|
+
|
|
963
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
964
|
+
while (1) {
|
|
965
|
+
switch (_context.prev = _context.next) {
|
|
966
|
+
case 0:
|
|
967
|
+
onChangeInputValue = jest.fn(function (event) {
|
|
968
|
+
newInputValue = event ? event.target.value : '';
|
|
969
|
+
});
|
|
970
|
+
onChangeValue = jest.fn();
|
|
971
|
+
_render32 = render(_react.default.createElement(_.default, {
|
|
972
|
+
label: "test",
|
|
973
|
+
options: defaultOptions,
|
|
974
|
+
inputValue: "value",
|
|
975
|
+
value: defaultOptions[1].id,
|
|
976
|
+
onChangeInputValue: onChangeInputValue,
|
|
977
|
+
onChangeValue: onChangeValue,
|
|
978
|
+
autoComplete: "auto-complete-test",
|
|
979
|
+
type: "search"
|
|
980
|
+
})), baseElement = _render32.baseElement, queryByLabelText = _render32.queryByLabelText, rerender = _render32.rerender;
|
|
981
|
+
|
|
982
|
+
_react2.fireEvent.click(queryByLabelText('test'));
|
|
983
|
+
|
|
984
|
+
expect(queryByLabelText('test')).toHaveValue('value');
|
|
985
|
+
expect(queryByLabelText('test')).toHaveAttribute('autoComplete', 'auto-complete-test');
|
|
986
|
+
expect(queryByLabelText('test')).toHaveAttribute('type', 'search');
|
|
987
|
+
expect((0, _react2.queryByText)(baseElement, defaultOptions[1].label).parentElement).toHaveStyle("\n background: ".concat((0, _toColorString.default)(_color.default.interaction.pacificOcean), ";\n color: ").concat((0, _toColorString.default)(_color.default.base.snowWhite), ";\n "));
|
|
988
|
+
rerender(_react.default.createElement(_.default, {
|
|
989
|
+
label: "test",
|
|
990
|
+
options: defaultOptions,
|
|
991
|
+
inputValue: "second value",
|
|
992
|
+
value: defaultOptions[0].id,
|
|
993
|
+
onChangeInputValue: onChangeInputValue,
|
|
994
|
+
onChangeValue: onChangeValue
|
|
995
|
+
}));
|
|
996
|
+
expect(queryByLabelText('test')).toHaveValue('second value');
|
|
997
|
+
expect((0, _react2.queryByText)(baseElement, defaultOptions[0].label).parentElement).toHaveStyle("\n background: ".concat((0, _toColorString.default)(_color.default.interaction.pacificOcean), ";\n color: ").concat((0, _toColorString.default)(_color.default.base.snowWhite), ";\n "));
|
|
998
|
+
expect((0, _react2.queryByText)(baseElement, defaultOptions[1].label).parentElement).not.toHaveStyle("\n background: ".concat((0, _toColorString.default)(_color.default.interaction.pacificOcean), ";\n color: ").concat((0, _toColorString.default)(_color.default.base.snowWhite), ";\n "));
|
|
999
|
+
expect(onChangeInputValue).not.toHaveBeenCalled();
|
|
1000
|
+
expect(onChangeValue).not.toHaveBeenCalled();
|
|
785
1001
|
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
onChangeInputValue: onChangeInputValue,
|
|
792
|
-
onChangeValue: onChangeValue
|
|
793
|
-
})),
|
|
794
|
-
baseElement = _render27.baseElement,
|
|
795
|
-
queryByLabelText = _render27.queryByLabelText,
|
|
796
|
-
rerender = _render27.rerender;
|
|
1002
|
+
_react2.fireEvent.change(queryByLabelText('test'), {
|
|
1003
|
+
target: {
|
|
1004
|
+
value: 'third value'
|
|
1005
|
+
}
|
|
1006
|
+
});
|
|
797
1007
|
|
|
798
|
-
|
|
1008
|
+
expect(onChangeInputValue).toHaveBeenCalled();
|
|
1009
|
+
expect(newInputValue).toEqual('third value'); // an `inputValue` prop is _always_ preferred. until the component re-renders,
|
|
1010
|
+
// it should have keep the provided input value.
|
|
799
1011
|
|
|
800
|
-
|
|
801
|
-
expect((0, _react2.queryByText)(baseElement, defaultOptions[1].label).parentElement).toHaveStyle("\n background: ".concat((0, _toColorString.default)(_color.default.interaction.pacificOcean), ";\n color: ").concat((0, _toColorString.default)(_color.default.base.snowWhite), ";\n "));
|
|
802
|
-
rerender(_react.default.createElement(_.default, {
|
|
803
|
-
label: "test",
|
|
804
|
-
options: defaultOptions,
|
|
805
|
-
inputValue: "second value",
|
|
806
|
-
value: defaultOptions[0].id,
|
|
807
|
-
onChangeInputValue: onChangeInputValue,
|
|
808
|
-
onChangeValue: onChangeValue
|
|
809
|
-
}));
|
|
810
|
-
expect(queryByLabelText('test')).toHaveValue('second value');
|
|
811
|
-
expect((0, _react2.queryByText)(baseElement, defaultOptions[0].label).parentElement).toHaveStyle("\n background: ".concat((0, _toColorString.default)(_color.default.interaction.pacificOcean), ";\n color: ").concat((0, _toColorString.default)(_color.default.base.snowWhite), ";\n "));
|
|
812
|
-
expect((0, _react2.queryByText)(baseElement, defaultOptions[1].label).parentElement).not.toHaveStyle("\n background: ".concat((0, _toColorString.default)(_color.default.interaction.pacificOcean), ";\n color: ").concat((0, _toColorString.default)(_color.default.base.snowWhite), ";\n "));
|
|
813
|
-
expect(onChangeInputValue).not.toHaveBeenCalled();
|
|
814
|
-
expect(onChangeValue).not.toHaveBeenCalled();
|
|
1012
|
+
expect(queryByLabelText('test')).toHaveValue('second value');
|
|
815
1013
|
|
|
816
|
-
|
|
817
|
-
target: {
|
|
818
|
-
value: 'third value'
|
|
819
|
-
}
|
|
820
|
-
});
|
|
1014
|
+
_react2.fireEvent.click((0, _react2.queryByText)(baseElement, defaultOptions[1].label));
|
|
821
1015
|
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
1016
|
+
expect(onChangeValue).toHaveBeenCalledWith(defaultOptions[1].id, {
|
|
1017
|
+
removed: false
|
|
1018
|
+
});
|
|
825
1019
|
|
|
826
|
-
|
|
1020
|
+
_react2.fireEvent.click(queryByLabelText('test'));
|
|
827
1021
|
|
|
828
|
-
|
|
1022
|
+
expect((0, _react2.queryByText)(baseElement, defaultOptions[0].label).parentElement).toHaveStyle("\n background: ".concat((0, _toColorString.default)(_color.default.interaction.pacificOcean), ";\n color: ").concat((0, _toColorString.default)(_color.default.base.snowWhite), ";\n "));
|
|
1023
|
+
expect((0, _react2.queryByText)(baseElement, defaultOptions[1].label).parentElement).not.toHaveStyle("\n background: ".concat((0, _toColorString.default)(_color.default.interaction.pacificOcean), ";\n color: ").concat((0, _toColorString.default)(_color.default.base.snowWhite), ";\n "));
|
|
829
1024
|
|
|
830
|
-
|
|
1025
|
+
case 23:
|
|
1026
|
+
case "end":
|
|
1027
|
+
return _context.stop();
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
}, _callee);
|
|
1031
|
+
})));
|
|
1032
|
+
describe('when in multiple select mode', function () {
|
|
1033
|
+
describe('when a value is selected', function () {
|
|
1034
|
+
describe('when the "X" button is clicked to deselect a value', function () {
|
|
1035
|
+
it('calls the onChangeValue prop with removed: true', function () {
|
|
1036
|
+
var onChangeValue = jest.fn();
|
|
1037
|
+
|
|
1038
|
+
var _render33 = render(_react.default.createElement(_.default, {
|
|
1039
|
+
label: "test",
|
|
1040
|
+
options: defaultOptions,
|
|
1041
|
+
inputValue: "",
|
|
1042
|
+
value: [defaultOptions[1]],
|
|
1043
|
+
onChangeValue: onChangeValue,
|
|
1044
|
+
multiple: true
|
|
1045
|
+
})),
|
|
1046
|
+
queryByText = _render33.queryByText,
|
|
1047
|
+
queryByLabelText = _render33.queryByLabelText;
|
|
831
1048
|
|
|
832
|
-
|
|
1049
|
+
expect(queryByText(defaultOptions[1].label)).toBeInTheDocument();
|
|
1050
|
+
|
|
1051
|
+
_react2.fireEvent.click(queryByLabelText('Delete'));
|
|
833
1052
|
|
|
834
|
-
|
|
835
|
-
|
|
1053
|
+
expect(onChangeValue).toHaveBeenCalledWith(defaultOptions[1].id, expect.objectContaining({
|
|
1054
|
+
removed: true
|
|
1055
|
+
}));
|
|
1056
|
+
});
|
|
1057
|
+
});
|
|
1058
|
+
});
|
|
836
1059
|
});
|
|
837
1060
|
});
|
|
838
1061
|
});
|