paris 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/package.json +17 -2
- package/src/stories/accordion/Accordion.test.tsx +140 -0
- package/src/stories/accordionselect/AccordionSelect.test.tsx +252 -0
- package/src/stories/avatar/Avatar.test.tsx +77 -0
- package/src/stories/button/Button.test.tsx +266 -0
- package/src/stories/callout/Callout.test.tsx +79 -0
- package/src/stories/card/Card.test.tsx +81 -0
- package/src/stories/cardbutton/CardButton.test.tsx +174 -0
- package/src/stories/checkbox/Checkbox.test.tsx +531 -0
- package/src/stories/combobox/Combobox.test.tsx +164 -0
- package/src/stories/dialog/Dialog.module.scss +2 -2
- package/src/stories/dialog/Dialog.test.tsx +244 -0
- package/src/stories/drawer/Drawer.module.scss +2 -2
- package/src/stories/drawer/Drawer.test.tsx +259 -0
- package/src/stories/field/Field.test.tsx +146 -0
- package/src/stories/icon/Icon.test.tsx +59 -0
- package/src/stories/informationaltooltip/InformationalTooltip.test.tsx +178 -0
- package/src/stories/input/Input.test.tsx +174 -0
- package/src/stories/markdown/Markdown.test.tsx +228 -0
- package/src/stories/markdowneditor/FixedToolbar.tsx +44 -14
- package/src/stories/markdowneditor/LinkPopover.module.scss +1 -1
- package/src/stories/markdowneditor/MarkdownEditor.stories.tsx +4 -1
- package/src/stories/markdowneditor/MarkdownEditor.test.tsx +115 -0
- package/src/stories/markdowneditor/MarkdownEditor.tsx +11 -1
- package/src/stories/markdowneditor/MarkdownEditorContext.tsx +3 -0
- package/src/stories/markdowneditor/index.ts +1 -0
- package/src/stories/menu/Menu.module.scss +1 -1
- package/src/stories/menu/Menu.test.tsx +211 -0
- package/src/stories/pagination/usePagination.test.ts +259 -0
- package/src/stories/popover/Popover.test.tsx +152 -0
- package/src/stories/select/Select.module.scss +2 -1
- package/src/stories/select/Select.test.tsx +233 -0
- package/src/stories/styledlink/StyledLink.test.tsx +59 -0
- package/src/stories/table/Table.test.tsx +156 -0
- package/src/stories/tabs/Tabs.module.scss +1 -1
- package/src/stories/tabs/Tabs.test.tsx +167 -0
- package/src/stories/tag/Tag.test.tsx +90 -0
- package/src/stories/text/Text.test.tsx +81 -0
- package/src/stories/textarea/TextArea.test.tsx +147 -0
- package/src/stories/theme/themes.ts +16 -0
- package/src/stories/tilt/Tilt.test.tsx +203 -0
- package/src/stories/toast/Toast.test.tsx +86 -0
- package/src/stories/utility/Dropdown.module.scss +1 -1
- package/src/stories/utility/Utility.test.tsx +96 -0
- package/src/test/render.tsx +20 -0
- package/src/test/setup.ts +32 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { render, screen } from '../../test/render';
|
|
2
|
+
import { RemoveFromDOM } from './RemoveFromDOM';
|
|
3
|
+
import { TextWhenString } from './TextWhenString';
|
|
4
|
+
import { VisuallyHidden } from './VisuallyHidden';
|
|
5
|
+
|
|
6
|
+
describe('RemoveFromDOM', () => {
|
|
7
|
+
it('renders children when `when` is false', () => {
|
|
8
|
+
render(
|
|
9
|
+
<RemoveFromDOM when={false}>
|
|
10
|
+
<span>visible child</span>
|
|
11
|
+
</RemoveFromDOM>,
|
|
12
|
+
);
|
|
13
|
+
expect(screen.getByText('visible child')).toBeInTheDocument();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('removes children from the DOM when `when` is true', () => {
|
|
17
|
+
render(
|
|
18
|
+
<RemoveFromDOM when={true}>
|
|
19
|
+
<span>hidden child</span>
|
|
20
|
+
</RemoveFromDOM>,
|
|
21
|
+
);
|
|
22
|
+
expect(screen.queryByText('hidden child')).not.toBeInTheDocument();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('toggles visibility when `when` prop changes', () => {
|
|
26
|
+
const { rerender } = render(
|
|
27
|
+
<RemoveFromDOM when={false}>
|
|
28
|
+
<span>toggle me</span>
|
|
29
|
+
</RemoveFromDOM>,
|
|
30
|
+
);
|
|
31
|
+
expect(screen.getByText('toggle me')).toBeInTheDocument();
|
|
32
|
+
|
|
33
|
+
rerender(
|
|
34
|
+
<RemoveFromDOM when={true}>
|
|
35
|
+
<span>toggle me</span>
|
|
36
|
+
</RemoveFromDOM>,
|
|
37
|
+
);
|
|
38
|
+
expect(screen.queryByText('toggle me')).not.toBeInTheDocument();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe('TextWhenString', () => {
|
|
43
|
+
it('wraps string children in a Text component', () => {
|
|
44
|
+
render(<TextWhenString as="span">hello world</TextWhenString>);
|
|
45
|
+
const el = screen.getByText('hello world');
|
|
46
|
+
expect(el).toBeInTheDocument();
|
|
47
|
+
expect(el.tagName).toBe('SPAN');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('wraps numeric children in a Text component', () => {
|
|
51
|
+
render(<TextWhenString as="span">{42}</TextWhenString>);
|
|
52
|
+
expect(screen.getByText('42')).toBeInTheDocument();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('passes ReactNode children through without wrapping', () => {
|
|
56
|
+
render(
|
|
57
|
+
<TextWhenString as="span">
|
|
58
|
+
<div data-testid="passthrough">node child</div>
|
|
59
|
+
</TextWhenString>,
|
|
60
|
+
);
|
|
61
|
+
const el = screen.getByTestId('passthrough');
|
|
62
|
+
expect(el).toBeInTheDocument();
|
|
63
|
+
expect(el.tagName).toBe('DIV');
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe('VisuallyHidden', () => {
|
|
68
|
+
it('visually hides children when `when` is true (default)', () => {
|
|
69
|
+
render(
|
|
70
|
+
<VisuallyHidden>
|
|
71
|
+
<span>hidden text</span>
|
|
72
|
+
</VisuallyHidden>,
|
|
73
|
+
);
|
|
74
|
+
expect(screen.getByText('hidden text')).toBeInTheDocument();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('renders children normally when `when` is false', () => {
|
|
78
|
+
render(
|
|
79
|
+
<VisuallyHidden when={false}>
|
|
80
|
+
<span data-testid="normal">visible text</span>
|
|
81
|
+
</VisuallyHidden>,
|
|
82
|
+
);
|
|
83
|
+
const el = screen.getByTestId('normal');
|
|
84
|
+
expect(el).toBeInTheDocument();
|
|
85
|
+
expect(el.tagName).toBe('SPAN');
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('visually hides children when `when` is explicitly true', () => {
|
|
89
|
+
render(
|
|
90
|
+
<VisuallyHidden when={true}>
|
|
91
|
+
<span>explicitly hidden</span>
|
|
92
|
+
</VisuallyHidden>,
|
|
93
|
+
);
|
|
94
|
+
expect(screen.getByText('explicitly hidden')).toBeInTheDocument();
|
|
95
|
+
});
|
|
96
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type RenderOptions, render as rtlRender } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import type { ReactElement } from 'react';
|
|
4
|
+
|
|
5
|
+
export function render(ui: ReactElement, options?: RenderOptions) {
|
|
6
|
+
return {
|
|
7
|
+
user: userEvent.setup(),
|
|
8
|
+
...rtlRender(ui, options),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { act, screen, waitFor, within } from '@testing-library/react';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Queries the close button rendered by the Paris Button component with shape="circle".
|
|
16
|
+
* Circle-shaped buttons render children as `aria-details` instead of visible text.
|
|
17
|
+
*/
|
|
18
|
+
export function getCloseButton() {
|
|
19
|
+
return document.querySelector('[aria-details="Close dialog"]');
|
|
20
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import '@testing-library/jest-dom/vitest';
|
|
2
|
+
|
|
3
|
+
// Mock ResizeObserver (used by Tilt component)
|
|
4
|
+
class ResizeObserverMock {
|
|
5
|
+
observe() {}
|
|
6
|
+
unobserve() {}
|
|
7
|
+
disconnect() {}
|
|
8
|
+
}
|
|
9
|
+
globalThis.ResizeObserver = ResizeObserverMock as any;
|
|
10
|
+
|
|
11
|
+
// Mock matchMedia (used by @headlessui/react)
|
|
12
|
+
Object.defineProperty(window, 'matchMedia', {
|
|
13
|
+
writable: true,
|
|
14
|
+
value: vi.fn().mockImplementation((query: string) => ({
|
|
15
|
+
matches: false,
|
|
16
|
+
media: query,
|
|
17
|
+
onchange: null,
|
|
18
|
+
addListener: vi.fn(),
|
|
19
|
+
removeListener: vi.fn(),
|
|
20
|
+
addEventListener: vi.fn(),
|
|
21
|
+
removeEventListener: vi.fn(),
|
|
22
|
+
dispatchEvent: vi.fn(),
|
|
23
|
+
})),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Mock IntersectionObserver
|
|
27
|
+
class IntersectionObserverMock {
|
|
28
|
+
observe() {}
|
|
29
|
+
unobserve() {}
|
|
30
|
+
disconnect() {}
|
|
31
|
+
}
|
|
32
|
+
globalThis.IntersectionObserver = IntersectionObserverMock as any;
|