@kaizen/components 1.61.0 → 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 +115 -114
- 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/__layout__/Workflow/v3/_docs/Workflow.stories.tsx +8 -2
- package/src/__layout__/Workflow/v3/subcomponents/Footer/components/Root/FooterRoot.module.css +1 -0
- package/src/__layout__/Workflow/v3/subcomponents/Header/components/Root/Root.module.css +1 -1
- 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 from "react"
|
|
2
2
|
import { render, waitFor, screen, within } from "@testing-library/react"
|
|
3
3
|
import userEvent from "@testing-library/user-event"
|
|
4
|
+
import { vi } from "vitest"
|
|
4
5
|
import { Select, SelectProps } from "./Select"
|
|
5
6
|
import { singleMockItems } from "./_docs/mockData"
|
|
6
|
-
|
|
7
7
|
const user = userEvent.setup()
|
|
8
8
|
|
|
9
9
|
const SelectWrapper = ({
|
|
@@ -87,7 +87,7 @@ describe("<Select />", () => {
|
|
|
87
87
|
})
|
|
88
88
|
|
|
89
89
|
it("fires the onOpenChange callback when the trigger is interacted", async () => {
|
|
90
|
-
const onOpenChange =
|
|
90
|
+
const onOpenChange = vi.fn()
|
|
91
91
|
const { getByRole } = render(
|
|
92
92
|
<SelectWrapper
|
|
93
93
|
selectedKey="batch-brew"
|
|
@@ -267,7 +267,7 @@ describe("<Select />", () => {
|
|
|
267
267
|
|
|
268
268
|
describe("Selection - Mouse interaction", () => {
|
|
269
269
|
it("fires onSelectionChange when clicks on a option", async () => {
|
|
270
|
-
const spy =
|
|
270
|
+
const spy = vi.fn()
|
|
271
271
|
const { getByRole } = render(
|
|
272
272
|
<SelectWrapper defaultOpen onSelectionChange={spy} />
|
|
273
273
|
)
|
|
@@ -335,7 +335,7 @@ describe("<Select />", () => {
|
|
|
335
335
|
})
|
|
336
336
|
|
|
337
337
|
it("fires onSelectionChange when hits enter on a option", async () => {
|
|
338
|
-
const spy =
|
|
338
|
+
const spy = vi.fn()
|
|
339
339
|
const { getByRole } = render(<SelectWrapper onSelectionChange={spy} />)
|
|
340
340
|
|
|
341
341
|
await user.tab()
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import { Meta, StoryObj } from "@storybook/react"
|
|
3
|
+
import { Heading } from "~components/Heading"
|
|
3
4
|
import { CloseIcon, VisibleIcon } from "~components/Icon"
|
|
5
|
+
import { Text } from "~components/Text"
|
|
4
6
|
import { TextField } from "~components/TextField"
|
|
5
7
|
import { Button } from "~components/__actions__/v2"
|
|
6
8
|
import { Tag } from "~components/__future__"
|
|
@@ -10,12 +12,16 @@ import { WorkflowControls } from "./controls"
|
|
|
10
12
|
const MockContent = (): JSX.Element => (
|
|
11
13
|
<div className="flex flex-col flex-1 m-24 items-center">
|
|
12
14
|
<div className="max-w-[1392px] w-full">
|
|
13
|
-
<
|
|
15
|
+
<Text variant="intro-lede">
|
|
16
|
+
Name and schedule the self-reflection cycle
|
|
17
|
+
</Text>
|
|
14
18
|
<form
|
|
15
19
|
id="workflow-form-id"
|
|
16
20
|
className="bg-white rounded shadow-sm my-32 p-64"
|
|
17
21
|
>
|
|
18
|
-
<
|
|
22
|
+
<Heading variant="heading-3" classNameOverride="mb-24">
|
|
23
|
+
Name the cycle
|
|
24
|
+
</Heading>
|
|
19
25
|
<TextField
|
|
20
26
|
labelText="Cycle name"
|
|
21
27
|
type="text"
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
justify-content: center;
|
|
7
7
|
align-items: center;
|
|
8
8
|
text-align: center;
|
|
9
|
-
box-shadow: var(--shadow-small-box-shadow);
|
|
10
9
|
padding: var(--spacing-24);
|
|
11
10
|
gap: var(--spacing-16);
|
|
11
|
+
border-bottom: 2px solid rgb(var(--color-gray-600-rgb), 0.1);
|
|
12
12
|
|
|
13
13
|
@media (width >= 768px) {
|
|
14
14
|
align-items: start;
|
|
@@ -48,7 +48,7 @@ describe("<Tooltip />", () => {
|
|
|
48
48
|
// Non-semantic elements without roles should not have aria-description on them.
|
|
49
49
|
// They won't read to all screen readers as expected and may be reported in Storybook's accessibility tab (which uses Axe under the hood)
|
|
50
50
|
it("doesn't add an accessible description when wrapping a non-semantic element", async () => {
|
|
51
|
-
const warn =
|
|
51
|
+
const warn = vi.spyOn(console, "warn").mockImplementation(vi.fn())
|
|
52
52
|
|
|
53
53
|
render(
|
|
54
54
|
<Tooltip
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from "react"
|
|
2
|
+
import { vi } from "vitest"
|
|
2
3
|
import { ArrowRightIcon } from "~components/Icon"
|
|
3
4
|
import { Button, IconButton } from "~components/__actions__/v2"
|
|
4
5
|
import { isSemanticElement } from "./isSemanticElement"
|
|
5
|
-
|
|
6
6
|
describe("isSemanticElement", () => {
|
|
7
7
|
it("returns true if provided a native element with a semantic role", () => {
|
|
8
8
|
expect(
|
|
9
9
|
isSemanticElement(
|
|
10
|
-
<button onClick={
|
|
10
|
+
<button onClick={vi.fn()} type="button">
|
|
11
11
|
click
|
|
12
12
|
</button>
|
|
13
13
|
)
|
|
@@ -28,19 +28,14 @@ describe("isSemanticElement", () => {
|
|
|
28
28
|
it("will return true if provided a non-semantic element with a semantic role", () => {
|
|
29
29
|
expect(
|
|
30
30
|
isSemanticElement(
|
|
31
|
-
<span
|
|
32
|
-
tabIndex={0}
|
|
33
|
-
role="button"
|
|
34
|
-
onKeyDown={jest.fn}
|
|
35
|
-
onClick={jest.fn()}
|
|
36
|
-
>
|
|
31
|
+
<span tabIndex={0} role="button" onKeyDown={vi.fn()} onClick={vi.fn()}>
|
|
37
32
|
custom semantic el
|
|
38
33
|
</span>
|
|
39
34
|
)
|
|
40
35
|
).toBe(true)
|
|
41
36
|
expect(
|
|
42
37
|
isSemanticElement(
|
|
43
|
-
<div tabIndex={0} role="button" onKeyDown={
|
|
38
|
+
<div tabIndex={0} role="button" onKeyDown={vi.fn()} onClick={vi.fn()}>
|
|
44
39
|
custom semantic el
|
|
45
40
|
</div>
|
|
46
41
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import { render, screen } from "@testing-library/react"
|
|
3
|
+
import { vi } from "vitest"
|
|
3
4
|
import { useMediaQueries, subtractOnePixel } from "./useMediaQueries"
|
|
4
|
-
|
|
5
5
|
const ExampleComponent = (): JSX.Element => {
|
|
6
6
|
const { queries, components } = useMediaQueries({
|
|
7
7
|
prefersReducedMotion: "(prefers-reduced-motion: reduce)",
|
|
@@ -27,15 +27,15 @@ const ExampleComponent = (): JSX.Element => {
|
|
|
27
27
|
export const mockMatchMedia = (matches: boolean = false): void => {
|
|
28
28
|
Object.defineProperty(window, "matchMedia", {
|
|
29
29
|
writable: true,
|
|
30
|
-
value:
|
|
30
|
+
value: vi.fn().mockImplementation(query => ({
|
|
31
31
|
matches,
|
|
32
32
|
media: query,
|
|
33
33
|
onchange: null,
|
|
34
|
-
addListener:
|
|
35
|
-
removeListener:
|
|
36
|
-
addEventListener:
|
|
37
|
-
removeEventListener:
|
|
38
|
-
dispatchEvent:
|
|
34
|
+
addListener: vi.fn(), // Deprecated
|
|
35
|
+
removeListener: vi.fn(), // Deprecated
|
|
36
|
+
addEventListener: vi.fn(),
|
|
37
|
+
removeEventListener: vi.fn(),
|
|
38
|
+
dispatchEvent: vi.fn(),
|
|
39
39
|
})),
|
|
40
40
|
})
|
|
41
41
|
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`<Heading /> defaults to the correct HTML element renders the correct element for <Heading variant={display-0} /> 1`] = `
|
|
4
|
-
<body>
|
|
5
|
-
<div>
|
|
6
|
-
<h1
|
|
7
|
-
class="heading display-0 dark large"
|
|
8
|
-
>
|
|
9
|
-
Example
|
|
10
|
-
</h1>
|
|
11
|
-
</div>
|
|
12
|
-
</body>
|
|
13
|
-
`;
|
|
14
|
-
|
|
15
|
-
exports[`<Heading /> defaults to the correct HTML element renders the correct element for <Heading variant={heading-1} /> 1`] = `
|
|
16
|
-
<body>
|
|
17
|
-
<div>
|
|
18
|
-
<h1
|
|
19
|
-
class="heading heading-1 dark large"
|
|
20
|
-
>
|
|
21
|
-
Example
|
|
22
|
-
</h1>
|
|
23
|
-
</div>
|
|
24
|
-
</body>
|
|
25
|
-
`;
|
|
26
|
-
|
|
27
|
-
exports[`<Heading /> defaults to the correct HTML element renders the correct element for <Heading variant={heading-2} /> 1`] = `
|
|
28
|
-
<body>
|
|
29
|
-
<div>
|
|
30
|
-
<h2
|
|
31
|
-
class="heading heading-2 dark large"
|
|
32
|
-
>
|
|
33
|
-
Example
|
|
34
|
-
</h2>
|
|
35
|
-
</div>
|
|
36
|
-
</body>
|
|
37
|
-
`;
|
|
38
|
-
|
|
39
|
-
exports[`<Heading /> defaults to the correct HTML element renders the correct element for <Heading variant={heading-3} /> 1`] = `
|
|
40
|
-
<body>
|
|
41
|
-
<div>
|
|
42
|
-
<h3
|
|
43
|
-
class="heading heading-3 dark small"
|
|
44
|
-
>
|
|
45
|
-
Example
|
|
46
|
-
</h3>
|
|
47
|
-
</div>
|
|
48
|
-
</body>
|
|
49
|
-
`;
|
|
50
|
-
|
|
51
|
-
exports[`<Heading /> defaults to the correct HTML element renders the correct element for <Heading variant={heading-4} /> 1`] = `
|
|
52
|
-
<body>
|
|
53
|
-
<div>
|
|
54
|
-
<h4
|
|
55
|
-
class="heading heading-4 dark small"
|
|
56
|
-
>
|
|
57
|
-
Example
|
|
58
|
-
</h4>
|
|
59
|
-
</div>
|
|
60
|
-
</body>
|
|
61
|
-
`;
|
|
62
|
-
|
|
63
|
-
exports[`<Heading /> defaults to the correct HTML element renders the correct element for <Heading variant={heading-5} /> 1`] = `
|
|
64
|
-
<body>
|
|
65
|
-
<div>
|
|
66
|
-
<h5
|
|
67
|
-
class="heading heading-5 dark small"
|
|
68
|
-
>
|
|
69
|
-
Example
|
|
70
|
-
</h5>
|
|
71
|
-
</div>
|
|
72
|
-
</body>
|
|
73
|
-
`;
|
|
74
|
-
|
|
75
|
-
exports[`<Heading /> defaults to the correct HTML element renders the correct element for <Heading variant={heading-6} /> 1`] = `
|
|
76
|
-
<body>
|
|
77
|
-
<div>
|
|
78
|
-
<h6
|
|
79
|
-
class="heading heading-6 dark small"
|
|
80
|
-
>
|
|
81
|
-
Example
|
|
82
|
-
</h6>
|
|
83
|
-
</div>
|
|
84
|
-
</body>
|
|
85
|
-
`;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import React, { RefObject, act } from "react"
|
|
2
|
-
import { render, renderHook } from "@testing-library/react"
|
|
3
|
-
import { LaunchIcon, PauseIcon } from "~components/Icon"
|
|
4
|
-
import { usePausePlay, usePausePlayHook } from "./usePausePlay"
|
|
5
|
-
|
|
6
|
-
describe("usePausePlay()", () => {
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
jest.clearAllMocks()
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
let hookResult: usePausePlayHook
|
|
12
|
-
const mockPause = jest.fn()
|
|
13
|
-
const mockPlay = jest.fn()
|
|
14
|
-
|
|
15
|
-
describe("when toggling a currently playing video", () => {
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
const fakeRef = {
|
|
18
|
-
current: {
|
|
19
|
-
pause: mockPause,
|
|
20
|
-
play: mockPlay,
|
|
21
|
-
paused: false, // It's playing
|
|
22
|
-
},
|
|
23
|
-
} as unknown as RefObject<HTMLVideoElement>
|
|
24
|
-
|
|
25
|
-
const { result } = renderHook(() => usePausePlay(fakeRef))
|
|
26
|
-
|
|
27
|
-
act(() => {
|
|
28
|
-
result.current.toggle()
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
hookResult = result.current
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
it("pauses the video", () => {
|
|
35
|
-
expect(mockPause).toHaveBeenCalled()
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
it("returns the play icon", () => {
|
|
39
|
-
const { baseElement: original } = render(hookResult.icon)
|
|
40
|
-
const { baseElement: comparison } = render(
|
|
41
|
-
<LaunchIcon role="presentation" />
|
|
42
|
-
)
|
|
43
|
-
expect(original).toEqual(comparison)
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
it("returns the 'Play animation' label", () => {
|
|
47
|
-
expect(hookResult.label).toEqual("Play animation")
|
|
48
|
-
})
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
describe("when toggling a currently paused video", () => {
|
|
52
|
-
beforeEach(() => {
|
|
53
|
-
const fakeRef = {
|
|
54
|
-
current: {
|
|
55
|
-
pause: mockPause,
|
|
56
|
-
play: mockPlay,
|
|
57
|
-
paused: true, // It's not playing
|
|
58
|
-
},
|
|
59
|
-
} as unknown as RefObject<HTMLVideoElement>
|
|
60
|
-
|
|
61
|
-
const { result } = renderHook(() => usePausePlay(fakeRef))
|
|
62
|
-
|
|
63
|
-
act(() => {
|
|
64
|
-
result.current.toggle()
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
hookResult = result.current
|
|
68
|
-
})
|
|
69
|
-
it("starts the video again", () => {
|
|
70
|
-
expect(mockPlay).toHaveBeenCalled()
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
it("returns the pause icon", () => {
|
|
74
|
-
const { baseElement: original } = render(hookResult.icon)
|
|
75
|
-
const { baseElement: comparison } = render(
|
|
76
|
-
<PauseIcon role="presentation" />
|
|
77
|
-
)
|
|
78
|
-
expect(original).toEqual(comparison)
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
it("returns the 'Pause animation' label", () => {
|
|
82
|
-
expect(hookResult.label).toEqual("Pause animation")
|
|
83
|
-
})
|
|
84
|
-
})
|
|
85
|
-
})
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import React, { act } from "react"
|
|
2
|
-
import { fireEvent, waitFor } from "@testing-library/dom"
|
|
3
|
-
import { render } from "@testing-library/react"
|
|
4
|
-
import ReactTestUtils from "react-dom/test-utils"
|
|
5
|
-
import { GenericNotification } from "./GenericNotification"
|
|
6
|
-
|
|
7
|
-
describe("<GenericNotification />", () => {
|
|
8
|
-
afterEach(() => {
|
|
9
|
-
jest.runAllTimers()
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
jest.useFakeTimers()
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
it('begins "hidden" but transitions out of it immediately', async () => {
|
|
17
|
-
const { container } = render(
|
|
18
|
-
<GenericNotification type="positive" style="inline" title="Success">
|
|
19
|
-
This is my positive notification
|
|
20
|
-
</GenericNotification>
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
await waitFor(() => {
|
|
24
|
-
expect(container.querySelector(".hidden")).toBeInTheDocument()
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
await act(async () => {
|
|
28
|
-
jest.advanceTimersByTime(50)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
await waitFor(() => {
|
|
32
|
-
expect(container.querySelector(".hidden")).not.toBeInTheDocument()
|
|
33
|
-
})
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it("hides the notification and triggers the onHide callback when the cancel button is clicked", async () => {
|
|
37
|
-
const onHide = jest.fn()
|
|
38
|
-
const { container, getByTestId } = render(
|
|
39
|
-
<GenericNotification
|
|
40
|
-
type="positive"
|
|
41
|
-
style="inline"
|
|
42
|
-
title="Success"
|
|
43
|
-
onHide={onHide}
|
|
44
|
-
>
|
|
45
|
-
Notification Text
|
|
46
|
-
</GenericNotification>
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
// The element should start in a "hidden" state
|
|
50
|
-
expect(container.querySelector(".hidden")).toBeTruthy()
|
|
51
|
-
|
|
52
|
-
// After clicking, the element should fade out, but the onHide not trigger yet.
|
|
53
|
-
const cancelButton = getByTestId("close-button")
|
|
54
|
-
const notification = container.querySelector(".notification")
|
|
55
|
-
|
|
56
|
-
fireEvent(cancelButton, new MouseEvent("click"))
|
|
57
|
-
|
|
58
|
-
await waitFor(() => {
|
|
59
|
-
expect(notification).toBeTruthy()
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
// Cannot use @testing-library/react `fireEvent` as it relies on jsdom events
|
|
63
|
-
// TransitionEvent has not been implemented yet, using `ReactTestUtils.Simulate` is a workaround
|
|
64
|
-
act(() => {
|
|
65
|
-
notification &&
|
|
66
|
-
ReactTestUtils.Simulate.transitionEnd(notification, {
|
|
67
|
-
propertyName: "margin-top",
|
|
68
|
-
} as any)
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
await waitFor(() => {
|
|
72
|
-
expect(notification).not.toBeInTheDocument()
|
|
73
|
-
})
|
|
74
|
-
await waitFor(() => expect(onHide).toHaveBeenCalledTimes(1))
|
|
75
|
-
})
|
|
76
|
-
})
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`<Text /> defaults to the correct HTML element renders the correct element for <Text variant={body} /> 1`] = `
|
|
4
|
-
<body>
|
|
5
|
-
<div>
|
|
6
|
-
<p
|
|
7
|
-
class="text body dark"
|
|
8
|
-
>
|
|
9
|
-
Example
|
|
10
|
-
</p>
|
|
11
|
-
</div>
|
|
12
|
-
</body>
|
|
13
|
-
`;
|
|
14
|
-
|
|
15
|
-
exports[`<Text /> defaults to the correct HTML element renders the correct element for <Text variant={extra-small} /> 1`] = `
|
|
16
|
-
<body>
|
|
17
|
-
<div>
|
|
18
|
-
<p
|
|
19
|
-
class="text extra-small dark"
|
|
20
|
-
>
|
|
21
|
-
Example
|
|
22
|
-
</p>
|
|
23
|
-
</div>
|
|
24
|
-
</body>
|
|
25
|
-
`;
|
|
26
|
-
|
|
27
|
-
exports[`<Text /> defaults to the correct HTML element renders the correct element for <Text variant={intro-lede} /> 1`] = `
|
|
28
|
-
<body>
|
|
29
|
-
<div>
|
|
30
|
-
<p
|
|
31
|
-
class="text intro-lede dark"
|
|
32
|
-
>
|
|
33
|
-
Example
|
|
34
|
-
</p>
|
|
35
|
-
</div>
|
|
36
|
-
</body>
|
|
37
|
-
`;
|
|
38
|
-
|
|
39
|
-
exports[`<Text /> defaults to the correct HTML element renders the correct element for <Text variant={small} /> 1`] = `
|
|
40
|
-
<body>
|
|
41
|
-
<div>
|
|
42
|
-
<p
|
|
43
|
-
class="text small dark"
|
|
44
|
-
>
|
|
45
|
-
Example
|
|
46
|
-
</p>
|
|
47
|
-
</div>
|
|
48
|
-
</body>
|
|
49
|
-
`;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React from "react"
|
|
2
|
-
import { render } from "@testing-library/react"
|
|
3
|
-
import useDebounce from "use-debounce"
|
|
4
|
-
import { AnimationProvider } from "./AppearanceAnim"
|
|
5
|
-
|
|
6
|
-
jest.mock("use-debounce")
|
|
7
|
-
|
|
8
|
-
const useDebouncedCallback = useDebounce.useDebouncedCallback as jest.Mock
|
|
9
|
-
let mockReturnValue: Record<string, any>
|
|
10
|
-
|
|
11
|
-
describe("<AnimationProvider />", () => {
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
mockReturnValue = jest.fn()
|
|
14
|
-
mockReturnValue.cancel = (): void => undefined
|
|
15
|
-
useDebouncedCallback.mockImplementation(() => mockReturnValue)
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
describe("When no animationDuration prop is given", () => {
|
|
19
|
-
it("calls useDebouncedCallback with a 400 ms delay", () => {
|
|
20
|
-
render(<AnimationProvider isVisible />)
|
|
21
|
-
expect(useDebouncedCallback).toHaveBeenCalledWith(
|
|
22
|
-
expect.anything(),
|
|
23
|
-
400,
|
|
24
|
-
expect.anything()
|
|
25
|
-
)
|
|
26
|
-
})
|
|
27
|
-
})
|
|
28
|
-
describe("When an animationDuration prop is given", () => {
|
|
29
|
-
it("calls useDebouncedCallback with the animationDuration value", () => {
|
|
30
|
-
const expected = 1000
|
|
31
|
-
render(<AnimationProvider isVisible animationDuration={expected} />)
|
|
32
|
-
expect(useDebouncedCallback).toHaveBeenCalledWith(
|
|
33
|
-
expect.anything(),
|
|
34
|
-
expected,
|
|
35
|
-
expect.anything()
|
|
36
|
-
)
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
})
|