@torpor/ui 0.3.4 → 0.3.6
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/dist/Form/Form.torp +1 -0
- package/dist/metafile-esm.json +1 -1
- package/package.json +12 -9
- package/CHANGELOG.md +0 -338
- package/scripts/postbuild.ts +0 -127
- package/src/Accordion/Accordion.torp +0 -230
- package/src/Accordion/AccordionContent.torp +0 -46
- package/src/Accordion/AccordionHeader.torp +0 -45
- package/src/Accordion/AccordionItem.torp +0 -101
- package/src/Accordion/AccordionTrigger.torp +0 -70
- package/src/Accordion/AccordionTypes.ts +0 -36
- package/src/Accordion/index.ts +0 -7
- package/src/Breadcrumb/Breadcrumb.torp +0 -45
- package/src/Breadcrumb/BreadcrumbItem.torp +0 -30
- package/src/Breadcrumb/BreadcrumbSeparator.torp +0 -27
- package/src/Breadcrumb/index.ts +0 -5
- package/src/Calendar/Calendar.torp +0 -277
- package/src/Calendar/CalendarDay.torp +0 -78
- package/src/Calendar/CalendarTypes.ts +0 -22
- package/src/Calendar/index.ts +0 -4
- package/src/Contextual/Contextual.torp +0 -129
- package/src/Contextual/ContextualContent.torp +0 -112
- package/src/Contextual/ContextualTrigger.torp +0 -70
- package/src/Contextual/ContextualTypes.ts +0 -30
- package/src/Contextual/index.ts +0 -5
- package/src/Dialog/Dialog.torp +0 -136
- package/src/Dialog/DialogBody.torp +0 -44
- package/src/Dialog/DialogButton.torp +0 -66
- package/src/Dialog/DialogFooter.torp +0 -25
- package/src/Dialog/DialogHeader.torp +0 -45
- package/src/Dialog/DialogTypes.ts +0 -17
- package/src/Dialog/index.ts +0 -7
- package/src/Disclosure/Disclosure.torp +0 -82
- package/src/Disclosure/DisclosureContent.torp +0 -46
- package/src/Disclosure/DisclosureHeader.torp +0 -45
- package/src/Disclosure/DisclosureTrigger.torp +0 -47
- package/src/Disclosure/DisclosureTypes.ts +0 -13
- package/src/Disclosure/index.ts +0 -6
- package/src/Drawer/Drawer.torp +0 -127
- package/src/Drawer/DrawerContent.torp +0 -83
- package/src/Drawer/DrawerOverlay.torp +0 -42
- package/src/Drawer/DrawerTrigger.torp +0 -39
- package/src/Drawer/DrawerTypes.ts +0 -24
- package/src/Drawer/index.ts +0 -6
- package/src/Form/CheckBox.torp +0 -94
- package/src/Form/Field.torp +0 -95
- package/src/Form/File.torp +0 -102
- package/src/Form/Form.torp +0 -146
- package/src/Form/FormTypes.ts +0 -35
- package/src/Form/Hidden.torp +0 -25
- package/src/Form/Input.torp +0 -112
- package/src/Form/Label.torp +0 -35
- package/src/Form/Message.torp +0 -39
- package/src/Form/Option.torp +0 -28
- package/src/Form/Select.torp +0 -101
- package/src/Form/StandardSchemaV1.ts +0 -70
- package/src/Form/TextArea.torp +0 -105
- package/src/Form/index.ts +0 -13
- package/src/Menu/Menu.torp +0 -174
- package/src/Menu/MenuButton.torp +0 -74
- package/src/Menu/MenuCheck.torp +0 -89
- package/src/Menu/MenuGroup.torp +0 -31
- package/src/Menu/MenuIndicator.torp +0 -40
- package/src/Menu/MenuPopout.torp +0 -83
- package/src/Menu/MenuPopoutContent.torp +0 -84
- package/src/Menu/MenuPopoutTrigger.torp +0 -128
- package/src/Menu/MenuRadio.torp +0 -103
- package/src/Menu/MenuRadioGroup.torp +0 -109
- package/src/Menu/MenuSeparator.torp +0 -26
- package/src/Menu/MenuTypes.ts +0 -60
- package/src/Menu/index.ts +0 -25
- package/src/MenuBar/MenuBar.torp +0 -162
- package/src/MenuBar/MenuBarItem.torp +0 -116
- package/src/MenuBar/MenuBarItemContent.torp +0 -119
- package/src/MenuBar/MenuBarItemTrigger.torp +0 -99
- package/src/MenuBar/MenuBarTypes.ts +0 -36
- package/src/MenuBar/index.ts +0 -6
- package/src/Modal/Modal.torp +0 -122
- package/src/Modal/ModalContent.torp +0 -81
- package/src/Modal/ModalOverlay.torp +0 -42
- package/src/Modal/ModalTrigger.torp +0 -54
- package/src/Modal/ModalTypes.ts +0 -22
- package/src/Modal/index.ts +0 -10
- package/src/Modal/showModal.ts +0 -19
- package/src/Modal/showPrompt.ts +0 -23
- package/src/NavMenu/NavMenu.torp +0 -190
- package/src/NavMenu/NavMenuButton.torp +0 -55
- package/src/NavMenu/NavMenuElement.torp +0 -55
- package/src/NavMenu/NavMenuGroup.torp +0 -41
- package/src/NavMenu/NavMenuGroupHeader.torp +0 -41
- package/src/NavMenu/NavMenuLink.torp +0 -60
- package/src/NavMenu/NavMenuPopout.torp +0 -89
- package/src/NavMenu/NavMenuPopoutButton.torp +0 -129
- package/src/NavMenu/NavMenuPopoutContent.torp +0 -92
- package/src/NavMenu/NavMenuSeparator.torp +0 -24
- package/src/NavMenu/NavMenuTypes.ts +0 -32
- package/src/NavMenu/index.ts +0 -23
- package/src/Notification/Notification.torp +0 -71
- package/src/Notification/NotificationClose.torp +0 -39
- package/src/Notification/NotificationContainer.torp +0 -26
- package/src/Notification/NotificationContent.torp +0 -25
- package/src/Notification/NotificationTypes.ts +0 -5
- package/src/Notification/index.ts +0 -13
- package/src/Notification/showNotification.ts +0 -30
- package/src/Popover/Popover.torp +0 -129
- package/src/Popover/PopoverContent.torp +0 -117
- package/src/Popover/PopoverTrigger.torp +0 -62
- package/src/Popover/PopoverTypes.ts +0 -30
- package/src/Popover/index.ts +0 -6
- package/src/Popover/showPopover.ts +0 -24
- package/src/Slider/Slider.torp +0 -84
- package/src/Slider/index.ts +0 -3
- package/src/TabGroup/TabContent.torp +0 -49
- package/src/TabGroup/TabGroup.torp +0 -250
- package/src/TabGroup/TabGroupTypes.ts +0 -44
- package/src/TabGroup/TabHeader.torp +0 -81
- package/src/TabGroup/TabList.torp +0 -61
- package/src/TabGroup/TabTrigger.torp +0 -76
- package/src/TabGroup/index.ts +0 -7
- package/src/ambient.d.ts +0 -7
- package/src/icons/ArrowDown.torp +0 -18
- package/src/icons/ArrowLeft.torp +0 -18
- package/src/icons/ArrowRight.torp +0 -18
- package/src/icons/ArrowUp.torp +0 -18
- package/src/icons/Bars.torp +0 -20
- package/src/icons/Check.torp +0 -18
- package/src/icons/ChevronDown.torp +0 -18
- package/src/icons/ChevronLeft.torp +0 -18
- package/src/icons/ChevronRight.torp +0 -18
- package/src/icons/ChevronUp.torp +0 -18
- package/src/icons/Cross.torp +0 -19
- package/src/icons/IconTypes.ts +0 -10
- package/src/icons/Loading.torp +0 -19
- package/src/icons/Minus.torp +0 -18
- package/src/icons/Plus.torp +0 -19
- package/src/icons/index.ts +0 -31
- package/src/motion/fade.ts +0 -16
- package/src/motion/grow.ts +0 -23
- package/src/motion/index.ts +0 -6
- package/src/motion/measure.ts +0 -28
- package/src/motion/slide.ts +0 -45
- package/src/mount/clickPopover.ts +0 -51
- package/src/mount/contextPopover.ts +0 -51
- package/src/mount/disableScroll.ts +0 -28
- package/src/mount/hoverPopover.ts +0 -58
- package/src/mount/hoverTrigger.ts +0 -59
- package/src/mount/trapFocus.ts +0 -58
- package/src/utils/dateUtils.ts +0 -244
- package/src/utils/documentEvents.ts +0 -17
- package/src/utils/getId.ts +0 -6
- package/src/utils/getScrollParent.ts +0 -22
- package/src/utils/setContextPosition.ts +0 -31
- package/src/utils/setPopoverPosition.ts +0 -142
- package/test/Accordion/accessibility.test.ts +0 -59
- package/test/Accordion/components/AccordionAccessibility.torp +0 -44
- package/test/Accordion/components/AccordionKeyboard.torp +0 -32
- package/test/Accordion/components/AccordionList.torp +0 -23
- package/test/Accordion/components/AccordionMultiple.torp +0 -32
- package/test/Accordion/components/AccordionSingle.torp +0 -32
- package/test/Accordion/for-items.test.ts +0 -52
- package/test/Accordion/keyboard.test.ts +0 -64
- package/test/Accordion/multiple-item-toggle.test.ts +0 -32
- package/test/Accordion/multiple-item-value.test.ts +0 -17
- package/test/Accordion/single-item-toggle.test.ts +0 -31
- package/test/Accordion/single-item-value.test.ts +0 -17
- package/test/Breadcrumb/accessibility.test.ts +0 -29
- package/test/Breadcrumb/basic.test.ts +0 -17
- package/test/Breadcrumb/components/BreadcrumbTest.torp +0 -15
- package/test/Calendar/components/CalendarTest.torp +0 -9
- package/test/Calendar/default.test.ts +0 -18
- package/test/Dialog/accessibility-alert.test.ts +0 -40
- package/test/Dialog/accessibility-modal.test.ts +0 -52
- package/test/Dialog/components/DialogAccessibility.torp +0 -25
- package/test/Dialog/components/DialogFunction.torp +0 -36
- package/test/Dialog/components/DialogModal.torp +0 -30
- package/test/Dialog/components/DialogVariable.torp +0 -33
- package/test/Dialog/function.test.ts +0 -26
- package/test/Dialog/variable.test.ts +0 -27
- package/test/Disclosure/accessibility.test.ts +0 -31
- package/test/Disclosure/components/DisclosureTest.torp +0 -17
- package/test/Disclosure/default.test.ts +0 -15
- package/test/Disclosure/toggle.test.ts +0 -20
- package/test/Form/components/FieldTest.torp +0 -25
- package/test/Form/components/FormTest.torp +0 -31
- package/test/Form/components/InputTest.torp +0 -9
- package/test/Form/field.test.ts +0 -34
- package/test/Form/form.test.ts +0 -34
- package/test/Form/input.test.ts +0 -19
- package/test/Menu/accessibility.test.ts +0 -83
- package/test/Menu/basic.test.ts +0 -58
- package/test/Menu/components/MenuAccessibility.torp +0 -59
- package/test/Menu/components/MenuBasic.torp +0 -58
- package/test/MenuBar/accessibility.test.ts +0 -87
- package/test/MenuBar/basic.test.ts +0 -22
- package/test/MenuBar/components/MenuBarAccessibility.torp +0 -34
- package/test/MenuBar/components/MenuBarBasic.torp +0 -25
- package/test/NavMenu/accessibility.test.ts +0 -97
- package/test/NavMenu/basic.test.ts +0 -22
- package/test/NavMenu/components/NavMenuAccessibility.torp +0 -35
- package/test/NavMenu/components/NavMenuBasic.torp +0 -28
- package/test/Notification/accessibility.test.ts +0 -21
- package/test/Notification/components/CustomNotification.torp +0 -14
- package/test/Notification/components/NotificationAccessibility.torp +0 -14
- package/test/Notification/components/NotificationFunction.torp +0 -17
- package/test/Notification/components/NotificationVariable.torp +0 -22
- package/test/Notification/function.test.ts +0 -25
- package/test/Notification/variable.test.ts +0 -25
- package/test/Popover/components/CustomDialog.torp +0 -25
- package/test/Popover/components/PopoverFunction.torp +0 -37
- package/test/Popover/components/PopoverTrigger.torp +0 -36
- package/test/Popover/components/PopoverVariable.torp +0 -40
- package/test/Popover/function.test.ts +0 -21
- package/test/Popover/trigger.test.ts +0 -27
- package/test/Popover/variable.test.ts +0 -27
- package/test/TabGroup/accessibility.test.ts +0 -67
- package/test/TabGroup/components/TabGroupAccessibility.torp +0 -28
- package/test/TabGroup/components/TabGroupKeyboard.torp +0 -28
- package/test/TabGroup/components/TabGroupList.torp +0 -26
- package/test/TabGroup/components/TabGroupTrigger.torp +0 -28
- package/test/TabGroup/for-items.test.ts +0 -52
- package/test/TabGroup/item-trigger.test.ts +0 -33
- package/test/TabGroup/item-value.test.ts +0 -17
- package/test/TabGroup/keyboard.test.ts +0 -72
- package/tsconfig.json +0 -4
- package/tsup.config.ts +0 -37
- package/vitest.config.ts +0 -12
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { getByText, queryByText } from "@testing-library/dom";
|
|
2
|
-
import "@testing-library/jest-dom/vitest";
|
|
3
|
-
import userEvent from "@testing-library/user-event";
|
|
4
|
-
import { $watch, mount } from "@torpor/view";
|
|
5
|
-
import { describe, expect, it } from "vitest";
|
|
6
|
-
import AccordionList from "./components/AccordionList.torp";
|
|
7
|
-
|
|
8
|
-
describe("Accordion", () => {
|
|
9
|
-
it("Items in a for loop", async () => {
|
|
10
|
-
let $state = $watch({
|
|
11
|
-
value: "1",
|
|
12
|
-
items: [
|
|
13
|
-
{ id: 0, header: "Item 1", text: "Content 1" },
|
|
14
|
-
{ id: 1, header: "Item 2", text: "Content 2" },
|
|
15
|
-
{ id: 2, header: "Item 3", text: "Content 3" },
|
|
16
|
-
],
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
const container = document.createElement("div");
|
|
20
|
-
document.body.appendChild(container);
|
|
21
|
-
mount(container, AccordionList, $state);
|
|
22
|
-
|
|
23
|
-
expect(queryByText(container, "Content 1")).not.toBeInTheDocument();
|
|
24
|
-
expect(queryByText(container, "Item 2")).toBeInTheDocument();
|
|
25
|
-
expect(queryByText(container, "Content 2")).toBeInTheDocument();
|
|
26
|
-
expect(queryByText(container, "Content 3")).not.toBeInTheDocument();
|
|
27
|
-
|
|
28
|
-
$state.items.splice(1, 1);
|
|
29
|
-
|
|
30
|
-
expect(queryByText(container, "Content 1")).not.toBeInTheDocument();
|
|
31
|
-
expect(queryByText(container, "Item 2")).not.toBeInTheDocument();
|
|
32
|
-
expect(queryByText(container, "Content 2")).not.toBeInTheDocument();
|
|
33
|
-
expect(queryByText(container, "Content 3")).not.toBeInTheDocument();
|
|
34
|
-
|
|
35
|
-
// Clicking header 1 should reveal body 1
|
|
36
|
-
await userEvent.click(getByText(container, "Item 1"));
|
|
37
|
-
expect(queryByText(container, "Content 1")).toBeInTheDocument();
|
|
38
|
-
|
|
39
|
-
$state.items.push({ id: 3, header: "Item 4", text: "Content 4" });
|
|
40
|
-
|
|
41
|
-
expect(queryByText(container, "Content 1")).toBeInTheDocument();
|
|
42
|
-
expect(queryByText(container, "Content 2")).not.toBeInTheDocument();
|
|
43
|
-
expect(queryByText(container, "Content 3")).not.toBeInTheDocument();
|
|
44
|
-
expect(queryByText(container, "Item 4")).toBeInTheDocument();
|
|
45
|
-
expect(queryByText(container, "Content 4")).not.toBeInTheDocument();
|
|
46
|
-
|
|
47
|
-
// Clicking header 4 should reveal body 4
|
|
48
|
-
await userEvent.click(getByText(container, "Item 4"));
|
|
49
|
-
expect(queryByText(container, "Content 1")).not.toBeInTheDocument();
|
|
50
|
-
expect(queryByText(container, "Content 4")).toBeInTheDocument();
|
|
51
|
-
});
|
|
52
|
-
});
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { fireEvent, getByText, queryByText } from "@testing-library/dom";
|
|
2
|
-
import "@testing-library/jest-dom/vitest";
|
|
3
|
-
import { mount } from "@torpor/view";
|
|
4
|
-
import { describe, expect, it } from "vitest";
|
|
5
|
-
import AccordionKeyboard from "./components/AccordionKeyboard.torp";
|
|
6
|
-
|
|
7
|
-
describe("Accordion", () => {
|
|
8
|
-
it("Keyboard", async () => {
|
|
9
|
-
const container = document.createElement("div");
|
|
10
|
-
document.body.appendChild(container);
|
|
11
|
-
mount(container, AccordionKeyboard, { value: ["1", "2"] });
|
|
12
|
-
|
|
13
|
-
// Tests from https://www.w3.org/WAI/ARIA/apg/patterns/accordion/
|
|
14
|
-
|
|
15
|
-
// Enter or Space:
|
|
16
|
-
// * When focus is on the accordion header for a collapsed panel, expands the associated panel.
|
|
17
|
-
// If the implementation allows only one panel to be expanded, and if another panel is expanded,
|
|
18
|
-
// collapses that panel
|
|
19
|
-
// * When focus is on the accordion header for an expanded panel, collapses the panel if the
|
|
20
|
-
// implementation supports collapsing. Some implementations require one panel to be expanded
|
|
21
|
-
// at all times and allow only one panel to be expanded; so, they do not support a collapse
|
|
22
|
-
// function
|
|
23
|
-
// NOTE: I don't think we can test this
|
|
24
|
-
// NOTE: Accordion headers are buttons so this functionality should be baked in by default
|
|
25
|
-
//screen.queryByText('Header 1').focus();
|
|
26
|
-
//expect(screen.queryByText('Content 1')).not.toBeInTheDocument();
|
|
27
|
-
//fireEvent(screen.getByText('Header 1'), { key: 'Space' });
|
|
28
|
-
//expect(screen.queryByText('Content 1')).toBeInTheDocument();
|
|
29
|
-
//fireEvent(screen.getByText('Header 1'), { key: 'Space' });
|
|
30
|
-
//expect(screen.queryByText('Content 1')).not.toBeInTheDocument();
|
|
31
|
-
|
|
32
|
-
// Tab: Moves focus to the next focusable element; all focusable elements in the accordion are
|
|
33
|
-
// included in the page Tab sequence
|
|
34
|
-
// NOTE: I don't think we can test this
|
|
35
|
-
//fireEvent(screen.getByText('Header 1'), { key: 'Tab' });
|
|
36
|
-
//expect(document.activeElement).toBe(screen.queryByText('Header 2'));
|
|
37
|
-
|
|
38
|
-
// Shift + Tab: Moves focus to the previous focusable element; all focusable elements in the
|
|
39
|
-
// accordion are included in the page Tab sequence
|
|
40
|
-
// NOTE: I don't think we can test this
|
|
41
|
-
//fireEvent(screen.getByText('Header 2'), { key: 'Tab', shiftKey: true });
|
|
42
|
-
//expect(document.activeElement).toBe(screen.queryByText('Header 1'));
|
|
43
|
-
|
|
44
|
-
// Down Arrow: If focus is on an accordion header, moves focus to the next accordion header.
|
|
45
|
-
// If focus is on the last accordion header, either does nothing or moves focus to the first
|
|
46
|
-
// accordion header
|
|
47
|
-
fireEvent(getByText(container, "Header 1"), new KeyboardEvent("keydown", { key: "ArrowDown" }));
|
|
48
|
-
expect(document.activeElement).toBe(queryByText(container, "Header 2"));
|
|
49
|
-
|
|
50
|
-
// Up Arrow: If focus is on an accordion header, moves focus to the previous accordion header.
|
|
51
|
-
// If focus is on the first accordion header, either does nothing or moves focus to the last
|
|
52
|
-
// accordion header
|
|
53
|
-
fireEvent(getByText(container, "Header 2"), new KeyboardEvent("keydown", { key: "ArrowUp" }));
|
|
54
|
-
expect(document.activeElement).toBe(queryByText(container, "Header 1"));
|
|
55
|
-
|
|
56
|
-
// Home: When focus is on an accordion header, moves focus to the first accordion header
|
|
57
|
-
fireEvent(getByText(container, "Header 3"), new KeyboardEvent("keydown", { key: "Home" }));
|
|
58
|
-
expect(document.activeElement).toBe(queryByText(container, "Header 1"));
|
|
59
|
-
|
|
60
|
-
// End: When focus is on an accordion header, moves focus to the last accordion header
|
|
61
|
-
fireEvent(getByText(container, "Header 1"), new KeyboardEvent("keydown", { key: "End" }));
|
|
62
|
-
expect(document.activeElement).toBe(queryByText(container, "Header 3"));
|
|
63
|
-
});
|
|
64
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { getByText, queryByText } from "@testing-library/dom";
|
|
2
|
-
import "@testing-library/jest-dom/vitest";
|
|
3
|
-
import userEvent from "@testing-library/user-event";
|
|
4
|
-
import { mount } from "@torpor/view";
|
|
5
|
-
import { describe, expect, it } from "vitest";
|
|
6
|
-
import AccordionMultiple from "./components/AccordionMultiple.torp";
|
|
7
|
-
|
|
8
|
-
describe("Accordion", () => {
|
|
9
|
-
it("Multiple item toggle", async () => {
|
|
10
|
-
const container = document.createElement("div");
|
|
11
|
-
document.body.appendChild(container);
|
|
12
|
-
mount(container, AccordionMultiple);
|
|
13
|
-
|
|
14
|
-
expect(queryByText(container, "Content 1")).not.toBeInTheDocument();
|
|
15
|
-
expect(queryByText(container, "Content 2")).not.toBeInTheDocument();
|
|
16
|
-
expect(queryByText(container, "Content 3")).not.toBeInTheDocument();
|
|
17
|
-
|
|
18
|
-
// Clicking header 1 should reveal body 1
|
|
19
|
-
await userEvent.click(getByText(container, "Header 1"));
|
|
20
|
-
expect(queryByText(container, "Content 1")).toBeInTheDocument();
|
|
21
|
-
|
|
22
|
-
// Clicking header 2 should reveal body 1 and body 2
|
|
23
|
-
await userEvent.click(getByText(container, "Header 2"));
|
|
24
|
-
expect(queryByText(container, "Content 1")).toBeInTheDocument();
|
|
25
|
-
expect(queryByText(container, "Content 2")).toBeInTheDocument();
|
|
26
|
-
|
|
27
|
-
// Clicking header 2 again should hide body 2
|
|
28
|
-
await userEvent.click(getByText(container, "Header 2"));
|
|
29
|
-
expect(queryByText(container, "Content 1")).toBeInTheDocument();
|
|
30
|
-
expect(queryByText(container, "Content 2")).not.toBeInTheDocument();
|
|
31
|
-
});
|
|
32
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { queryByText } from "@testing-library/dom";
|
|
2
|
-
import "@testing-library/jest-dom/vitest";
|
|
3
|
-
import { mount } from "@torpor/view";
|
|
4
|
-
import { describe, expect, it } from "vitest";
|
|
5
|
-
import AccordionMultiple from "./components/AccordionMultiple.torp";
|
|
6
|
-
|
|
7
|
-
describe("Accordion", () => {
|
|
8
|
-
it("Multiple item default value", async () => {
|
|
9
|
-
const container = document.createElement("div");
|
|
10
|
-
document.body.appendChild(container);
|
|
11
|
-
mount(container, AccordionMultiple, { value: "1" });
|
|
12
|
-
|
|
13
|
-
expect(queryByText(container, "Content 1")).not.toBeInTheDocument();
|
|
14
|
-
expect(queryByText(container, "Content 2")).toBeInTheDocument();
|
|
15
|
-
expect(queryByText(container, "Content 3")).not.toBeInTheDocument();
|
|
16
|
-
});
|
|
17
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { getByText, queryByText } from "@testing-library/dom";
|
|
2
|
-
import "@testing-library/jest-dom/vitest";
|
|
3
|
-
import userEvent from "@testing-library/user-event";
|
|
4
|
-
import { mount } from "@torpor/view";
|
|
5
|
-
import { describe, expect, it } from "vitest";
|
|
6
|
-
import AccordionSingle from "./components/AccordionSingle.torp";
|
|
7
|
-
|
|
8
|
-
describe("Accordion", () => {
|
|
9
|
-
it("Single item toggle", async () => {
|
|
10
|
-
const container = document.createElement("div");
|
|
11
|
-
document.body.appendChild(container);
|
|
12
|
-
mount(container, AccordionSingle);
|
|
13
|
-
|
|
14
|
-
expect(queryByText(container, "Content 1")).not.toBeInTheDocument();
|
|
15
|
-
expect(queryByText(container, "Content 2")).not.toBeInTheDocument();
|
|
16
|
-
expect(queryByText(container, "Content 3")).not.toBeInTheDocument();
|
|
17
|
-
|
|
18
|
-
// Clicking header 1 should reveal body 1
|
|
19
|
-
await userEvent.click(getByText(container, "Header 1"));
|
|
20
|
-
expect(queryByText(container, "Content 1")).toBeInTheDocument();
|
|
21
|
-
|
|
22
|
-
// Clicking header 2 should hide body 1 and reveal body 2
|
|
23
|
-
await userEvent.click(getByText(container, "Header 2"));
|
|
24
|
-
expect(queryByText(container, "Content 1")).not.toBeInTheDocument();
|
|
25
|
-
expect(queryByText(container, "Content 2")).toBeInTheDocument();
|
|
26
|
-
|
|
27
|
-
// Clicking header 2 again should hide body 2
|
|
28
|
-
await userEvent.click(getByText(container, "Header 2"));
|
|
29
|
-
expect(queryByText(container, "Content 2")).not.toBeInTheDocument();
|
|
30
|
-
});
|
|
31
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { queryByText } from "@testing-library/dom";
|
|
2
|
-
import "@testing-library/jest-dom/vitest";
|
|
3
|
-
import { mount } from "@torpor/view";
|
|
4
|
-
import { describe, expect, it } from "vitest";
|
|
5
|
-
import AccordionSingle from "./components/AccordionSingle.torp";
|
|
6
|
-
|
|
7
|
-
describe("Accordion", () => {
|
|
8
|
-
it("Single item default value", async () => {
|
|
9
|
-
const container = document.createElement("div");
|
|
10
|
-
document.body.appendChild(container);
|
|
11
|
-
mount(container, AccordionSingle, { value: "1" });
|
|
12
|
-
|
|
13
|
-
expect(queryByText(container, "Content 1")).not.toBeInTheDocument();
|
|
14
|
-
expect(queryByText(container, "Content 2")).toBeInTheDocument();
|
|
15
|
-
expect(queryByText(container, "Content 3")).not.toBeInTheDocument();
|
|
16
|
-
});
|
|
17
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { queryByText } from "@testing-library/dom";
|
|
2
|
-
import "@testing-library/jest-dom/vitest";
|
|
3
|
-
import { mount } from "@torpor/view";
|
|
4
|
-
import { describe, expect, it } from "vitest";
|
|
5
|
-
import BreadcrumbTest from "./components/BreadcrumbTest.torp";
|
|
6
|
-
|
|
7
|
-
describe("Breadcrumb", () => {
|
|
8
|
-
it("Accessibility", async () => {
|
|
9
|
-
const container = document.createElement("div");
|
|
10
|
-
document.body.appendChild(container);
|
|
11
|
-
mount(container, BreadcrumbTest);
|
|
12
|
-
|
|
13
|
-
// Tests from https://www.w3.org/WAI/ARIA/apg/patterns/breadcrumb/
|
|
14
|
-
|
|
15
|
-
// Breadcrumb trail is contained within a navigation landmark region
|
|
16
|
-
expect(
|
|
17
|
-
queryByText(container, "Main page")?.parentElement?.parentElement?.tagName.toLowerCase(),
|
|
18
|
-
).toMatch("nav");
|
|
19
|
-
|
|
20
|
-
// The landmark region is labelled via aria-label or aria-labelledby
|
|
21
|
-
expect(queryByText(container, "Main page")?.parentElement?.parentElement).toHaveAttribute(
|
|
22
|
-
"aria-label",
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
// The link to the current page has aria-current set to page. If the element representing the
|
|
26
|
-
// current page is not a link, aria-current is optional
|
|
27
|
-
expect(queryByText(container, "Current page")).toHaveAttribute("aria-current", "page");
|
|
28
|
-
});
|
|
29
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { queryByText } from "@testing-library/dom";
|
|
2
|
-
import "@testing-library/jest-dom/vitest";
|
|
3
|
-
import { mount } from "@torpor/view";
|
|
4
|
-
import { describe, expect, it } from "vitest";
|
|
5
|
-
import BreadcrumbTest from "./components/BreadcrumbTest.torp";
|
|
6
|
-
|
|
7
|
-
describe("Breadcrumb", () => {
|
|
8
|
-
it("Basic", async () => {
|
|
9
|
-
const container = document.createElement("div");
|
|
10
|
-
document.body.appendChild(container);
|
|
11
|
-
mount(container, BreadcrumbTest);
|
|
12
|
-
|
|
13
|
-
expect(queryByText(container, "Main page")).toBeInTheDocument();
|
|
14
|
-
expect(queryByText(container, "Sub page")).toBeInTheDocument();
|
|
15
|
-
expect(queryByText(container, "Current page")).toBeInTheDocument();
|
|
16
|
-
});
|
|
17
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Breadcrumb, BreadcrumbItem } from "../../../src/Breadcrumb/index";
|
|
2
|
-
|
|
3
|
-
export default function BreadcrumbAccessibility() {
|
|
4
|
-
@render {
|
|
5
|
-
<Breadcrumb ariaLabel="Breadcrumb">
|
|
6
|
-
<BreadcrumbItem>
|
|
7
|
-
<a href={location + "#mainpage"}>Main page</a>
|
|
8
|
-
</BreadcrumbItem>
|
|
9
|
-
<BreadcrumbItem>
|
|
10
|
-
<a href={location + "#subpage"}>Sub page</a>
|
|
11
|
-
</BreadcrumbItem>
|
|
12
|
-
<BreadcrumbItem current>Current page</BreadcrumbItem>
|
|
13
|
-
</Breadcrumb>
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { queryByText } from "@testing-library/dom";
|
|
2
|
-
import "@testing-library/jest-dom/vitest";
|
|
3
|
-
import { mount } from "@torpor/view";
|
|
4
|
-
import { describe, expect, it } from "vitest";
|
|
5
|
-
import CalendarTest from "./components/CalendarTest.torp";
|
|
6
|
-
|
|
7
|
-
describe("Calendar", () => {
|
|
8
|
-
it("Default value", async () => {
|
|
9
|
-
const container = document.createElement("div");
|
|
10
|
-
document.body.appendChild(container);
|
|
11
|
-
mount(container, CalendarTest, { selectable: true, value: new Date(2025, 8, 15) });
|
|
12
|
-
|
|
13
|
-
expect(queryByText(container, "September 2025")).toBeInTheDocument();
|
|
14
|
-
|
|
15
|
-
expect(queryByText(container, "15")).toBeInTheDocument();
|
|
16
|
-
expect(queryByText(container, "15")!.parentElement!.parentElement).toHaveClass("active");
|
|
17
|
-
});
|
|
18
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { queryByText } from "@testing-library/dom";
|
|
2
|
-
import "@testing-library/jest-dom/vitest";
|
|
3
|
-
import { mount } from "@torpor/view";
|
|
4
|
-
import { assert, describe, expect, it } from "vitest";
|
|
5
|
-
import DialogAccessibility from "./components/DialogAccessibility.torp";
|
|
6
|
-
|
|
7
|
-
describe("Dialog", () => {
|
|
8
|
-
it("Accessibility -- alert", async () => {
|
|
9
|
-
const container = document.createElement("div");
|
|
10
|
-
document.body.appendChild(container);
|
|
11
|
-
mount(container, DialogAccessibility, { alert: true });
|
|
12
|
-
|
|
13
|
-
// Tests from https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/
|
|
14
|
-
// This is for a Dialog with its alert property set to true
|
|
15
|
-
|
|
16
|
-
// The element that contains all elements of the dialog, including the
|
|
17
|
-
// alert message and any dialog buttons, has role alertdialog
|
|
18
|
-
let dialog = queryByText(container, "Which color do you prefer?");
|
|
19
|
-
assert(dialog, "Dialog not found");
|
|
20
|
-
assert(dialog.parentElement, "Dialog parent not found");
|
|
21
|
-
dialog = dialog.parentElement;
|
|
22
|
-
expect(dialog).toHaveAttribute("role", "alertdialog");
|
|
23
|
-
|
|
24
|
-
// The element with role alertdialog has either:
|
|
25
|
-
// * A value for aria-labelledby that refers to the element containing
|
|
26
|
-
// the title of the dialog if the dialog has a visible label
|
|
27
|
-
// * A value for aria-label if the dialog does not have a visible
|
|
28
|
-
// label
|
|
29
|
-
const header = queryByText(container, "Color preference");
|
|
30
|
-
assert(header, "Header not found");
|
|
31
|
-
expect(dialog).toHaveAttribute("aria-labelledby", header.id);
|
|
32
|
-
|
|
33
|
-
// The element with role alertdialog has a value set for
|
|
34
|
-
// aria-describedby that refers to the element containing the alert
|
|
35
|
-
// message
|
|
36
|
-
const body = queryByText(container, "Which color do you prefer?");
|
|
37
|
-
assert(body, "Body not found");
|
|
38
|
-
expect(dialog).toHaveAttribute("aria-describedby", body.id);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { queryByText } from "@testing-library/dom";
|
|
2
|
-
import "@testing-library/jest-dom/vitest";
|
|
3
|
-
import { mount } from "@torpor/view";
|
|
4
|
-
import { assert, describe, expect, it } from "vitest";
|
|
5
|
-
import DialogModal from "./components/DialogModal.torp";
|
|
6
|
-
|
|
7
|
-
describe("Dialog", () => {
|
|
8
|
-
it("Accessibility -- modal", async () => {
|
|
9
|
-
const container = document.createElement("div");
|
|
10
|
-
document.body.appendChild(container);
|
|
11
|
-
mount(container, DialogModal, { modal: true, ariaAnnounce: false });
|
|
12
|
-
|
|
13
|
-
// Tests from https://www.w3.org/WAI/ARIA/apg/patterns/dialogmodal/
|
|
14
|
-
// This is for a Dialog in a Popover with its modal property set to true
|
|
15
|
-
|
|
16
|
-
// The element that serves as the dialog container has a role of dialog
|
|
17
|
-
let dialog = queryByText(container, "Which color do you prefer?");
|
|
18
|
-
assert(dialog, "Dialog not found");
|
|
19
|
-
assert(dialog.parentElement, "Dialog parent not found");
|
|
20
|
-
dialog = dialog.parentElement;
|
|
21
|
-
expect(dialog).toHaveAttribute("role", "dialog");
|
|
22
|
-
|
|
23
|
-
// All elements required to operate the dialog are descendants of the
|
|
24
|
-
// element that has role dialog
|
|
25
|
-
|
|
26
|
-
// The dialog container element has aria-modal set to true
|
|
27
|
-
expect(dialog).toHaveAttribute("aria-modal", "true");
|
|
28
|
-
|
|
29
|
-
// The dialog has either:
|
|
30
|
-
// * A value set for the aria-labelledby property that refers to a
|
|
31
|
-
// visible dialog title
|
|
32
|
-
// * A label specified by aria-label
|
|
33
|
-
const header = queryByText(container, "Color preference");
|
|
34
|
-
assert(header, "Header not found");
|
|
35
|
-
expect(dialog).toHaveAttribute("aria-labelledby", header.id);
|
|
36
|
-
|
|
37
|
-
// Optionally, the aria-describedby property is set on the element with
|
|
38
|
-
// the dialog role to indicate which element or elements in the dialog
|
|
39
|
-
// contain content that describes the primary purpose or message of the
|
|
40
|
-
// dialog. Specifying descriptive elements enables screen readers to
|
|
41
|
-
// announce the description along with the dialog title and initially
|
|
42
|
-
// focused element when the dialog opens, which is typically helpful
|
|
43
|
-
// only when the descriptive content is simple and can easily be
|
|
44
|
-
// understood without structural information. It is advisable to omit
|
|
45
|
-
// specifying aria-describedby if the dialog content includes semantic
|
|
46
|
-
// structures, such as lists, tables, or multiple paragraphs, that need
|
|
47
|
-
// to be perceived in order to easily understand the content, i.e., if
|
|
48
|
-
// the content would be difficult to understand when announced as a
|
|
49
|
-
// single unbroken string
|
|
50
|
-
expect(dialog).not.toHaveAttribute("aria-describedby");
|
|
51
|
-
});
|
|
52
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Dialog,
|
|
3
|
-
DialogHeader,
|
|
4
|
-
DialogBody,
|
|
5
|
-
DialogFooter,
|
|
6
|
-
DialogButton
|
|
7
|
-
} from "../../../src/Dialog/index";
|
|
8
|
-
|
|
9
|
-
export default function DialogAccessibility($props: any) {
|
|
10
|
-
$props.alert ??= false;
|
|
11
|
-
$props.ariaAnnounce ??= true;
|
|
12
|
-
|
|
13
|
-
let color = "";
|
|
14
|
-
|
|
15
|
-
@render {
|
|
16
|
-
<Dialog alert={$props.alert}>
|
|
17
|
-
<DialogHeader>Color preference</DialogHeader>
|
|
18
|
-
<DialogBody ariaAnnounce={$props.ariaAnnounce}>Which color do you prefer?</DialogBody>
|
|
19
|
-
<DialogFooter>
|
|
20
|
-
<DialogButton value="blue" onclick={() => (color = "blue")}>Blue</DialogButton>
|
|
21
|
-
<DialogButton value="red" onclick={() => (color = "red")}>Red</DialogButton>
|
|
22
|
-
</DialogFooter>
|
|
23
|
-
</Dialog>
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Modal, ModalContent, showPrompt } from "../../../src/Modal/index";
|
|
2
|
-
import { Dialog, DialogBody, DialogFooter, DialogButton } from "../../../src/Dialog/index";
|
|
3
|
-
|
|
4
|
-
export default function DialogFunction($props: any) {
|
|
5
|
-
let $state = $watch({ color: "" });
|
|
6
|
-
|
|
7
|
-
async function show() {
|
|
8
|
-
$state.color = await showPrompt(CustomDialog, null, $parent);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
@render {
|
|
12
|
-
<button type="button" onclick={show}>Show the modal</button>
|
|
13
|
-
|
|
14
|
-
@if ($state.color) {
|
|
15
|
-
<p>Your favorite color is {$state.color}?!</p>
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function CustomDialog($props: any) {
|
|
21
|
-
@render {
|
|
22
|
-
<Modal visible callback={$props.callback}>
|
|
23
|
-
<ModalContent>
|
|
24
|
-
<Dialog>
|
|
25
|
-
<DialogBody>
|
|
26
|
-
<p>Which color do you prefer?</p>
|
|
27
|
-
</DialogBody>
|
|
28
|
-
<DialogFooter>
|
|
29
|
-
<DialogButton value="blue">Blue</DialogButton>
|
|
30
|
-
<DialogButton value="red">Red</DialogButton>
|
|
31
|
-
</DialogFooter>
|
|
32
|
-
</Dialog>
|
|
33
|
-
</ModalContent>
|
|
34
|
-
</Modal>
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Modal, ModalContent } from "../../../src/Modal/index";
|
|
2
|
-
import {
|
|
3
|
-
Dialog,
|
|
4
|
-
DialogHeader,
|
|
5
|
-
DialogBody,
|
|
6
|
-
DialogFooter,
|
|
7
|
-
DialogButton
|
|
8
|
-
} from "../../../src/Dialog/index";
|
|
9
|
-
|
|
10
|
-
export default function DialogModal($props: any) {
|
|
11
|
-
$props.alert ??= false;
|
|
12
|
-
$props.ariaAnnounce ??= true;
|
|
13
|
-
|
|
14
|
-
let color = "";
|
|
15
|
-
|
|
16
|
-
@render {
|
|
17
|
-
<Modal visible>
|
|
18
|
-
<ModalContent>
|
|
19
|
-
<Dialog alert={$props.alert}>
|
|
20
|
-
<DialogHeader>Color preference</DialogHeader>
|
|
21
|
-
<DialogBody ariaAnnounce={$props.ariaAnnounce}>Which color do you prefer?</DialogBody>
|
|
22
|
-
<DialogFooter>
|
|
23
|
-
<DialogButton value="blue" onclick={() => (color = "blue")}>Blue</DialogButton>
|
|
24
|
-
<DialogButton value="red" onclick={() => (color = "red")}>Red</DialogButton>
|
|
25
|
-
</DialogFooter>
|
|
26
|
-
</Dialog>
|
|
27
|
-
</ModalContent>
|
|
28
|
-
</Modal>
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Modal, ModalContent } from "../../../src/Modal/index";
|
|
2
|
-
import { Dialog, DialogBody, DialogFooter, DialogButton } from "../../../src/Dialog/index";
|
|
3
|
-
|
|
4
|
-
export default function DialogVariable($props: any) {
|
|
5
|
-
let $state = $watch({
|
|
6
|
-
color: "",
|
|
7
|
-
showModal: false
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
@render {
|
|
11
|
-
<button type="button" onclick={(e) => ($state.showModal = !$state.showModal)}>
|
|
12
|
-
Show the modal
|
|
13
|
-
</button>
|
|
14
|
-
|
|
15
|
-
@if ($state.color) {
|
|
16
|
-
<p>Your favorite color is {$state.color}?!</p>
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
<Modal &visible={$state.showModal}>
|
|
20
|
-
<ModalContent>
|
|
21
|
-
<Dialog>
|
|
22
|
-
<DialogBody>
|
|
23
|
-
<p>Which color do you prefer?</p>
|
|
24
|
-
</DialogBody>
|
|
25
|
-
<DialogFooter>
|
|
26
|
-
<DialogButton value="blue" onclick={() => ($state.color = "blue")}>Blue</DialogButton>
|
|
27
|
-
<DialogButton value="red" onclick={() => ($state.color = "red")}>Red</DialogButton>
|
|
28
|
-
</DialogFooter>
|
|
29
|
-
</Dialog>
|
|
30
|
-
</ModalContent>
|
|
31
|
-
</Modal>
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { getByText, queryByText } from "@testing-library/dom";
|
|
2
|
-
import "@testing-library/jest-dom/vitest";
|
|
3
|
-
import userEvent from "@testing-library/user-event";
|
|
4
|
-
import { mount } from "@torpor/view";
|
|
5
|
-
import { describe, expect, it } from "vitest";
|
|
6
|
-
import DialogFunction from "./components/DialogFunction.torp";
|
|
7
|
-
|
|
8
|
-
describe("Dialog", () => {
|
|
9
|
-
it("Showing with a function", async () => {
|
|
10
|
-
const container = document.createElement("div");
|
|
11
|
-
document.body.appendChild(container);
|
|
12
|
-
mount(container, DialogFunction);
|
|
13
|
-
|
|
14
|
-
// By default, the modal shouldn't be shown
|
|
15
|
-
expect(queryByText(container, "Which color do you prefer?")).not.toBeInTheDocument();
|
|
16
|
-
|
|
17
|
-
// Clicking the button should show the modal
|
|
18
|
-
await userEvent.click(getByText(container, "Show the modal"));
|
|
19
|
-
expect(queryByText(container, "Which color do you prefer?")).toBeInTheDocument();
|
|
20
|
-
|
|
21
|
-
// Clicking the blue button should hide the modal and set the value
|
|
22
|
-
await userEvent.click(getByText(container, "Blue"));
|
|
23
|
-
expect(queryByText(container, "Which color do you prefer?")).not.toBeInTheDocument();
|
|
24
|
-
expect(queryByText(container, "Your favorite color is blue?!")).toBeInTheDocument();
|
|
25
|
-
});
|
|
26
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { getByText, queryByText } from "@testing-library/dom";
|
|
2
|
-
import "@testing-library/jest-dom/vitest";
|
|
3
|
-
import userEvent from "@testing-library/user-event";
|
|
4
|
-
import { mount } from "@torpor/view";
|
|
5
|
-
import { describe, expect, it } from "vitest";
|
|
6
|
-
import DialogVariable from "./components/DialogVariable.torp";
|
|
7
|
-
|
|
8
|
-
describe("Dialog", () => {
|
|
9
|
-
it("Showing with a variable", async () => {
|
|
10
|
-
const container = document.createElement("div");
|
|
11
|
-
document.body.appendChild(container);
|
|
12
|
-
mount(container, DialogVariable);
|
|
13
|
-
|
|
14
|
-
// By default, the modal shouldn't be shown
|
|
15
|
-
expect(queryByText(container, "Which color do you prefer?")).not.toBeInTheDocument();
|
|
16
|
-
expect(queryByText(container, "Your favorite color is blue?!")).not.toBeInTheDocument();
|
|
17
|
-
|
|
18
|
-
// Clicking the button should show the modal
|
|
19
|
-
await userEvent.click(getByText(container, "Show the modal"));
|
|
20
|
-
expect(queryByText(container, "Which color do you prefer?")).toBeInTheDocument();
|
|
21
|
-
|
|
22
|
-
// Clicking the blue button should hide the modal and set the value
|
|
23
|
-
await userEvent.click(getByText(container, "Blue"));
|
|
24
|
-
expect(queryByText(container, "Which color do you prefer?")).not.toBeInTheDocument();
|
|
25
|
-
expect(queryByText(container, "Your favorite color is blue?!")).toBeInTheDocument();
|
|
26
|
-
});
|
|
27
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { getByText, queryByText } from "@testing-library/dom";
|
|
2
|
-
import "@testing-library/jest-dom/vitest";
|
|
3
|
-
import userEvent from "@testing-library/user-event";
|
|
4
|
-
import { mount } from "@torpor/view";
|
|
5
|
-
import { describe, expect, it } from "vitest";
|
|
6
|
-
import DisclosureTest from "./components/DisclosureTest.torp";
|
|
7
|
-
|
|
8
|
-
describe("Disclosure", () => {
|
|
9
|
-
it("Accessibility", async () => {
|
|
10
|
-
const container = document.createElement("div");
|
|
11
|
-
document.body.appendChild(container);
|
|
12
|
-
mount(container, DisclosureTest);
|
|
13
|
-
|
|
14
|
-
// Tests from https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/
|
|
15
|
-
|
|
16
|
-
// The element that shows and hides the content has role button
|
|
17
|
-
expect(queryByText(container, "Disclosure header")?.tagName.toLowerCase()).toMatch("button");
|
|
18
|
-
|
|
19
|
-
// When the content is hidden, the element with role button has aria-expanded set to false
|
|
20
|
-
expect(queryByText(container, "Disclosure header")).toHaveAttribute("aria-expanded", "false");
|
|
21
|
-
|
|
22
|
-
// When the content area is visible, it is set to true
|
|
23
|
-
await userEvent.click(getByText(container, "Disclosure header"));
|
|
24
|
-
expect(queryByText(container, "Disclosure header")).toHaveAttribute("aria-expanded", "true");
|
|
25
|
-
|
|
26
|
-
// Optionally, the element with role button has a value specified for aria-controls that refers
|
|
27
|
-
// to the element that contains all the content that is shown or hidden
|
|
28
|
-
const contentId = queryByText(container, "Disclosure content")?.id;
|
|
29
|
-
expect(queryByText(container, "Disclosure header")).toHaveAttribute("aria-controls", contentId);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Disclosure,
|
|
3
|
-
DisclosureHeader,
|
|
4
|
-
DisclosureTrigger,
|
|
5
|
-
DisclosureContent
|
|
6
|
-
} from "../../../src/Disclosure/index";
|
|
7
|
-
|
|
8
|
-
export default function DisclosureAccessibility($props: { expanded: boolean }) {
|
|
9
|
-
@render {
|
|
10
|
-
<Disclosure {$props?.expanded}>
|
|
11
|
-
<DisclosureHeader as="h4">
|
|
12
|
-
<DisclosureTrigger>Disclosure header</DisclosureTrigger>
|
|
13
|
-
</DisclosureHeader>
|
|
14
|
-
<DisclosureContent>Disclosure content</DisclosureContent>
|
|
15
|
-
</Disclosure>
|
|
16
|
-
}
|
|
17
|
-
}
|