@kaizen/components 1.61.1 → 1.61.2
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/codemods/utils/__snapshots__/transformSource.spec.ts.snap +2 -2
- package/dist/cjs/RichTextEditor/RichTextContent/RichTextContent.cjs +10 -1
- package/dist/esm/RichTextEditor/RichTextContent/RichTextContent.mjs +11 -2
- package/dist/styles.css +220 -220
- package/package.json +5 -4
- package/src/Avatar/Avatar.spec.tsx +1 -1
- package/src/Calendar/utils/setFocusInCalendar.spec.tsx +2 -2
- package/src/Checkbox/Checkbox/Checkbox.spec.tsx +2 -2
- package/src/Collapsible/Collapsible/Collapsible.spec.tsx +2 -14
- package/src/Collapsible/Collapsible/_docs/Collapsible.stickersheet.stories.tsx +49 -0
- package/src/Collapsible/Collapsible/_docs/Collapsible.stories.tsx +0 -11
- package/src/DateInput/DateInputDescription/DateInputDescription.spec.tsx +5 -6
- package/src/DateInput/DateInputWithIconButton/DateInputWithIconButton.spec.tsx +4 -6
- package/src/DatePicker/DatePicker.spec.tsx +32 -36
- package/src/DatePicker/subcomponents/DateInputField/DateInputField.spec.tsx +13 -13
- package/src/DatePicker/utils/validateDate.spec.ts +5 -6
- package/src/EmptyState/EmptyState.spec.tsx +1 -1
- package/src/ErrorPage/ErrorPage.spec.tsx +19 -19
- package/src/Filter/FilterBar/FilterBar.spec.tsx +26 -26
- package/src/Filter/FilterBar/context/utils/updateDependentFilters.spec.ts +2 -4
- package/src/Filter/FilterBar/subcomponents/AddFiltersMenu/AddFiltersMenu.spec.tsx +3 -4
- package/src/Filter/FilterBar/subcomponents/FilterBarButton/FilterBarButton.spec.tsx +3 -6
- package/src/Filter/FilterBar/subcomponents/FilterBarDatePicker/FilterBarDatePicker.spec.tsx +10 -12
- package/src/Filter/FilterBar/subcomponents/FilterBarDateRangePicker/FilterBarDateRangePicker.spec.tsx +9 -10
- package/src/Filter/FilterBar/subcomponents/FilterBarMultiSelect/FilterBarMultiSelect.spec.tsx +12 -14
- package/src/Filter/FilterBar/subcomponents/FilterBarSelect/FilterBarSelect.spec.tsx +11 -13
- package/src/Filter/FilterButton/FilterButtonRemovable/FilterButtonRemovable.spec.tsx +5 -5
- package/src/Filter/FilterDatePicker/FilterDatePicker.spec.tsx +12 -15
- package/src/Filter/FilterDatePicker/hooks/useDateInputHandlers.spec.ts +12 -15
- package/src/Filter/FilterDatePicker/hooks/useDateValidation.spec.ts +3 -5
- package/src/Filter/FilterDatePicker/subcomponents/FilterDatePickerField/FilterDatePickerField.spec.tsx +23 -28
- package/src/Filter/FilterDatePicker/utils/getDateValidationHandler.spec.tsx +2 -6
- package/src/Filter/FilterDatePicker/utils/validateDate.spec.ts +5 -6
- package/src/Filter/FilterDateRangePicker/FilterDateRangePicker.spec.tsx +2 -3
- package/src/Filter/FilterDateRangePicker/_docs/FilterDateRangePicker.stickersheet.stories.tsx +27 -0
- package/src/Filter/FilterDateRangePicker/subcomponents/DateRangeInputField/DateRangeInputField.spec.tsx +9 -11
- package/src/Filter/FilterDateRangePicker/subcomponents/DateRangeValidationMessage/DateRangeValidationMessage.spec.tsx +1 -63
- package/src/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/FilterDateRangePickerField.spec.tsx +32 -32
- package/src/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/hooks/useEndDateValidation.spec.ts +3 -8
- package/src/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/hooks/useStartDateValidation.spec.ts +2 -5
- package/src/Filter/FilterDateRangePicker/subcomponents/FilterDateRangePickerField/utils/validateEndDateBeforeStartDate.spec.ts +2 -3
- package/src/Filter/FilterMultiSelect/FilterMultiSelect.spec.tsx +9 -10
- package/src/Filter/FilterMultiSelect/context/MenuTriggerProvider/MenuTriggerProvider.spec.tsx +2 -1
- package/src/Filter/FilterMultiSelect/context/SelectionProvider/SelectionProvider.spec.tsx +32 -32
- package/src/Filter/FilterMultiSelect/subcomponents/MultiSelectOption/MultiSelectOption.spec.tsx +9 -7
- package/src/Filter/FilterMultiSelect/subcomponents/SearchInput/SearchInput.spec.tsx +12 -12
- package/src/Filter/FilterMultiSelect/subcomponents/SelectionControlButton/ClearButton/ClearButton.spec.tsx +7 -7
- package/src/Filter/FilterMultiSelect/subcomponents/SelectionControlButton/SelectAllButton/SelectAllButton.spec.tsx +9 -9
- package/src/Filter/FilterSelect/FilterSelect.spec.tsx +2 -2
- package/src/Heading/Heading.spec.tsx +1 -31
- package/src/Illustration/subcomponents/VideoPlayer/VideoPlayer.spec.tsx +43 -97
- package/src/Illustration/subcomponents/VideoPlayer/VideoPlayer.stickersheet.stories.tsx +68 -0
- package/src/Illustration/subcomponents/VideoPlayer/VideoPlayer.stories.tsx +37 -0
- package/src/Input/InputRange/InputRange.spec.tsx +2 -2
- package/src/Input/InputSearch/InputSearch.spec.tsx +3 -5
- package/src/KaizenProvider/KaizenProvider.spec.tsx +2 -2
- package/src/KaizenProvider/subcomponents/OptionalIntlProvider/OptionalIntlProvider.spec.tsx +2 -3
- package/src/Modal/ConfirmationModal/ConfirmationModal.spec.tsx +7 -7
- package/src/Modal/ContextModal/ContextModal.spec.tsx +5 -5
- package/src/Modal/GenericModal/GenericModal.spec.tsx +4 -4
- package/src/Modal/InputEditModal/InputEditModal.spec.tsx +7 -7
- package/src/MultiSelect/subcomponents/MultiSelectOptionField/MultiSelectOptionField.spec.tsx +3 -3
- package/src/MultiSelect/subcomponents/MultiSelectOptions/MultiSelectOptions.spec.tsx +3 -3
- package/src/MultiSelect/subcomponents/MultiSelectToggle/MultiSelectToggle.spec.tsx +2 -2
- package/src/Notification/subcomponents/GenericNotification/GenericNotification.stories.tsx +60 -0
- package/src/Pagination/Pagination.spec.tsx +2 -2
- package/src/RichTextEditor/EditableRichTextContent/EditableRichTextContent.spec.tsx +4 -4
- package/src/RichTextEditor/RichTextContent/RichTextContent.tsx +11 -2
- package/src/RichTextEditor/utils/commands/addMark.spec.ts +2 -2
- package/src/RichTextEditor/utils/commands/fixtures/helpers.ts +4 -3
- package/src/RichTextEditor/utils/commands/getMarkAttrs.spec.ts +2 -2
- package/src/RichTextEditor/utils/commands/getMarkRange.spec.ts +2 -2
- package/src/RichTextEditor/utils/commands/listIsActive.spec.ts +2 -2
- package/src/RichTextEditor/utils/commands/markContainsSelection.spec.ts +2 -2
- package/src/RichTextEditor/utils/commands/markIsActive.spec.ts +2 -2
- package/src/RichTextEditor/utils/commands/removeMark.spec.ts +2 -2
- package/src/RichTextEditor/utils/commands/updateMark.spec.ts +2 -2
- package/src/RichTextEditor/utils/commands/validateAndRemoveMarks.spec.ts +3 -3
- package/src/RichTextEditor/utils/core/createRichTextEditor.spec.ts +11 -11
- package/src/RichTextEditor/utils/core/hooks/useRichTextEditor.spec.tsx +2 -2
- package/src/SplitButton/SplitButton.spec.tsx +5 -5
- package/src/SplitButton/subcomponents/DropdownButton/DropdownButton.spec.tsx +3 -4
- package/src/Text/Text.spec.tsx +1 -57
- package/src/TextArea/TextArea.spec.tsx +2 -2
- package/src/TimeField/TimeField.spec.tsx +2 -2
- package/src/TitleBlockZen/TitleBlockZen.spec.tsx +36 -68
- package/src/TitleBlockZen/_docs/TitleBlockZen.stories.tsx +78 -8
- package/src/TitleBlockZen/subcomponents/MobileActions.spec.tsx +2 -2
- package/src/TitleBlockZen/subcomponents/NavigationTabs.spec.tsx +8 -2
- package/src/ToggleSwitch/ToggleSwitch/ToggleSwitch.spec.tsx +2 -2
- package/src/__actions__/Menu/v1/Menu.spec.tsx +2 -2
- package/src/__containers__/GuidanceBlock/v1/GuidanceBlock.spec.tsx +5 -5
- package/src/__containers__/GuidanceBlock/v2/GuidanceBlock.spec.tsx +5 -5
- package/src/__future__/Select/Select.spec.tsx +4 -4
- package/src/__overlays__/Tooltip/v1/Tooltip.spec.tsx +1 -1
- package/src/__overlays__/Tooltip/v1/utils/isSemanticElement.spec.tsx +4 -9
- package/src/utils/useMediaQueries.spec.tsx +7 -7
- package/src/Heading/__snapshots__/Heading.spec.tsx.snap +0 -85
- package/src/Illustration/utils/usePausePlay.spec.tsx +0 -85
- package/src/Notification/subcomponents/GenericNotification/GenericNotification.spec.tsx +0 -76
- package/src/Text/__snapshots__/Text.spec.tsx.snap +0 -49
- package/src/__overlays__/Tooltip/v1/subcomponents/AppearanceAnim.spec.tsx +0 -39
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { useState } from "react"
|
|
2
2
|
import { StaticIntlProvider } from "@cultureamp/i18n-react-intl"
|
|
3
3
|
import { Selection } from "@react-types/shared"
|
|
4
|
-
import { screen, waitFor } from "@testing-library/react"
|
|
4
|
+
import { screen, waitFor, render } from "@testing-library/react"
|
|
5
5
|
import userEvent from "@testing-library/user-event"
|
|
6
|
-
import {
|
|
6
|
+
import { vi } from "vitest"
|
|
7
7
|
import { FilterMultiSelect } from "../../FilterMultiSelect"
|
|
8
8
|
import { ListBox } from "../../subcomponents/ListBox"
|
|
9
9
|
import { SearchInput } from "../../subcomponents/SearchInput"
|
|
@@ -104,7 +104,7 @@ describe("<SelectionProvider>", () => {
|
|
|
104
104
|
describe("<SelectionProviderWrapper /> - Visual content", () => {
|
|
105
105
|
describe("Given no selectedKeys", () => {
|
|
106
106
|
it("shows all the options unselected", async () => {
|
|
107
|
-
|
|
107
|
+
render(<SelectionProviderWrapper />)
|
|
108
108
|
await waitFor(() => {
|
|
109
109
|
expect(
|
|
110
110
|
screen.getByRole("option", {
|
|
@@ -128,7 +128,7 @@ describe("<SelectionProvider>", () => {
|
|
|
128
128
|
})
|
|
129
129
|
|
|
130
130
|
it("labels the listbox with the provided label", async () => {
|
|
131
|
-
|
|
131
|
+
render(<SelectionProviderWrapper />)
|
|
132
132
|
await waitFor(() => {
|
|
133
133
|
const listBox = screen.getByLabelText("selection-label-mock", {
|
|
134
134
|
selector: "ul",
|
|
@@ -140,7 +140,7 @@ describe("<SelectionProvider>", () => {
|
|
|
140
140
|
|
|
141
141
|
describe("Given selectedKeys is [option-2-value-mock]", () => {
|
|
142
142
|
it("shows only option 2 is selected", async () => {
|
|
143
|
-
|
|
143
|
+
render(
|
|
144
144
|
<SelectionProviderWrapper
|
|
145
145
|
selectedKeys={new Set(["option-2-value-mock"])}
|
|
146
146
|
/>
|
|
@@ -170,7 +170,7 @@ describe("<SelectionProvider>", () => {
|
|
|
170
170
|
|
|
171
171
|
describe("Given selectedKeys is 'all'", () => {
|
|
172
172
|
it("shows all options are selected", async () => {
|
|
173
|
-
|
|
173
|
+
render(<SelectionProviderWrapper selectedKeys="all" />)
|
|
174
174
|
await waitFor(() => {
|
|
175
175
|
expect(
|
|
176
176
|
screen.getByRole("option", {
|
|
@@ -197,7 +197,7 @@ describe("<SelectionProvider>", () => {
|
|
|
197
197
|
|
|
198
198
|
describe("<SelectionProviderWrapper /> - Mouse interaction", () => {
|
|
199
199
|
it("selects the option when clicks on a non-selected option", async () => {
|
|
200
|
-
|
|
200
|
+
render(<SelectionProviderWrapper />)
|
|
201
201
|
const option1 = screen.getByRole("option", {
|
|
202
202
|
name: "option-1-label-mock",
|
|
203
203
|
})
|
|
@@ -215,8 +215,8 @@ describe("<SelectionProvider>", () => {
|
|
|
215
215
|
})
|
|
216
216
|
|
|
217
217
|
it("fires onSelectionChange when clicks on a option", async () => {
|
|
218
|
-
const spy =
|
|
219
|
-
|
|
218
|
+
const spy = vi.fn()
|
|
219
|
+
render(<SelectionProviderWrapper onSelectionChange={spy} />)
|
|
220
220
|
const option1 = screen.getByRole("option", {
|
|
221
221
|
name: "option-1-label-mock",
|
|
222
222
|
})
|
|
@@ -229,7 +229,7 @@ describe("<SelectionProvider>", () => {
|
|
|
229
229
|
})
|
|
230
230
|
|
|
231
231
|
it("selects all options when clicks on Select all button", async () => {
|
|
232
|
-
|
|
232
|
+
render(<SelectionProviderWrapper />)
|
|
233
233
|
const selectAll = screen.getByRole("button", {
|
|
234
234
|
name: "Select all",
|
|
235
235
|
})
|
|
@@ -261,8 +261,8 @@ describe("<SelectionProvider>", () => {
|
|
|
261
261
|
})
|
|
262
262
|
|
|
263
263
|
it("fires onSelectionChange when clicks on Select all button", async () => {
|
|
264
|
-
const spy =
|
|
265
|
-
|
|
264
|
+
const spy = vi.fn()
|
|
265
|
+
render(<SelectionProviderWrapper onSelectionChange={spy} />)
|
|
266
266
|
const selectAll = screen.getByRole("button", {
|
|
267
267
|
name: "Select all",
|
|
268
268
|
})
|
|
@@ -275,7 +275,7 @@ describe("<SelectionProvider>", () => {
|
|
|
275
275
|
})
|
|
276
276
|
|
|
277
277
|
it("clears all the selection when clicks on Clear button", async () => {
|
|
278
|
-
|
|
278
|
+
render(
|
|
279
279
|
<SelectionProviderWrapper
|
|
280
280
|
selectedKeys={new Set(["option-2-value-mock"])}
|
|
281
281
|
/>
|
|
@@ -309,8 +309,8 @@ describe("<SelectionProvider>", () => {
|
|
|
309
309
|
})
|
|
310
310
|
|
|
311
311
|
it("fires onSelectionChange when clicks on Clear all button", async () => {
|
|
312
|
-
const spy =
|
|
313
|
-
|
|
312
|
+
const spy = vi.fn()
|
|
313
|
+
render(
|
|
314
314
|
<SelectionProviderWrapper
|
|
315
315
|
onSelectionChange={spy}
|
|
316
316
|
selectedKeys={new Set(["option-2-value-mock"])}
|
|
@@ -328,7 +328,7 @@ describe("<SelectionProvider>", () => {
|
|
|
328
328
|
})
|
|
329
329
|
|
|
330
330
|
it("de-selects the option when clicks on a selected option", async () => {
|
|
331
|
-
|
|
331
|
+
render(
|
|
332
332
|
<SelectionProviderWrapper
|
|
333
333
|
selectedKeys={new Set(["option-2-value-mock"])}
|
|
334
334
|
/>
|
|
@@ -354,7 +354,7 @@ describe("<SelectionProvider>", () => {
|
|
|
354
354
|
describe("<SelectionProviderWrapper /> - Keyboard interaction", () => {
|
|
355
355
|
describe("Given no selectedKeys", () => {
|
|
356
356
|
it("focuses on the frist option when tabs onto the list", async () => {
|
|
357
|
-
|
|
357
|
+
render(<SelectionProviderWrapper />)
|
|
358
358
|
await user.tab()
|
|
359
359
|
|
|
360
360
|
await waitFor(() => {
|
|
@@ -367,7 +367,7 @@ describe("<SelectionProvider>", () => {
|
|
|
367
367
|
|
|
368
368
|
describe("Given selectedKeys is [option-2-value-mock, option-3-value-mock]", () => {
|
|
369
369
|
it("focuses the frist selected option when tabs onto the list", async () => {
|
|
370
|
-
|
|
370
|
+
render(
|
|
371
371
|
<SelectionProviderWrapper
|
|
372
372
|
selectedKeys={new Set(["option-2-value-mock"])}
|
|
373
373
|
/>
|
|
@@ -383,7 +383,7 @@ describe("<SelectionProvider>", () => {
|
|
|
383
383
|
})
|
|
384
384
|
|
|
385
385
|
it("moves the focus down when hits arrow down key", async () => {
|
|
386
|
-
|
|
386
|
+
render(<SelectionProviderWrapper />)
|
|
387
387
|
await user.tab()
|
|
388
388
|
await user.keyboard("{ArrowDown}")
|
|
389
389
|
|
|
@@ -395,7 +395,7 @@ describe("<SelectionProvider>", () => {
|
|
|
395
395
|
})
|
|
396
396
|
|
|
397
397
|
it("keeps the focus at the last element when hits arrow down key on it", async () => {
|
|
398
|
-
|
|
398
|
+
render(
|
|
399
399
|
<SelectionProviderWrapper
|
|
400
400
|
selectedKeys={new Set(["option-3-value-mock"])}
|
|
401
401
|
/>
|
|
@@ -411,7 +411,7 @@ describe("<SelectionProvider>", () => {
|
|
|
411
411
|
})
|
|
412
412
|
|
|
413
413
|
it("moves the focus up when hits arrow up key", async () => {
|
|
414
|
-
|
|
414
|
+
render(
|
|
415
415
|
<SelectionProviderWrapper
|
|
416
416
|
selectedKeys={new Set(["option-3-value-mock"])}
|
|
417
417
|
/>
|
|
@@ -427,7 +427,7 @@ describe("<SelectionProvider>", () => {
|
|
|
427
427
|
})
|
|
428
428
|
|
|
429
429
|
it("keeps the focus ring at the first element when hits arrow up key on it", async () => {
|
|
430
|
-
|
|
430
|
+
render(<SelectionProviderWrapper />)
|
|
431
431
|
await user.tab()
|
|
432
432
|
await user.keyboard("{ArrowUp}")
|
|
433
433
|
|
|
@@ -439,7 +439,7 @@ describe("<SelectionProvider>", () => {
|
|
|
439
439
|
})
|
|
440
440
|
|
|
441
441
|
it("selects the option when hits enter on a non-selected option", async () => {
|
|
442
|
-
|
|
442
|
+
render(<SelectionProviderWrapper />)
|
|
443
443
|
|
|
444
444
|
await user.tab()
|
|
445
445
|
await user.keyboard("{Enter}")
|
|
@@ -455,7 +455,7 @@ describe("<SelectionProvider>", () => {
|
|
|
455
455
|
})
|
|
456
456
|
|
|
457
457
|
it("de-selects the option when hits enter on a selected option", async () => {
|
|
458
|
-
|
|
458
|
+
render(
|
|
459
459
|
<SelectionProviderWrapper
|
|
460
460
|
selectedKeys={new Set(["option-2-value-mock"])}
|
|
461
461
|
/>
|
|
@@ -475,8 +475,8 @@ describe("<SelectionProvider>", () => {
|
|
|
475
475
|
})
|
|
476
476
|
|
|
477
477
|
it("fires onSelectionChange when hits enter on a option", async () => {
|
|
478
|
-
const spy =
|
|
479
|
-
|
|
478
|
+
const spy = vi.fn()
|
|
479
|
+
render(<SelectionProviderWrapper onSelectionChange={spy} />)
|
|
480
480
|
|
|
481
481
|
await user.tab()
|
|
482
482
|
await user.keyboard("{Enter}")
|
|
@@ -490,7 +490,7 @@ describe("<SelectionProvider>", () => {
|
|
|
490
490
|
describe("<SelectionProviderWrapper /> - Search Filtering", () => {
|
|
491
491
|
describe("With no onSearchInputChange callback", () => {
|
|
492
492
|
it("shows only the matched options", async () => {
|
|
493
|
-
|
|
493
|
+
render(<SelectionProviderWrapper />)
|
|
494
494
|
const searchInput = screen.getByRole("searchbox")
|
|
495
495
|
await user.type(searchInput, "1")
|
|
496
496
|
|
|
@@ -515,9 +515,9 @@ describe("<SelectionProvider>", () => {
|
|
|
515
515
|
})
|
|
516
516
|
describe("With a onSearchInputChange callback", () => {
|
|
517
517
|
it("Does not filter the matched options", async () => {
|
|
518
|
-
const onSearchInputChange =
|
|
518
|
+
const onSearchInputChange = vi.fn()
|
|
519
519
|
|
|
520
|
-
|
|
520
|
+
render(
|
|
521
521
|
<SelectionProviderWrapper onSearchInputChange={onSearchInputChange} />
|
|
522
522
|
)
|
|
523
523
|
const searchInput = screen.getByRole("searchbox")
|
|
@@ -544,9 +544,9 @@ describe("<SelectionProvider>", () => {
|
|
|
544
544
|
})
|
|
545
545
|
|
|
546
546
|
it("Calls back to the consumer with the search text", async () => {
|
|
547
|
-
const onSearchInputChange =
|
|
547
|
+
const onSearchInputChange = vi.fn()
|
|
548
548
|
|
|
549
|
-
|
|
549
|
+
render(
|
|
550
550
|
<SelectionProviderWrapper onSearchInputChange={onSearchInputChange} />
|
|
551
551
|
)
|
|
552
552
|
const searchInput = screen.getByRole("searchbox")
|
|
@@ -563,7 +563,7 @@ describe("<SelectionProvider>", () => {
|
|
|
563
563
|
|
|
564
564
|
describe("<SelectionProviderWrapper /> - controlling items from the consumer", () => {
|
|
565
565
|
it("renders only items passed", async () => {
|
|
566
|
-
const { rerender } =
|
|
566
|
+
const { rerender } = render(<SelectionProviderWrapper />)
|
|
567
567
|
await waitFor(() => {
|
|
568
568
|
expect(
|
|
569
569
|
screen.getByRole("option", {
|
package/src/Filter/FilterMultiSelect/subcomponents/MultiSelectOption/MultiSelectOption.spec.tsx
CHANGED
|
@@ -3,14 +3,16 @@
|
|
|
3
3
|
import React from "react"
|
|
4
4
|
import { useOption } from "@react-aria/listbox"
|
|
5
5
|
import { render, screen } from "@testing-library/react"
|
|
6
|
+
import { vi, beforeEach, Mock } from "vitest"
|
|
6
7
|
import { ItemType } from "../../types"
|
|
7
8
|
import { MultiSelectOption, MultiSelectOptionProps } from "./MultiSelectOption"
|
|
9
|
+
import styles from "./MultiSelectOption.module.scss"
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
useOption:
|
|
11
|
+
vi.mock("@react-aria/listbox", () => ({
|
|
12
|
+
useOption: vi.fn(),
|
|
11
13
|
}))
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
vi.mock("../../context", () => ({
|
|
14
16
|
useSelectionContext: (): { selectionState: Record<string, unknown> } => ({
|
|
15
17
|
selectionState: {},
|
|
16
18
|
}),
|
|
@@ -36,7 +38,7 @@ const MultiSelectOptionWrapper = ({
|
|
|
36
38
|
describe("<MultiSelectOptionWrapper /> - Visual content", () => {
|
|
37
39
|
describe("Given item is unselected", () => {
|
|
38
40
|
beforeEach(() => {
|
|
39
|
-
;(useOption as
|
|
41
|
+
;(useOption as Mock).mockReturnValue({
|
|
40
42
|
optionProps: {},
|
|
41
43
|
isSelected: false,
|
|
42
44
|
isDisabled: false,
|
|
@@ -56,7 +58,7 @@ describe("<MultiSelectOptionWrapper /> - Visual content", () => {
|
|
|
56
58
|
|
|
57
59
|
describe("Given item is disabled", () => {
|
|
58
60
|
beforeEach(() => {
|
|
59
|
-
;(useOption as
|
|
61
|
+
;(useOption as Mock).mockReturnValue({
|
|
60
62
|
optionProps: {},
|
|
61
63
|
isSelected: false,
|
|
62
64
|
isDisabled: true,
|
|
@@ -66,13 +68,13 @@ describe("<MultiSelectOptionWrapper /> - Visual content", () => {
|
|
|
66
68
|
|
|
67
69
|
it("has a disabled class", () => {
|
|
68
70
|
const label = screen.getByLabelText("label-mock")
|
|
69
|
-
expect(label).toHaveClass(
|
|
71
|
+
expect(label).toHaveClass(styles.isDisabled)
|
|
70
72
|
})
|
|
71
73
|
})
|
|
72
74
|
|
|
73
75
|
describe("Given count is provided", () => {
|
|
74
76
|
beforeEach(() => {
|
|
75
|
-
;(useOption as
|
|
77
|
+
;(useOption as Mock).mockReturnValue({
|
|
76
78
|
optionProps: {},
|
|
77
79
|
isSelected: false,
|
|
78
80
|
isDisabled: false,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React from "react"
|
|
2
|
-
import { screen, waitFor } from "@testing-library/react"
|
|
2
|
+
import { screen, waitFor, render } from "@testing-library/react"
|
|
3
3
|
import userEvent from "@testing-library/user-event"
|
|
4
|
-
import {
|
|
4
|
+
import { vi, Mock } from "vitest"
|
|
5
5
|
import { useSelectionContext } from "../../context"
|
|
6
6
|
import { SearchInput } from "."
|
|
7
7
|
|
|
8
8
|
const user = userEvent.setup()
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
useSelectionContext:
|
|
10
|
+
vi.mock("../../context", () => ({
|
|
11
|
+
useSelectionContext: vi.fn(),
|
|
12
12
|
}))
|
|
13
13
|
|
|
14
14
|
const SearchInputWrapper = (): JSX.Element => <SearchInput label="label-mock" />
|
|
@@ -16,10 +16,10 @@ const SearchInputWrapper = (): JSX.Element => <SearchInput label="label-mock" />
|
|
|
16
16
|
describe("<SearchInput /> - interaction", () => {
|
|
17
17
|
describe("Given searchQuery is provided", () => {
|
|
18
18
|
it("shows searchQuery as value", async () => {
|
|
19
|
-
;(useSelectionContext as
|
|
19
|
+
;(useSelectionContext as Mock).mockReturnValue({
|
|
20
20
|
searchQuery: "search-query-mock",
|
|
21
21
|
})
|
|
22
|
-
|
|
22
|
+
render(<SearchInputWrapper />)
|
|
23
23
|
await waitFor(() => {
|
|
24
24
|
expect(screen.getByRole("searchbox")).toHaveValue("search-query-mock")
|
|
25
25
|
})
|
|
@@ -27,12 +27,12 @@ describe("<SearchInput /> - interaction", () => {
|
|
|
27
27
|
})
|
|
28
28
|
|
|
29
29
|
it("triggers setSearchQuery with input value when user types the input", async () => {
|
|
30
|
-
const spy =
|
|
31
|
-
;(useSelectionContext as
|
|
30
|
+
const spy = vi.fn()
|
|
31
|
+
;(useSelectionContext as Mock).mockReturnValue({
|
|
32
32
|
setSearchQuery: spy,
|
|
33
33
|
})
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
render(<SearchInputWrapper />)
|
|
36
36
|
const search = screen.getByRole("searchbox")
|
|
37
37
|
await user.type(search, "want to search this text")
|
|
38
38
|
|
|
@@ -40,13 +40,13 @@ describe("<SearchInput /> - interaction", () => {
|
|
|
40
40
|
})
|
|
41
41
|
|
|
42
42
|
it("triggers setSearchQuery with input value when clear the input", async () => {
|
|
43
|
-
const spy =
|
|
44
|
-
;(useSelectionContext as
|
|
43
|
+
const spy = vi.fn()
|
|
44
|
+
;(useSelectionContext as Mock).mockReturnValue({
|
|
45
45
|
searchQuery: "search-query-mock",
|
|
46
46
|
setSearchQuery: spy,
|
|
47
47
|
})
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
render(<SearchInputWrapper />)
|
|
50
50
|
const clearButton = screen.getByRole("button")
|
|
51
51
|
await user.click(clearButton)
|
|
52
52
|
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import { render, screen, waitFor } from "@testing-library/react"
|
|
3
3
|
import userEvent from "@testing-library/user-event"
|
|
4
|
+
import { Mock, vi } from "vitest"
|
|
4
5
|
import { useSelectionContext } from "../../../context"
|
|
5
6
|
import { ClearButton } from "."
|
|
6
|
-
|
|
7
7
|
const user = userEvent.setup()
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
useSelectionContext:
|
|
9
|
+
vi.mock("../../../context", () => ({
|
|
10
|
+
useSelectionContext: vi.fn(),
|
|
11
11
|
}))
|
|
12
12
|
|
|
13
13
|
describe("<ClearButton /> - interaction", () => {
|
|
14
14
|
describe("Given selection is not empty", () => {
|
|
15
15
|
it("triggers selectionManager.selSelectedKeys() with focused keys filtered out when button is clicked", async () => {
|
|
16
|
-
const spy =
|
|
16
|
+
const spy = vi.fn()
|
|
17
17
|
const selectedAndFocused = "selectedAndFocused"
|
|
18
18
|
const selectedButNotFocused = "selectedButNotFocused"
|
|
19
19
|
const selectedKeys: string[] = [selectedAndFocused, selectedButNotFocused]
|
|
20
20
|
const filteredKeys: string[] = [selectedAndFocused]
|
|
21
|
-
;(useSelectionContext as
|
|
21
|
+
;(useSelectionContext as Mock).mockReturnValue({
|
|
22
22
|
selectionState: {
|
|
23
23
|
collection: {
|
|
24
24
|
getKeys: () => filteredKeys,
|
|
@@ -43,10 +43,10 @@ describe("<ClearButton /> - interaction", () => {
|
|
|
43
43
|
|
|
44
44
|
describe("Given selection is empty", () => {
|
|
45
45
|
it("does not trigger selectionManager.setSelectedKeys() when clicks on the button", async () => {
|
|
46
|
-
const spy =
|
|
46
|
+
const spy = vi.fn()
|
|
47
47
|
const filteredKeys: string[] = []
|
|
48
48
|
const selectedKeys: string[] = []
|
|
49
|
-
;(useSelectionContext as
|
|
49
|
+
;(useSelectionContext as Mock).mockReturnValue({
|
|
50
50
|
selectionState: {
|
|
51
51
|
collection: {
|
|
52
52
|
getKeys: () => filteredKeys,
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import { render, screen, waitFor } from "@testing-library/react"
|
|
3
3
|
import userEvent from "@testing-library/user-event"
|
|
4
|
+
import { Mock, vi } from "vitest"
|
|
4
5
|
import { useSelectionContext } from "../../../context"
|
|
5
6
|
import { SelectAllButton } from "."
|
|
6
|
-
|
|
7
7
|
const user = userEvent.setup()
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
useSelectionContext:
|
|
9
|
+
vi.mock("../../../context", () => ({
|
|
10
|
+
useSelectionContext: vi.fn(),
|
|
11
11
|
}))
|
|
12
12
|
|
|
13
13
|
describe("<SelectAllButton /> - interaction", () => {
|
|
14
14
|
describe("Given not all options are selected", () => {
|
|
15
15
|
it("triggers selectionManager.setSelectedKeys() with currently selected and filtered options when button is clicked", async () => {
|
|
16
|
-
const spy =
|
|
16
|
+
const spy = vi.fn()
|
|
17
17
|
const selectedAndFiltered = "selectedAndFiltered"
|
|
18
18
|
const filteredButNotSelected = "focusedButNotSelected"
|
|
19
19
|
const selectedButNotFiltered = "selectedButNotFiltered"
|
|
20
20
|
const selectedKeys = [selectedAndFiltered, selectedButNotFiltered]
|
|
21
21
|
const filteredKeys = [selectedAndFiltered, filteredButNotSelected]
|
|
22
22
|
|
|
23
|
-
;(useSelectionContext as
|
|
23
|
+
;(useSelectionContext as Mock).mockReturnValue({
|
|
24
24
|
selectionState: {
|
|
25
25
|
collection: {
|
|
26
26
|
getKeys: () => filteredKeys,
|
|
@@ -45,12 +45,12 @@ describe("<SelectAllButton /> - interaction", () => {
|
|
|
45
45
|
|
|
46
46
|
describe("Given all filtered options are selected", () => {
|
|
47
47
|
it("does not trigger selectionManager.setSelectedKeys() when clicks on the button", async () => {
|
|
48
|
-
const spy =
|
|
48
|
+
const spy = vi.fn()
|
|
49
49
|
const selectedAndFiltered1 = "selectedAndFiltered1"
|
|
50
50
|
const selectedAndFiltered2 = "selectedAndFocused2"
|
|
51
51
|
const selectedKeys = [selectedAndFiltered1, selectedAndFiltered2]
|
|
52
52
|
const filteredKeys = [selectedAndFiltered1, selectedAndFiltered2]
|
|
53
|
-
;(useSelectionContext as
|
|
53
|
+
;(useSelectionContext as Mock).mockReturnValue({
|
|
54
54
|
selectionState: {
|
|
55
55
|
collection: {
|
|
56
56
|
getKeys: () => filteredKeys,
|
|
@@ -74,7 +74,7 @@ describe("<SelectAllButton /> - interaction", () => {
|
|
|
74
74
|
|
|
75
75
|
describe("Given some options are disabled", () => {
|
|
76
76
|
it("triggers selectionManager.setSelectedKeys() on non-disabled options", async () => {
|
|
77
|
-
const spy =
|
|
77
|
+
const spy = vi.fn()
|
|
78
78
|
const filtered = "filtered"
|
|
79
79
|
const filteredAndSelected = "filteredAndSelected"
|
|
80
80
|
const filteredAndDisabled = "filteredAndDisabled"
|
|
@@ -82,7 +82,7 @@ describe("<SelectAllButton /> - interaction", () => {
|
|
|
82
82
|
const filteredKeys = [filtered, filteredAndSelected, filteredAndDisabled]
|
|
83
83
|
const disabledKeys = [filteredAndDisabled]
|
|
84
84
|
|
|
85
|
-
;(useSelectionContext as
|
|
85
|
+
;(useSelectionContext as Mock).mockReturnValue({
|
|
86
86
|
selectionState: {
|
|
87
87
|
disabledKeys,
|
|
88
88
|
collection: {
|
|
@@ -180,7 +180,7 @@ const defaultProps: FilterSelectProps = {
|
|
|
180
180
|
items: singleMockItems,
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
/* eslint-disable
|
|
183
|
+
/* eslint-disable vitest/expect-expect */
|
|
184
184
|
describe("FilterSelect generic", () => {
|
|
185
185
|
it("should prevent adding `options` attribute to option", () => {
|
|
186
186
|
/* @ts-expect-error */
|
|
@@ -213,4 +213,4 @@ describe("FilterSelect generic", () => {
|
|
|
213
213
|
})
|
|
214
214
|
})
|
|
215
215
|
})
|
|
216
|
-
/* eslint-enable
|
|
216
|
+
/* eslint-enable vitest/expect-expect */
|
|
@@ -1,37 +1,8 @@
|
|
|
1
1
|
import * as React from "react"
|
|
2
2
|
import { render } from "@testing-library/react"
|
|
3
|
-
import { AllowedHeadingTags, Heading, HeadingVariants } from "
|
|
3
|
+
import { AllowedHeadingTags, Heading, HeadingVariants } from "."
|
|
4
4
|
|
|
5
5
|
describe("<Heading />", () => {
|
|
6
|
-
it("renders the correct classes", () => {
|
|
7
|
-
const headingMock = render(<Heading variant="display-0">Example</Heading>)
|
|
8
|
-
const headingClasslist = headingMock.getByText("Example").classList
|
|
9
|
-
expect(headingClasslist).toContain("heading")
|
|
10
|
-
expect(headingClasslist).toContain("display-0")
|
|
11
|
-
expect(headingClasslist).toContain("large")
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
it("adds a .small class instead of .large if a Heading 3 is used", () => {
|
|
15
|
-
const headingMock = render(
|
|
16
|
-
<Heading variant="heading-3" tag="div">
|
|
17
|
-
Example
|
|
18
|
-
</Heading>
|
|
19
|
-
)
|
|
20
|
-
expect(headingMock.getByText("Example").classList).toContain("small")
|
|
21
|
-
expect(headingMock.getByText("Example").classList).not.toContain("large")
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
it("adds a .dark-reduced-opacity class if the color prop is set to that", () => {
|
|
25
|
-
const headingMock = render(
|
|
26
|
-
<Heading variant="heading-3" color="dark-reduced-opacity">
|
|
27
|
-
Example
|
|
28
|
-
</Heading>
|
|
29
|
-
)
|
|
30
|
-
expect(headingMock.getByText("Example").classList).toContain(
|
|
31
|
-
"dark-reduced-opacity"
|
|
32
|
-
)
|
|
33
|
-
})
|
|
34
|
-
|
|
35
6
|
it("changes rendered HTML element when passed tag", () => {
|
|
36
7
|
const headingMock = render(
|
|
37
8
|
<Heading variant="display-0" tag="div">
|
|
@@ -66,7 +37,6 @@ describe("<Heading />", () => {
|
|
|
66
37
|
it(`renders the correct element for <Heading variant={${variant}} />`, () => {
|
|
67
38
|
const headingMock = render(<Heading variant={variant}>Example</Heading>)
|
|
68
39
|
expect(headingMock.getByText("Example").tagName.toLowerCase()).toBe(el)
|
|
69
|
-
expect(headingMock.baseElement).toMatchSnapshot()
|
|
70
40
|
})
|
|
71
41
|
})
|
|
72
42
|
})
|