@procore/core-react 11.25.1 → 11.26.0

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 (234) hide show
  1. package/babel.config.js +1 -1
  2. package/dist/Avatar/Avatar.styles.js +5 -5
  3. package/dist/AvatarStack/AvatarStack.styles.js +7 -7
  4. package/dist/Badge/Badge.styles.js +2 -2
  5. package/dist/Banner/Banner.d.ts +8 -0
  6. package/dist/Banner/Banner.js +13 -2
  7. package/dist/Banner/Banner.js.map +1 -1
  8. package/dist/Banner/Banner.styles.js +16 -11
  9. package/dist/Banner/Banner.styles.js.map +1 -1
  10. package/dist/Banner/Banner.types.d.ts +4 -2
  11. package/dist/Banner/Banner.types.js.map +1 -1
  12. package/dist/Banner/index.d.ts +1 -1
  13. package/dist/Banner/index.js +1 -1
  14. package/dist/Banner/index.js.map +1 -1
  15. package/dist/Box/Box.styles.js +1 -1
  16. package/dist/Breadcrumbs/Breadcrumbs.styles.js +4 -4
  17. package/dist/Button/Button.styles.js +5 -5
  18. package/dist/Calendar/Calendar.styles.js +8 -8
  19. package/dist/Card/Card.styles.js +1 -1
  20. package/dist/Checkbox/Checkbox.styles.js +6 -6
  21. package/dist/ContactItem/ContactItem.styles.js +5 -5
  22. package/dist/Content/Content.styles.js +2 -2
  23. package/dist/DateInput/DateInput.styles.js +6 -6
  24. package/dist/DetailPage/DetailPage.styles.js +10 -10
  25. package/dist/DetailPage/DetailPage.styles.js.map +1 -1
  26. package/dist/DetailPage/examples/TableExample.d.ts +2 -0
  27. package/dist/DetailPage/examples/TableExample.js +141 -0
  28. package/dist/DetailPage/examples/TableExample.js.map +1 -0
  29. package/dist/Dropdown/Dropdown.styles.js +3 -3
  30. package/dist/DropdownFlyout/DropdownFlyout.styles.js +4 -4
  31. package/dist/Dropzone/Dropzone.js +1 -1
  32. package/dist/Dropzone/Dropzone.styles.js +9 -9
  33. package/dist/EmptyState/EmptyState.styles.js +6 -6
  34. package/dist/Field/Field.styles.js +3 -3
  35. package/dist/FileList/FileList.styles.js +4 -4
  36. package/dist/FileSelect/FileExplorer/FileExplorer.styles.js +9 -9
  37. package/dist/FileSelect/FileExplorer/FileExplorerSidebar.styles.js +3 -3
  38. package/dist/FileSelect/FileSelect.styles.js +2 -2
  39. package/dist/FileSelect/FileSelectDropzone/FileSelectDropzone.styles.js +3 -3
  40. package/dist/FileSelect/FileTokenList/FileTokenList.styles.js +2 -2
  41. package/dist/FileSelect/GridSource/GridSource.styles.js +6 -6
  42. package/dist/FileSelect/LocalSource/LocalSource.styles.js +4 -4
  43. package/dist/FileSelect/SourceItem/SourceItem.styles.js +3 -3
  44. package/dist/FileSelect/ThumbnailList/ThumbnailList.styles.js +6 -6
  45. package/dist/FileSelect/TreeSource/TreeSource.styles.js +1 -1
  46. package/dist/FileToken/FileToken.styles.js +4 -4
  47. package/dist/FilterToken/FilterToken.styles.js +2 -2
  48. package/dist/FlexList/FlexList.styles.js +1 -1
  49. package/dist/Form/Form.styles.js +16 -16
  50. package/dist/Grid/Grid.styles.js +2 -2
  51. package/dist/GroupSelect/GroupSelect.styles.js +1 -1
  52. package/dist/Input/Input.styles.js +1 -1
  53. package/dist/Link/Link.styles.js +2 -2
  54. package/dist/Link/Link.styles.js.map +1 -1
  55. package/dist/ListPage/ListPage.styles.js +8 -8
  56. package/dist/Loader/Loader.styles.js +2 -2
  57. package/dist/MenuImperative/MenuImperative.styles.js +10 -10
  58. package/dist/Modal/Modal.styles.js +13 -13
  59. package/dist/MultiSelect/MultiSelect.styles.js +6 -6
  60. package/dist/NextMenu/NextMenu.styles.js +3 -3
  61. package/dist/Notation/Notation.js +1 -1
  62. package/dist/NumberInput/NumberInput.styles.js +7 -7
  63. package/dist/Overlay/OverlayArrow.styles.js +1 -1
  64. package/dist/PageLayout/PageLayout.styles.js +14 -14
  65. package/dist/PageLayout/PageLayout.styles.js.map +1 -1
  66. package/dist/Pagination/Pagination.styles.js +5 -5
  67. package/dist/Panel/Panel.styles.js +11 -11
  68. package/dist/Pill/Pill.styles.js +2 -2
  69. package/dist/PillSelect/PillSelect.styles.js +4 -4
  70. package/dist/Popover/Popover.styles.js +2 -2
  71. package/dist/Portal/Portal.styles.js +1 -1
  72. package/dist/ProgressBar/ProgressBar.styles.js +2 -2
  73. package/dist/RadioButton/RadioButton.styles.js +3 -3
  74. package/dist/Required/Required.styles.js +3 -3
  75. package/dist/Search/Search.styles.js +5 -5
  76. package/dist/Section/Section.styles.d.ts +1 -1
  77. package/dist/Section/Section.styles.js +6 -6
  78. package/dist/SegmentedController/SegmentedController.styles.js +4 -4
  79. package/dist/Select/Select.styles.js +7 -7
  80. package/dist/Semantic/Semantic.d.ts +6 -1
  81. package/dist/Semantic/Semantic.js +7 -1
  82. package/dist/Semantic/Semantic.js.map +1 -1
  83. package/dist/Semantic/Semantic.styles.d.ts +14 -4
  84. package/dist/Semantic/Semantic.styles.js +20 -10
  85. package/dist/Semantic/Semantic.styles.js.map +1 -1
  86. package/dist/Semantic/index.d.ts +1 -1
  87. package/dist/Semantic/index.js +1 -1
  88. package/dist/Semantic/index.js.map +1 -1
  89. package/dist/Sidebar/Sidebar.styles.js +7 -7
  90. package/dist/Slider/Slider.styles.js +5 -5
  91. package/dist/Spinner/Spinner.styles.js +7 -7
  92. package/dist/SuperSelect/SuperSelect.presets.styles.js +1 -1
  93. package/dist/SuperSelect/SuperSelect.styles.js +37 -37
  94. package/dist/Switch/Switch.styles.js +4 -4
  95. package/dist/Table/Table.styles.js +28 -28
  96. package/dist/TableShelf/TableShelf.styles.js +5 -5
  97. package/dist/Tabs/Tabs.styles.js +8 -8
  98. package/dist/Tearsheet/Tearsheet.styles.js +5 -5
  99. package/dist/TextArea/TextArea.styles.js +1 -1
  100. package/dist/TextEditorOutput/TextEditorOutput.styles.js +1 -1
  101. package/dist/Thumbnail/Thumbnail.styles.js +17 -17
  102. package/dist/ThumbnailGrid/ThumbnailGrid.styles.js +7 -7
  103. package/dist/TieredSelect/TieredSelect.js +6 -1
  104. package/dist/TieredSelect/TieredSelect.js.map +1 -1
  105. package/dist/TieredSelect/TieredSelect.styles.js +9 -9
  106. package/dist/Tile/Tile.styles.js +8 -8
  107. package/dist/Title/Title.d.ts +2 -2
  108. package/dist/Title/Title.js.map +1 -1
  109. package/dist/Title/Title.styles.d.ts +2 -1
  110. package/dist/Title/Title.styles.js +13 -10
  111. package/dist/Title/Title.styles.js.map +1 -1
  112. package/dist/Title/Title.types.d.ts +7 -0
  113. package/dist/Title/Title.types.js.map +1 -1
  114. package/dist/Toast/Toast.styles.js +3 -3
  115. package/dist/ToggleButton/ToggleButton.styles.js +1 -1
  116. package/dist/Token/Token.styles.js +3 -3
  117. package/dist/ToolHeader/ToolHeader.styles.js +6 -6
  118. package/dist/Tooltip/Tooltip.styles.js +2 -2
  119. package/dist/Tree/Tree.styles.js +9 -9
  120. package/dist/Typeahead/Typeahead.styles.js +3 -3
  121. package/dist/Typography/Typography.styles.js +1 -1
  122. package/dist/Typography/Typography.table.story.js +2 -2
  123. package/dist/_hooks/ScrollLock.js +11 -0
  124. package/dist/_hooks/ScrollLock.js.map +1 -1
  125. package/dist/_typedoc/Avatar/Avatar.types.json +20 -20
  126. package/dist/_typedoc/AvatarStack/AvatarStack.types.json +23 -23
  127. package/dist/_typedoc/Badge/Badge.types.json +6 -6
  128. package/dist/_typedoc/Banner/Banner.types.json +16 -16
  129. package/dist/_typedoc/Box/Box.types.json +68 -68
  130. package/dist/_typedoc/Breadcrumbs/Breadcrumbs.types.json +10 -10
  131. package/dist/_typedoc/Button/Button.types.json +11 -11
  132. package/dist/_typedoc/Calendar/Calendar.types.json +80 -80
  133. package/dist/_typedoc/Card/Card.types.json +6 -6
  134. package/dist/_typedoc/Checkbox/Checkbox.types.json +9 -9
  135. package/dist/_typedoc/ContactItem/ContactItem.types.json +9 -9
  136. package/dist/_typedoc/DateInput/DateInput.types.json +35 -35
  137. package/dist/_typedoc/DateSelect/DateSelect.types.json +13 -13
  138. package/dist/_typedoc/DetailPage/DetailPage.types.json +4 -4
  139. package/dist/_typedoc/Dropdown/Dropdown.types.json +37 -37
  140. package/dist/_typedoc/DropdownFlyout/DropdownFlyout.types.json +29 -29
  141. package/dist/_typedoc/Dropzone/Dropzone.types.json +41 -41
  142. package/dist/_typedoc/EmptyState/EmptyState.types.json +14 -14
  143. package/dist/_typedoc/FileList/FileList.types.json +9 -9
  144. package/dist/_typedoc/FileSelect/FileSelect.types.json +26 -26
  145. package/dist/_typedoc/FileSelect/GridSource/GridSource.types.json +20 -20
  146. package/dist/_typedoc/FileSelect/LocalSource/LocalSource.types.json +14 -14
  147. package/dist/_typedoc/FileSelect/TreeSource/TreeSource.types.json +9 -9
  148. package/dist/_typedoc/Flex/Flex.types.json +27 -27
  149. package/dist/_typedoc/FlexList/FlexList.types.json +30 -30
  150. package/dist/_typedoc/Form/Form.types.json +726 -726
  151. package/dist/_typedoc/Grid/Grid.types.json +8 -8
  152. package/dist/_typedoc/GroupSelect/GroupSelect.types.json +52 -52
  153. package/dist/_typedoc/Input/Input.types.json +2 -2
  154. package/dist/_typedoc/Link/Link.types.json +4 -4
  155. package/dist/_typedoc/ListPage/ListPage.types.json +13 -13
  156. package/dist/_typedoc/Menu/Menu.types.json +62 -62
  157. package/dist/_typedoc/MenuImperative/MenuImperative.types.json +74 -74
  158. package/dist/_typedoc/Modal/Modal.types.json +41 -41
  159. package/dist/_typedoc/MultiSelect/MultiSelect.types.json +31 -31
  160. package/dist/_typedoc/Notation/Notation.types.json +4 -4
  161. package/dist/_typedoc/NumberInput/NumberInput.types.json +38 -38
  162. package/dist/_typedoc/OverlayTrigger/OverlayTrigger.types.json +31 -31
  163. package/dist/_typedoc/PageLayout/PageLayout.types.json +22 -22
  164. package/dist/_typedoc/Pagination/Pagination.types.json +7 -7
  165. package/dist/_typedoc/Panel/Panel.types.json +27 -27
  166. package/dist/_typedoc/Pill/Pill.types.json +2 -2
  167. package/dist/_typedoc/PillSelect/PillSelect.types.json +47 -47
  168. package/dist/_typedoc/Popover/Popover.types.json +14 -14
  169. package/dist/_typedoc/ProgressBar/ProgressBar.types.json +6 -6
  170. package/dist/_typedoc/RadioButton/RadioButton.types.json +6 -6
  171. package/dist/_typedoc/Required/Required.types.json +5 -5
  172. package/dist/_typedoc/Search/Search.types.json +18 -18
  173. package/dist/_typedoc/Section/Section.types.json +14 -14
  174. package/dist/_typedoc/SegmentedController/SegmentedController.types.json +20 -20
  175. package/dist/_typedoc/Select/Select.types.json +57 -57
  176. package/dist/_typedoc/Slider/Slider.types.json +6 -6
  177. package/dist/_typedoc/Spinner/Spinner.types.json +9 -9
  178. package/dist/_typedoc/Switch/Switch.types.json +3 -3
  179. package/dist/_typedoc/Table/Table.types.json +97 -97
  180. package/dist/_typedoc/Tabs/Tabs.types.json +17 -17
  181. package/dist/_typedoc/Tearsheet/Tearsheet.types.json +16 -16
  182. package/dist/_typedoc/TextArea/TextArea.types.json +3 -3
  183. package/dist/_typedoc/TextEditor/TextEditor.types.json +9 -9
  184. package/dist/_typedoc/TextEditorOutput/TextEditorOutput.types.json +4 -4
  185. package/dist/_typedoc/Thumbnail/Thumbnail.types.json +19 -19
  186. package/dist/_typedoc/TieredDropdown/TieredDropdown.types.json +42 -42
  187. package/dist/_typedoc/TieredSelect/TieredSelect.types.json +28 -28
  188. package/dist/_typedoc/Tile/Tile.types.json +30 -30
  189. package/dist/_typedoc/Title/Title.types.json +23 -0
  190. package/dist/_typedoc/Toast/Toast.types.json +4 -4
  191. package/dist/_typedoc/ToggleButton/ToggleButton.types.json +3 -3
  192. package/dist/_typedoc/Token/Token.types.json +4 -4
  193. package/dist/_typedoc/ToolHeader/ToolHeader.types.json +10 -10
  194. package/dist/_typedoc/Tooltip/Tooltip.types.json +13 -13
  195. package/dist/_typedoc/Tree/Tree.types.json +86 -86
  196. package/dist/_typedoc/Typeahead/Typeahead.types.json +2 -2
  197. package/dist/_typedoc/Typography/Typography.types.json +8 -8
  198. package/dist/_typedoc/_utils/types.json +3 -3
  199. package/dist/_utils/propsTypedoc.d.ts +1 -0
  200. package/dist/_utils/propsTypedoc.js +1 -0
  201. package/dist/_utils/propsTypedoc.js.map +1 -1
  202. package/dist/index.d.ts +1 -0
  203. package/dist/index.js +1 -0
  204. package/dist/index.js.map +1 -1
  205. package/package.json +13 -10
  206. package/tsconfig.prod.json +7 -1
  207. package/dist/FileSelect/SourceItem/SourceItem.test.js +0 -53
  208. package/dist/MultiSelect/MultiSelect.test.js +0 -250
  209. package/dist/OverlayTrigger/OverlayTrigger.test.js +0 -483
  210. package/dist/SuperSelect/SuperSelect.utils.test.js +0 -717
  211. package/dist/SuperSelect/useSuperSelect.test.js +0 -1284
  212. package/dist/_hooks/OverflowObserver/OverflowObserver.test.js +0 -110
  213. package/dist/_hooks/__tests__/Anchor.test.js +0 -109
  214. package/dist/_hooks/__tests__/BoundingRect.test.js +0 -85
  215. package/dist/_hooks/__tests__/Buffer.test.js +0 -76
  216. package/dist/_hooks/__tests__/DateTime.test.js +0 -136
  217. package/dist/_hooks/__tests__/DelayedCallback.test.js +0 -119
  218. package/dist/_hooks/__tests__/DelayedToggle.test.js +0 -50
  219. package/dist/_hooks/__tests__/Deprecation.test.js +0 -58
  220. package/dist/_hooks/__tests__/Event.test.js +0 -46
  221. package/dist/_hooks/__tests__/EventListener.test.js +0 -124
  222. package/dist/_hooks/__tests__/Hotkey.test.js +0 -18
  223. package/dist/_hooks/__tests__/InjectedScript.test.js +0 -80
  224. package/dist/_hooks/__tests__/ListNavigation.test.js +0 -101
  225. package/dist/_hooks/__tests__/TextEntry.test.js +0 -92
  226. package/dist/_hooks/__tests__/Timer.test.js +0 -60
  227. package/dist/_hooks/__tests__/Trigger.test.js +0 -52
  228. package/dist/_hooks/__tests__/Visibility.test.js +0 -86
  229. package/dist/_hooks/__tests__/ZIndex.test.js +0 -76
  230. package/dist/_utils/__tests__/CalendarHelpers.test.js +0 -64
  231. package/dist/_utils/__tests__/filename.test.js +0 -27
  232. package/dist/_utils/__tests__/getAnchorPosition.test.js +0 -250
  233. package/dist/_utils/__tests__/mergeRefs.test.js +0 -58
  234. package/dist/_utils/__tests__/slotify.test.js +0 -152
@@ -1,1284 +0,0 @@
1
- import { act, renderHook } from '@testing-library/react-hooks'
2
- import {
3
- draggableOptionIdSymbol,
4
- isOptgroupSymbol,
5
- } from './SuperSelect.constants'
6
- import { useSuperSelect } from './useSuperSelect'
7
-
8
- describe('setSearchValue', () => {
9
- jest.useFakeTimers()
10
-
11
- test('should set new searchValue', () => {
12
- const { result } = renderHook(() => useSuperSelect({}))
13
-
14
- act(() => {
15
- result.current.state.setSearchValue('ababa')
16
- result.current.state.setSearchValue('ababa2')
17
- result.current.state.setSearchValue('ababa1')
18
- jest.runAllTimers()
19
- })
20
-
21
- expect(result.current.state.searchValue).toEqual('ababa1')
22
-
23
- act(() => {
24
- result.current.state.setSearchValue('The value')
25
- jest.runAllTimers()
26
- })
27
-
28
- expect(result.current.state.searchValue).toEqual('The value')
29
- })
30
- })
31
-
32
- describe('getClearProps', () => {
33
- test('should return value [] and set open true', () => {
34
- const { result } = renderHook(() =>
35
- useSuperSelect({ multiple: true, initialValue: ['123', '321'] })
36
- )
37
-
38
- const stopPropagationMock = jest.fn()
39
-
40
- act(() => {
41
- result.current.props.clear().onClick({
42
- stopPropagation: stopPropagationMock,
43
- })
44
- })
45
-
46
- expect(result.current.state.value).toEqual([])
47
- expect(result.current.state.open).toEqual(true)
48
- })
49
- })
50
-
51
- describe('getOptionGroup', () => {
52
- test('should return group name default', () => {
53
- const { result } = renderHook(() => useSuperSelect({}))
54
- expect(
55
- result.current.option.group({
56
- id: 2,
57
- label: 'item 2',
58
- group: 'Group 1',
59
- })
60
- ).toEqual('Group 1')
61
-
62
- expect(
63
- result.current.option.group({
64
- id: 2,
65
- label: 'item 2',
66
- })
67
- ).toEqual('')
68
- })
69
-
70
- test('should return option group custom', () => {
71
- const { result } = renderHook(() =>
72
- useSuperSelect({
73
- getOptionGroup: (option) => option?.customGroup ?? '',
74
- })
75
- )
76
-
77
- expect(
78
- result.current.option.group({
79
- id: 2,
80
- label: 'item 2',
81
- customGroup: 'Group custom',
82
- })
83
- ).toEqual('Group custom')
84
-
85
- expect(
86
- result.current.option.group({
87
- id: 2,
88
- label: 'item 2',
89
- })
90
- ).toEqual('')
91
- })
92
- })
93
-
94
- describe('getOptionIsBatch', () => {
95
- test('should return true if is batch', () => {
96
- const { result } = renderHook(() => useSuperSelect({}))
97
- expect(
98
- result.current.option.isBatch({
99
- id: '1',
100
- group: 'Groups 1',
101
- value: [2, 4, 6],
102
- label: 'Group B',
103
- disabled: false,
104
- })
105
- ).toEqual(true)
106
-
107
- expect(
108
- result.current.option.isBatch({
109
- id: '1',
110
- group: 'Groups 1',
111
- option: 'test 1',
112
- label: 'Group B',
113
- disabled: false,
114
- })
115
- ).toEqual(false)
116
- })
117
-
118
- test('should return true if is custom batch', () => {
119
- const { result } = renderHook(() =>
120
- useSuperSelect({
121
- getOptionIsBatch: (option) => {
122
- return Array.isArray(option?.customValue)
123
- },
124
- })
125
- )
126
-
127
- expect(
128
- result.current.option.isBatch({
129
- id: '1',
130
- group: 'Groups 1',
131
- customValue: [2, 4, 6],
132
- label: 'Group B',
133
- disabled: false,
134
- })
135
- ).toEqual(true)
136
-
137
- expect(
138
- result.current.option.isBatch({
139
- id: '1',
140
- group: 'Groups 1',
141
- label: 'Group B',
142
- disabled: false,
143
- })
144
- ).toEqual(false)
145
- })
146
- })
147
-
148
- describe('getOptionIsDisabled', () => {
149
- test('should return true if option is disabled', () => {
150
- const { result } = renderHook(() => useSuperSelect({}))
151
-
152
- expect(
153
- result.current.option.isDisabled({
154
- id: 2,
155
- label: 'item 2',
156
- group: 'Group 1',
157
- disabled: true,
158
- })
159
- ).toEqual(true)
160
-
161
- expect(
162
- result.current.option.isDisabled({
163
- id: 2,
164
- label: 'item 2',
165
- group: 'Group 1',
166
- })
167
- ).toEqual(false)
168
- })
169
-
170
- test('should return true if option is disabled custom', () => {
171
- const { result } = renderHook(() =>
172
- useSuperSelect({
173
- getOptionIsDisabled: (option) => {
174
- return option?.customDisabled ?? false
175
- },
176
- })
177
- )
178
-
179
- expect(
180
- result.current.option.isDisabled({
181
- id: 2,
182
- label: 'item 2',
183
- group: 'Group 1',
184
- customDisabled: true,
185
- })
186
- ).toEqual(true)
187
-
188
- expect(
189
- result.current.option.isDisabled({
190
- id: 2,
191
- label: 'item 2',
192
- group: 'Group 1',
193
- })
194
- ).toEqual(false)
195
- })
196
- })
197
-
198
- describe('getOptionLabel', () => {
199
- test('should return label', () => {
200
- const { result } = renderHook(() => useSuperSelect({}))
201
-
202
- expect(
203
- result.current.option.label({
204
- id: 2,
205
- label: 'item 2',
206
- group: 'Group 1',
207
- })
208
- ).toEqual('item 2')
209
-
210
- expect(
211
- result.current.option.label({
212
- id: 2,
213
- group: 'Group 1',
214
- })
215
- ).toEqual('')
216
- })
217
-
218
- test('should return custom label', () => {
219
- const { result } = renderHook(() =>
220
- useSuperSelect({
221
- getOptionLabel: (option) => {
222
- return option?.customLabel ?? ''
223
- },
224
- })
225
- )
226
-
227
- expect(
228
- result.current.option.label({
229
- id: 2,
230
- customLabel: 'item 2',
231
- group: 'Group 1',
232
- })
233
- ).toEqual('item 2')
234
-
235
- expect(
236
- result.current.option.label({
237
- id: 2,
238
- group: 'Group 1',
239
- })
240
- ).toEqual('')
241
- })
242
- })
243
-
244
- describe('onSelect', () => {
245
- describe('multiple', () => {
246
- test('should handle batch option value', () => {
247
- const { result } = renderHook(() =>
248
- useSuperSelect({ multiple: true, defaultValue: ['123', '321'] })
249
- )
250
-
251
- act(() => {
252
- result.current.state.onSelect({
253
- value: ['456', '123'],
254
- })
255
- })
256
-
257
- expect(result.current.state.value).toEqual(['123', '321', '456'])
258
- })
259
-
260
- test('should not select disabled option', () => {
261
- const { result } = renderHook(() =>
262
- useSuperSelect({ multiple: true, defaultValue: ['123', '321'] })
263
- )
264
-
265
- act(() => {
266
- result.current.state.onSelect({
267
- value: ['456', '123'],
268
- disabled: true,
269
- })
270
- })
271
-
272
- expect(result.current.state.value).toEqual(['123', '321'])
273
- })
274
-
275
- test('should handle regular option', () => {
276
- const { result } = renderHook(() =>
277
- useSuperSelect({ multiple: true, defaultValue: ['123', '321'] })
278
- )
279
-
280
- act(() => {
281
- result.current.state.onSelect({
282
- value: '456',
283
- })
284
- })
285
-
286
- expect(result.current.state.value).toEqual(['123', '321', '456'])
287
- })
288
- })
289
-
290
- describe('single', () => {
291
- test('should not select disabled option', () => {
292
- const { result } = renderHook(() =>
293
- useSuperSelect({ multiple: false, defaultValue: '123' })
294
- )
295
-
296
- act(() => {
297
- result.current.state.onSelect({
298
- value: '456',
299
- disabled: true,
300
- })
301
- })
302
-
303
- expect(result.current.state.value).toEqual('123')
304
- })
305
-
306
- test('should set new value', () => {
307
- const { result } = renderHook(() =>
308
- useSuperSelect({ multiple: false, defaultValue: '123' })
309
- )
310
-
311
- act(() => {
312
- result.current.state.onSelect({
313
- value: '456',
314
- })
315
- })
316
-
317
- expect(result.current.state.value).toEqual('456')
318
- })
319
- })
320
- })
321
-
322
- describe('controlled API', () => {
323
- test('should always return value when passed value', () => {
324
- const { result } = renderHook(() => useSuperSelect({ value: '123' }))
325
-
326
- expect(result.current.state.value).toEqual('123')
327
- })
328
-
329
- test('should call onChange when value is changed', () => {
330
- const onChangeMock = jest.fn()
331
- const { result, rerender } = renderHook(useSuperSelect, {
332
- initialProps: {
333
- value: '123',
334
- onChange: onChangeMock,
335
- },
336
- })
337
-
338
- act(() => {
339
- result.current.state.onSelect({
340
- value: '456',
341
- })
342
- })
343
-
344
- rerender({ value: '456' })
345
-
346
- expect(onChangeMock).toHaveBeenCalledWith('456')
347
- expect(result.current.state.value).toEqual('456')
348
- })
349
- })
350
-
351
- describe('uncontrolled API', () => {
352
- test('should call onChange when the value is changed', () => {
353
- const onChangeMock = jest.fn()
354
-
355
- const { result } = renderHook(() =>
356
- useSuperSelect({
357
- defaultValue: '123',
358
- onChange: (v) => {
359
- onChangeMock(v)
360
- },
361
- })
362
- )
363
-
364
- expect(onChangeMock).not.toHaveBeenCalled()
365
- expect(result.current.state.value).toEqual('123')
366
-
367
- act(() => {
368
- result.current.state.onSelect({
369
- value: '321',
370
- })
371
- })
372
-
373
- expect(onChangeMock).toHaveBeenCalledWith('321')
374
- expect(result.current.state.value).toEqual('321')
375
- })
376
- })
377
-
378
- describe('options', () => {
379
- describe('draggable = false', () => {
380
- describe('sorted', () => {
381
- test('should return unfiltered array', () => {
382
- const { result } = renderHook(useSuperSelect, {
383
- initialProps: {
384
- options: [
385
- { label: 'value 0', value: 0, group: 'Group 1' },
386
- {
387
- label: 'value 1',
388
- value: 1,
389
- },
390
- {
391
- label: 'Batch Group 1.1',
392
- value: [4, 6],
393
- group: 'Group 1',
394
- disabled: false,
395
- },
396
- {
397
- label: 'Batch Group 1.2',
398
- value: [1, 7],
399
- group: 'Group 1',
400
- disabled: false,
401
- },
402
- {
403
- value: [2, 3, 5],
404
- label: 'Batch Group',
405
- group: 'Batch Group',
406
- disabled: false,
407
- },
408
- {
409
- value: [9, 8, 10],
410
- label: 'Batch Ungrouped',
411
- disabled: false,
412
- },
413
- { label: 'value 2', value: 2, group: 'Group 2' },
414
- { label: 'value 3', value: 3, group: 'Group 2' },
415
- {
416
- label: 'Batch Group 2',
417
- value: [11, 12, 13],
418
- group: 'Group 2',
419
- disabled: false,
420
- },
421
- ],
422
- multiple: true,
423
- value: [2, 3, 5],
424
- },
425
- })
426
-
427
- expect(result.current.state.options).toEqual([
428
- {
429
- value: [9, 8, 10],
430
- label: 'Batch Ungrouped',
431
- disabled: false,
432
- },
433
- {
434
- label: 'value 1',
435
- value: 1,
436
- },
437
- {
438
- id: 'Batch Group',
439
- label: 'Batch Group',
440
- [isOptgroupSymbol]: true,
441
- },
442
- {
443
- value: [2, 3, 5],
444
- label: 'Batch Group',
445
- group: 'Batch Group',
446
- disabled: true,
447
- },
448
- {
449
- id: 'Group 1',
450
- label: 'Group 1',
451
- [isOptgroupSymbol]: true,
452
- },
453
- {
454
- label: 'Batch Group 1.1',
455
- value: [4, 6],
456
- group: 'Group 1',
457
- disabled: false,
458
- },
459
- {
460
- label: 'Batch Group 1.2',
461
- value: [1, 7],
462
- group: 'Group 1',
463
- disabled: false,
464
- },
465
- { label: 'value 0', value: 0, group: 'Group 1' },
466
- {
467
- id: 'Group 2',
468
- label: 'Group 2',
469
- [isOptgroupSymbol]: true,
470
- },
471
- {
472
- label: 'Batch Group 2',
473
- value: [11, 12, 13],
474
- group: 'Group 2',
475
- disabled: false,
476
- },
477
- { label: 'value 2', value: 2, group: 'Group 2' },
478
- { label: 'value 3', value: 3, group: 'Group 2' },
479
- ])
480
- })
481
-
482
- test('should return filtered array', () => {
483
- jest.useFakeTimers()
484
-
485
- const { result } = renderHook(useSuperSelect, {
486
- initialProps: {
487
- options: [
488
- { label: 'value 0', value: 0, group: 'Group 1' },
489
- {
490
- label: 'value 1',
491
- value: 1,
492
- },
493
- {
494
- label: 'Batch Group 1.1',
495
- value: [4, 6],
496
- group: 'Group 1',
497
- disabled: false,
498
- },
499
- {
500
- label: 'Batch Group 1.2',
501
- value: [1, 7],
502
- group: 'Group 1',
503
- disabled: false,
504
- },
505
- {
506
- value: [2, 3, 5],
507
- label: 'Batch Group',
508
- group: 'Batch Group',
509
- disabled: false,
510
- },
511
- {
512
- value: [9, 8, 10],
513
- label: 'Batch Ungrouped',
514
- disabled: false,
515
- },
516
- { label: 'value 2', value: 2, group: 'Group 2' },
517
- { label: 'value 3', value: 3, group: 'Group 2' },
518
- {
519
- label: 'Batch Group 2',
520
- value: [11, 12, 13],
521
- group: 'Group 2',
522
- disabled: false,
523
- },
524
- ],
525
- multiple: true,
526
- value: [2, 3, 5],
527
- },
528
- })
529
-
530
- act(() => {
531
- result.current.state.setSearchValue('value')
532
- jest.runAllTimers()
533
- })
534
-
535
- expect(result.current.state.options).toEqual([
536
- {
537
- label: 'value 1',
538
- value: 1,
539
- },
540
- {
541
- id: 'Group 1',
542
- label: 'Group 1',
543
- [isOptgroupSymbol]: true,
544
- },
545
- {
546
- group: 'Group 1',
547
- label: 'value 0',
548
- value: 0,
549
- },
550
- {
551
- id: 'Group 2',
552
- label: 'Group 2',
553
- [isOptgroupSymbol]: true,
554
- },
555
- { label: 'value 2', value: 2, group: 'Group 2' },
556
- { label: 'value 3', value: 3, group: 'Group 2' },
557
- ])
558
- })
559
- })
560
-
561
- describe('unsorted', () => {
562
- test('should return unfiltered array', () => {
563
- const { result } = renderHook(useSuperSelect, {
564
- initialProps: {
565
- options: [
566
- { label: 'value 0', value: 0, group: 'Group 1' },
567
- {
568
- label: 'value 1',
569
- value: 1,
570
- },
571
- {
572
- label: 'Batch Group 1.1',
573
- value: [4, 6],
574
- group: 'Group 1',
575
- disabled: false,
576
- },
577
- {
578
- label: 'Batch Group 1.2',
579
- value: [1, 7],
580
- group: 'Group 1',
581
- disabled: false,
582
- },
583
- {
584
- value: [2, 3, 5],
585
- label: 'Batch Group',
586
- group: 'Batch Group',
587
- disabled: false,
588
- },
589
- {
590
- value: [9, 8, 10],
591
- label: 'Batch Ungrouped',
592
- disabled: false,
593
- },
594
- { label: 'value 2', value: 2, group: 'Group 2' },
595
- { label: 'value 3', value: 3, group: 'Group 2' },
596
- {
597
- label: 'Batch Group 2',
598
- value: [11, 12, 13],
599
- group: 'Group 2',
600
- disabled: false,
601
- },
602
- ],
603
- multiple: true,
604
- value: [2, 3, 5],
605
- sort: false,
606
- },
607
- })
608
-
609
- expect(result.current.state.options).toEqual([
610
- {
611
- label: 'value 1',
612
- value: 1,
613
- },
614
- {
615
- value: [9, 8, 10],
616
- label: 'Batch Ungrouped',
617
- disabled: false,
618
- },
619
- {
620
- id: 'Group 1',
621
- label: 'Group 1',
622
- [isOptgroupSymbol]: true,
623
- },
624
- { label: 'value 0', value: 0, group: 'Group 1' },
625
- {
626
- label: 'Batch Group 1.1',
627
- value: [4, 6],
628
- group: 'Group 1',
629
- disabled: false,
630
- },
631
- {
632
- label: 'Batch Group 1.2',
633
- value: [1, 7],
634
- group: 'Group 1',
635
- disabled: false,
636
- },
637
- {
638
- id: 'Batch Group',
639
- label: 'Batch Group',
640
- [isOptgroupSymbol]: true,
641
- },
642
- {
643
- value: [2, 3, 5],
644
- label: 'Batch Group',
645
- group: 'Batch Group',
646
- disabled: true,
647
- },
648
- {
649
- id: 'Group 2',
650
- label: 'Group 2',
651
- [isOptgroupSymbol]: true,
652
- },
653
- { label: 'value 2', value: 2, group: 'Group 2' },
654
- { label: 'value 3', value: 3, group: 'Group 2' },
655
- {
656
- label: 'Batch Group 2',
657
- value: [11, 12, 13],
658
- group: 'Group 2',
659
- disabled: false,
660
- },
661
- ])
662
- })
663
-
664
- test('should return filtered array', () => {
665
- jest.useFakeTimers()
666
-
667
- const { result } = renderHook(useSuperSelect, {
668
- initialProps: {
669
- options: [
670
- { label: 'value 0', value: 0, group: 'Group 1' },
671
- {
672
- label: 'value 1',
673
- value: 1,
674
- },
675
- {
676
- label: 'Batch Group 1.1',
677
- value: [4, 6],
678
- group: 'Group 1',
679
- disabled: false,
680
- },
681
- {
682
- label: 'Batch Group 1.2',
683
- value: [1, 7],
684
- group: 'Group 1',
685
- disabled: false,
686
- },
687
- {
688
- value: [2, 3, 5],
689
- label: 'Batch Group',
690
- group: 'Batch Group',
691
- disabled: false,
692
- },
693
- {
694
- value: [9, 8, 10],
695
- label: 'Batch Ungrouped',
696
- disabled: false,
697
- },
698
- { label: 'value 2', value: 2, group: 'Group 2' },
699
- { label: 'value 3', value: 3, group: 'Group 2' },
700
- {
701
- label: 'Batch Group 2',
702
- value: [11, 12, 13],
703
- group: 'Group 2',
704
- disabled: false,
705
- },
706
- ],
707
- multiple: true,
708
- value: [2, 3, 5],
709
- sort: false,
710
- },
711
- })
712
-
713
- act(() => {
714
- result.current.state.setSearchValue('value')
715
- jest.runAllTimers()
716
- })
717
-
718
- expect(result.current.state.options).toEqual([
719
- {
720
- label: 'value 1',
721
- value: 1,
722
- },
723
- {
724
- id: 'Group 1',
725
- label: 'Group 1',
726
- [isOptgroupSymbol]: true,
727
- },
728
- { label: 'value 0', value: 0, group: 'Group 1' },
729
- {
730
- id: 'Group 2',
731
- label: 'Group 2',
732
- [isOptgroupSymbol]: true,
733
- },
734
- { label: 'value 2', value: 2, group: 'Group 2' },
735
- { label: 'value 3', value: 3, group: 'Group 2' },
736
- ])
737
- })
738
- })
739
- })
740
-
741
- describe('draggable = true', () => {
742
- describe('sorted', () => {
743
- test('should return filtered array', () => {
744
- jest.useFakeTimers()
745
-
746
- const { result } = renderHook(useSuperSelect, {
747
- initialProps: {
748
- draggable: true,
749
- options: [
750
- { label: 'value 0', value: 0, group: 'Group 1' },
751
- {
752
- label: 'value 1',
753
- value: 1,
754
- },
755
- {
756
- label: 'Batch Group 1.1',
757
- value: [4, 6],
758
- group: 'Group 1',
759
- disabled: false,
760
- },
761
- {
762
- label: 'Batch Group 1.2',
763
- value: [1, 7],
764
- group: 'Group 1',
765
- disabled: false,
766
- },
767
- {
768
- value: [2, 3, 5],
769
- label: 'Batch Group',
770
- group: 'Batch Group',
771
- disabled: false,
772
- },
773
- {
774
- value: [2, 3, 5],
775
- label: 'Batch Group',
776
- group: 'Batch Group',
777
- disabled: false,
778
- },
779
- {
780
- value: [9, 8, 10],
781
- label: 'Batch Ungrouped',
782
- disabled: false,
783
- },
784
- { label: 'value 2', value: 2, group: 'Group 2' },
785
- { label: 'value 3', value: 3, group: 'Group 2' },
786
- {
787
- label: 'Batch Group 2',
788
- value: [11, 12, 13],
789
- group: 'Group 2',
790
- disabled: false,
791
- },
792
- ],
793
-
794
- multiple: true,
795
- value: [2, 3, 5],
796
- },
797
- })
798
-
799
- act(() => {
800
- result.current.state.setSearchValue('value')
801
- jest.runAllTimers()
802
- })
803
-
804
- expect(result.current.state.options).toEqual([
805
- {
806
- label: 'value 1',
807
- value: 1,
808
- [draggableOptionIdSymbol]: expect.any(String),
809
- },
810
- {
811
- id: 'Group 1',
812
- label: 'Group 1',
813
- [isOptgroupSymbol]: true,
814
- },
815
- {
816
- group: 'Group 1',
817
- label: 'value 0',
818
- value: 0,
819
- [draggableOptionIdSymbol]: expect.any(String),
820
- },
821
- {
822
- id: 'Group 2',
823
- label: 'Group 2',
824
- [isOptgroupSymbol]: true,
825
- },
826
- {
827
- label: 'value 2',
828
- value: 2,
829
- group: 'Group 2',
830
- [draggableOptionIdSymbol]: expect.any(String),
831
- },
832
- {
833
- label: 'value 3',
834
- value: 3,
835
- group: 'Group 2',
836
- [draggableOptionIdSymbol]: expect.any(String),
837
- },
838
- ])
839
- })
840
-
841
- test('should return unfiltered array', () => {
842
- const { result } = renderHook(useSuperSelect, {
843
- initialProps: {
844
- draggable: true,
845
- options: [
846
- { label: 'value 0', value: 0, group: 'Group 1' },
847
- {
848
- label: 'value 1',
849
- value: 1,
850
- },
851
- {
852
- label: 'Batch Group 1.1',
853
- value: [4, 6],
854
- group: 'Group 1',
855
- disabled: false,
856
- },
857
- {
858
- label: 'Batch Group 1.2',
859
- value: [1, 7],
860
- group: 'Group 1',
861
- disabled: false,
862
- },
863
- {
864
- value: [2, 3, 5],
865
- label: 'Batch Group',
866
- group: 'Batch Group',
867
- disabled: false,
868
- },
869
- {
870
- value: [9, 8, 10],
871
- label: 'Batch Ungrouped',
872
- disabled: false,
873
- },
874
- { label: 'value 2', value: 2, group: 'Group 2' },
875
- { label: 'value 3', value: 3, group: 'Group 2' },
876
- {
877
- label: 'Batch Group 2',
878
- value: [11, 12, 13],
879
- group: 'Group 2',
880
- disabled: false,
881
- },
882
- ],
883
-
884
- multiple: true,
885
- value: [2, 3, 5],
886
- },
887
- })
888
-
889
- expect(result.current.state.options).toEqual([
890
- {
891
- value: [9, 8, 10],
892
- label: 'Batch Ungrouped',
893
- disabled: false,
894
- [draggableOptionIdSymbol]: expect.any(String),
895
- },
896
- {
897
- label: 'value 1',
898
- value: 1,
899
- [draggableOptionIdSymbol]: expect.any(String),
900
- },
901
- {
902
- id: 'Batch Group',
903
- label: 'Batch Group',
904
- [isOptgroupSymbol]: true,
905
- },
906
- {
907
- value: [2, 3, 5],
908
- label: 'Batch Group',
909
- group: 'Batch Group',
910
- disabled: true,
911
- [draggableOptionIdSymbol]: expect.any(String),
912
- },
913
- {
914
- id: 'Group 1',
915
- label: 'Group 1',
916
- [isOptgroupSymbol]: true,
917
- },
918
- {
919
- label: 'Batch Group 1.1',
920
- value: [4, 6],
921
- group: 'Group 1',
922
- disabled: false,
923
- [draggableOptionIdSymbol]: expect.any(String),
924
- },
925
- {
926
- label: 'Batch Group 1.2',
927
- value: [1, 7],
928
- group: 'Group 1',
929
- disabled: false,
930
- [draggableOptionIdSymbol]: expect.any(String),
931
- },
932
- {
933
- label: 'value 0',
934
- value: 0,
935
- group: 'Group 1',
936
- [draggableOptionIdSymbol]: expect.any(String),
937
- },
938
- {
939
- id: 'Group 2',
940
- label: 'Group 2',
941
- [isOptgroupSymbol]: true,
942
- },
943
- {
944
- label: 'Batch Group 2',
945
- value: [11, 12, 13],
946
- group: 'Group 2',
947
- disabled: false,
948
- [draggableOptionIdSymbol]: expect.any(String),
949
- },
950
- {
951
- label: 'value 2',
952
- value: 2,
953
- group: 'Group 2',
954
- [draggableOptionIdSymbol]: expect.any(String),
955
- },
956
- {
957
- label: 'value 3',
958
- value: 3,
959
- group: 'Group 2',
960
- [draggableOptionIdSymbol]: expect.any(String),
961
- },
962
- ])
963
- })
964
-
965
- test('should return filtered array', () => {
966
- jest.useFakeTimers()
967
-
968
- const { result } = renderHook(useSuperSelect, {
969
- initialProps: {
970
- draggable: true,
971
- options: [
972
- { label: 'value 0', value: 0, group: 'Group 1' },
973
- {
974
- label: 'value 1',
975
- value: 1,
976
- },
977
- {
978
- label: 'Batch Group 1.1',
979
- value: [4, 6],
980
- group: 'Group 1',
981
- disabled: false,
982
- },
983
- {
984
- label: 'Batch Group 1.2',
985
- value: [1, 7],
986
- group: 'Group 1',
987
- disabled: false,
988
- },
989
- {
990
- value: [2, 3, 5],
991
- label: 'Batch Group',
992
- group: 'Batch Group',
993
- disabled: false,
994
- },
995
- {
996
- value: [2, 3, 5],
997
- label: 'Batch Group',
998
- group: 'Batch Group',
999
- disabled: false,
1000
- },
1001
- {
1002
- value: [9, 8, 10],
1003
- label: 'Batch Ungrouped',
1004
- disabled: false,
1005
- },
1006
- { label: 'value 2', value: 2, group: 'Group 2' },
1007
- { label: 'value 3', value: 3, group: 'Group 2' },
1008
- {
1009
- label: 'Batch Group 2',
1010
- value: [11, 12, 13],
1011
- group: 'Group 2',
1012
- disabled: false,
1013
- },
1014
- ],
1015
-
1016
- multiple: true,
1017
- value: [2, 3, 5],
1018
- },
1019
- })
1020
-
1021
- act(() => {
1022
- result.current.state.setSearchValue('value')
1023
- jest.runAllTimers()
1024
- })
1025
-
1026
- expect(result.current.state.options).toEqual([
1027
- {
1028
- label: 'value 1',
1029
- value: 1,
1030
- [draggableOptionIdSymbol]: expect.any(String),
1031
- },
1032
- {
1033
- id: 'Group 1',
1034
- label: 'Group 1',
1035
- [isOptgroupSymbol]: true,
1036
- },
1037
- {
1038
- group: 'Group 1',
1039
- label: 'value 0',
1040
- value: 0,
1041
- [draggableOptionIdSymbol]: expect.any(String),
1042
- },
1043
- {
1044
- id: 'Group 2',
1045
- label: 'Group 2',
1046
- [isOptgroupSymbol]: true,
1047
- },
1048
- {
1049
- label: 'value 2',
1050
- value: 2,
1051
- group: 'Group 2',
1052
- [draggableOptionIdSymbol]: expect.any(String),
1053
- },
1054
- {
1055
- label: 'value 3',
1056
- value: 3,
1057
- group: 'Group 2',
1058
- [draggableOptionIdSymbol]: expect.any(String),
1059
- },
1060
- ])
1061
- })
1062
- })
1063
-
1064
- describe('unsorted', () => {
1065
- test('should return filtered array', () => {
1066
- jest.useFakeTimers()
1067
-
1068
- const { result } = renderHook(useSuperSelect, {
1069
- initialProps: {
1070
- draggable: true,
1071
- options: [
1072
- { label: 'value 0', value: 0, group: 'Group 1' },
1073
- {
1074
- label: 'value 1',
1075
- value: 1,
1076
- },
1077
- {
1078
- label: 'Batch Group 1.1',
1079
- value: [4, 6],
1080
- group: 'Group 1',
1081
- disabled: false,
1082
- },
1083
- {
1084
- label: 'Batch Group 1.2',
1085
- value: [1, 7],
1086
- group: 'Group 1',
1087
- disabled: false,
1088
- },
1089
- {
1090
- value: [2, 3, 5],
1091
- label: 'Batch Group',
1092
- group: 'Batch Group',
1093
- disabled: false,
1094
- },
1095
- {
1096
- value: [9, 8, 10],
1097
- label: 'Batch Ungrouped',
1098
- disabled: false,
1099
- },
1100
- { label: 'value 2', value: 2, group: 'Group 2' },
1101
- { label: 'value 3', value: 3, group: 'Group 2' },
1102
- {
1103
- label: 'Batch Group 2',
1104
- value: [11, 12, 13],
1105
- group: 'Group 2',
1106
- disabled: false,
1107
- },
1108
- ],
1109
-
1110
- multiple: true,
1111
- value: [2, 3, 5],
1112
- sort: false,
1113
- },
1114
- })
1115
-
1116
- act(() => {
1117
- result.current.state.setSearchValue('value')
1118
- jest.runAllTimers()
1119
- })
1120
-
1121
- expect(result.current.state.options).toEqual([
1122
- {
1123
- label: 'value 1',
1124
- value: 1,
1125
- [draggableOptionIdSymbol]: expect.any(String),
1126
- },
1127
- {
1128
- id: 'Group 1',
1129
- label: 'Group 1',
1130
- [isOptgroupSymbol]: true,
1131
- },
1132
- {
1133
- label: 'value 0',
1134
- value: 0,
1135
- group: 'Group 1',
1136
- [draggableOptionIdSymbol]: expect.any(String),
1137
- },
1138
- {
1139
- id: 'Group 2',
1140
- label: 'Group 2',
1141
- [isOptgroupSymbol]: true,
1142
- },
1143
- {
1144
- label: 'value 2',
1145
- value: 2,
1146
- group: 'Group 2',
1147
- [draggableOptionIdSymbol]: expect.any(String),
1148
- },
1149
- {
1150
- label: 'value 3',
1151
- value: 3,
1152
- group: 'Group 2',
1153
- [draggableOptionIdSymbol]: expect.any(String),
1154
- },
1155
- ])
1156
- })
1157
-
1158
- test('should return unfiltered array', () => {
1159
- const { result } = renderHook(useSuperSelect, {
1160
- initialProps: {
1161
- draggable: true,
1162
- options: [
1163
- { label: 'value 0', value: 0, group: 'Group 1' },
1164
- {
1165
- label: 'value 1',
1166
- value: 1,
1167
- },
1168
- {
1169
- label: 'Batch Group 1.1',
1170
- value: [4, 6],
1171
- group: 'Group 1',
1172
- disabled: false,
1173
- },
1174
- {
1175
- label: 'Batch Group 1.2',
1176
- value: [1, 7],
1177
- group: 'Group 1',
1178
- disabled: false,
1179
- },
1180
- {
1181
- value: [2, 3, 5],
1182
- label: 'Batch Group',
1183
- group: 'Batch Group',
1184
- disabled: false,
1185
- },
1186
- {
1187
- value: [9, 8, 10],
1188
- label: 'Batch Ungrouped',
1189
- disabled: false,
1190
- },
1191
- { label: 'value 2', value: 2, group: 'Group 2' },
1192
- { label: 'value 3', value: 3, group: 'Group 2' },
1193
- {
1194
- label: 'Batch Group 2',
1195
- value: [11, 12, 13],
1196
- group: 'Group 2',
1197
- disabled: false,
1198
- },
1199
- ],
1200
-
1201
- multiple: true,
1202
- value: [2, 3, 5],
1203
- sort: false,
1204
- },
1205
- })
1206
-
1207
- expect(result.current.state.options).toEqual([
1208
- {
1209
- label: 'value 1',
1210
- value: 1,
1211
- [draggableOptionIdSymbol]: expect.any(String),
1212
- },
1213
- {
1214
- value: [9, 8, 10],
1215
- label: 'Batch Ungrouped',
1216
- disabled: false,
1217
- [draggableOptionIdSymbol]: expect.any(String),
1218
- },
1219
- {
1220
- id: 'Group 1',
1221
- label: 'Group 1',
1222
- [isOptgroupSymbol]: true,
1223
- },
1224
- {
1225
- label: 'value 0',
1226
- value: 0,
1227
- group: 'Group 1',
1228
- [draggableOptionIdSymbol]: expect.any(String),
1229
- },
1230
- {
1231
- label: 'Batch Group 1.1',
1232
- value: [4, 6],
1233
- group: 'Group 1',
1234
- disabled: false,
1235
- [draggableOptionIdSymbol]: expect.any(String),
1236
- },
1237
- {
1238
- label: 'Batch Group 1.2',
1239
- value: [1, 7],
1240
- group: 'Group 1',
1241
- disabled: false,
1242
- [draggableOptionIdSymbol]: expect.any(String),
1243
- },
1244
- {
1245
- id: 'Batch Group',
1246
- label: 'Batch Group',
1247
- [isOptgroupSymbol]: true,
1248
- },
1249
- {
1250
- value: [2, 3, 5],
1251
- label: 'Batch Group',
1252
- group: 'Batch Group',
1253
- disabled: true,
1254
- [draggableOptionIdSymbol]: expect.any(String),
1255
- },
1256
- {
1257
- id: 'Group 2',
1258
- label: 'Group 2',
1259
- [isOptgroupSymbol]: true,
1260
- },
1261
- {
1262
- label: 'value 2',
1263
- value: 2,
1264
- group: 'Group 2',
1265
- [draggableOptionIdSymbol]: expect.any(String),
1266
- },
1267
- {
1268
- label: 'value 3',
1269
- value: 3,
1270
- group: 'Group 2',
1271
- [draggableOptionIdSymbol]: expect.any(String),
1272
- },
1273
- {
1274
- label: 'Batch Group 2',
1275
- value: [11, 12, 13],
1276
- group: 'Group 2',
1277
- disabled: false,
1278
- [draggableOptionIdSymbol]: expect.any(String),
1279
- },
1280
- ])
1281
- })
1282
- })
1283
- })
1284
- })