@patternfly/react-core 4.266.0 → 4.266.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/CHANGELOG.md +19 -0
- package/dist/esm/components/Pagination/Pagination.d.ts +12 -2
- package/dist/esm/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/esm/components/Pagination/Pagination.js +3 -2
- package/dist/esm/components/Pagination/Pagination.js.map +1 -1
- package/dist/esm/components/Sidebar/SidebarPanel.d.ts +9 -0
- package/dist/esm/components/Sidebar/SidebarPanel.d.ts.map +1 -1
- package/dist/esm/components/Sidebar/SidebarPanel.js +10 -0
- package/dist/esm/components/Sidebar/SidebarPanel.js.map +1 -1
- package/dist/js/components/Pagination/Pagination.d.ts +12 -2
- package/dist/js/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/js/components/Pagination/Pagination.js +3 -2
- package/dist/js/components/Pagination/Pagination.js.map +1 -1
- package/dist/js/components/Sidebar/SidebarPanel.d.ts +9 -0
- package/dist/js/components/Sidebar/SidebarPanel.d.ts.map +1 -1
- package/dist/js/components/Sidebar/SidebarPanel.js +11 -1
- package/dist/js/components/Sidebar/SidebarPanel.js.map +1 -1
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +2 -2
- package/src/components/Pagination/Pagination.tsx +17 -2
- package/src/components/Pagination/__tests__/Pagination.test.tsx +21 -0
- package/src/components/Pagination/__tests__/__snapshots__/Pagination.test.tsx.snap +1266 -0
- package/src/components/Pagination/examples/Pagination.md +5 -0
- package/src/components/Pagination/examples/PaginationInset.tsx +37 -0
- package/src/components/Pagination/examples/PaginationSticky.tsx +47 -55
- package/src/components/Panel/__tests__/Panel.test.tsx +96 -58
- package/src/components/Panel/__tests__/PanelFooter.test.tsx +42 -0
- package/src/components/Panel/__tests__/PanelHeader.test.tsx +42 -0
- package/src/components/Panel/__tests__/PanelMain.test.tsx +48 -0
- package/src/components/Panel/__tests__/PanelMainBody.test.tsx +42 -0
- package/src/components/Panel/__tests__/__snapshots__/Panel.test.tsx.snap +2 -82
- package/src/components/Panel/__tests__/__snapshots__/PanelFooter.test.tsx.snap +11 -0
- package/src/components/Panel/__tests__/__snapshots__/PanelHeader.test.tsx.snap +11 -0
- package/src/components/Panel/__tests__/__snapshots__/PanelMain.test.tsx.snap +11 -0
- package/src/components/Panel/__tests__/__snapshots__/PanelMainBody.test.tsx.snap +11 -0
- package/src/components/Sidebar/SidebarPanel.tsx +10 -0
- package/src/components/Sidebar/__tests__/Sidebar.test.tsx +72 -0
- package/src/components/Sidebar/__tests__/SidebarContent.test.tsx +38 -0
- package/src/components/Sidebar/__tests__/SidebarPanel.test.tsx +75 -0
- package/src/components/Sidebar/__tests__/__snapshots__/Sidebar.test.tsx.snap +15 -0
- package/src/components/Sidebar/__tests__/__snapshots__/SidebarContent.test.tsx.snap +11 -0
- package/src/components/Sidebar/__tests__/__snapshots__/SidebarPanel.test.tsx.snap +11 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { Sidebar } from '../Sidebar';
|
|
4
|
+
|
|
5
|
+
test('Renders without children', () => {
|
|
6
|
+
render(
|
|
7
|
+
<div data-testid="sidebar">
|
|
8
|
+
<Sidebar />
|
|
9
|
+
</div>
|
|
10
|
+
);
|
|
11
|
+
expect(screen.getByTestId('sidebar').firstChild).toBeVisible();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('Renders children', () => {
|
|
15
|
+
render(<Sidebar>Test</Sidebar>);
|
|
16
|
+
expect(screen.getByText('Test')).toBeVisible();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('Renders with only class name pf-c-sidebar by default', () => {
|
|
20
|
+
render(<Sidebar>Test</Sidebar>);
|
|
21
|
+
expect(screen.getByText('Test').parentElement).toHaveClass('pf-c-sidebar', { exact: true });
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('Renders with class name pf-c-sidebar', () => {
|
|
25
|
+
render(<Sidebar>Test</Sidebar>);
|
|
26
|
+
expect(screen.getByText('Test').parentElement).toHaveClass('pf-c-sidebar');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('Renders with custom class name when className prop is provided', () => {
|
|
30
|
+
render(<Sidebar className="custom-class">Test</Sidebar>);
|
|
31
|
+
expect(screen.getByText('Test').parentElement).toHaveClass('custom-class');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('Renders with class name pf-m-no-background when hasNoBackground prop is passed', () => {
|
|
35
|
+
render(<Sidebar hasNoBackground>Test</Sidebar>);
|
|
36
|
+
expect(screen.getByText('Test').parentElement).toHaveClass('pf-m-no-background');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('Renders with class name pf-m-stack when "stack" is passed to orientation prop', () => {
|
|
40
|
+
render(<Sidebar orientation="stack">Test</Sidebar>);
|
|
41
|
+
expect(screen.getByText('Test').parentElement).toHaveClass('pf-m-stack');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('Renders with class name pf-m-split when "split" is passed to orientation prop', () => {
|
|
45
|
+
render(<Sidebar orientation="split">Test</Sidebar>);
|
|
46
|
+
expect(screen.getByText('Test').parentElement).toHaveClass('pf-m-split');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('Renders with class name pf-m-panel-right when isPanelRight prop is passed', () => {
|
|
50
|
+
render(<Sidebar isPanelRight>Test</Sidebar>);
|
|
51
|
+
expect(screen.getByText('Test').parentElement).toHaveClass('pf-m-panel-right');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('Renders with class name pf-m-gutter when hasGutter prop is passed', () => {
|
|
55
|
+
render(<Sidebar hasGutter>Test</Sidebar>);
|
|
56
|
+
expect(screen.getByText('Test').parentElement).toHaveClass('pf-m-gutter');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('Renders with class name pf-m-sidebar__main by default for child component', () => {
|
|
60
|
+
render(<Sidebar>Test</Sidebar>);
|
|
61
|
+
expect(screen.getByText('Test')).toHaveClass('pf-c-sidebar__main');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('Renders with inherited element props spread to the component', () => {
|
|
65
|
+
render(<Sidebar aria-label="Test label">Test</Sidebar>);
|
|
66
|
+
expect(screen.getByText('Test').parentElement).toHaveAccessibleName('Test label');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('Matches the snapshot', () => {
|
|
70
|
+
const { asFragment } = render(<Sidebar>Test</Sidebar>);
|
|
71
|
+
expect(asFragment()).toMatchSnapshot();
|
|
72
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { SidebarContent } from '../SidebarContent';
|
|
4
|
+
|
|
5
|
+
test('Renders children', () => {
|
|
6
|
+
render(<SidebarContent>Test</SidebarContent>);
|
|
7
|
+
expect(screen.getByText('Test')).toBeVisible();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test('Renders with only class name pf-c-sidebar__content by default', () => {
|
|
11
|
+
render(<SidebarContent>Test</SidebarContent>);
|
|
12
|
+
expect(screen.getByText('Test')).toHaveClass('pf-c-sidebar__content', { exact: true });
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('Renders with class name pf-c-sidebar__content', () => {
|
|
16
|
+
render(<SidebarContent>Test</SidebarContent>);
|
|
17
|
+
expect(screen.getByText('Test')).toHaveClass('pf-c-sidebar__content');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('Renders with custom class name when className prop is provided', () => {
|
|
21
|
+
render(<SidebarContent className="custom-class">Test</SidebarContent>);
|
|
22
|
+
expect(screen.getByText('Test')).toHaveClass('custom-class');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('Renders with class name pf-m-no-background when hasNoBackground prop is passed', () => {
|
|
26
|
+
render(<SidebarContent hasNoBackground>Test</SidebarContent>);
|
|
27
|
+
expect(screen.getByText('Test')).toHaveClass('pf-m-no-background');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('Renders with inherited element props spread to the component', () => {
|
|
31
|
+
render(<SidebarContent aria-label="Test label">Test</SidebarContent>);
|
|
32
|
+
expect(screen.getByText('Test')).toHaveAccessibleName('Test label');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('Matches the snapshot', () => {
|
|
36
|
+
const { asFragment } = render(<SidebarContent>Test</SidebarContent>);
|
|
37
|
+
expect(asFragment()).toMatchSnapshot();
|
|
38
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { SidebarPanel, SidebarPanelWidthType } from '../SidebarPanel';
|
|
4
|
+
|
|
5
|
+
test('Renders children', () => {
|
|
6
|
+
render(<SidebarPanel>Test</SidebarPanel>);
|
|
7
|
+
expect(screen.getByText('Test')).toBeVisible();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test('Renders with with only class name pf-c-sidebar__panel by default', () => {
|
|
11
|
+
render(<SidebarPanel>Test</SidebarPanel>);
|
|
12
|
+
expect(screen.getByText('Test')).toHaveClass('pf-c-sidebar__panel', { exact: true });
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('Renders with with class name pf-c-sidebar__panel', () => {
|
|
16
|
+
render(<SidebarPanel>Test</SidebarPanel>);
|
|
17
|
+
expect(screen.getByText('Test')).toHaveClass('pf-c-sidebar__panel');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('Renders with custom class name when className prop is provided', () => {
|
|
21
|
+
render(<SidebarPanel className="custom-class">Test</SidebarPanel>);
|
|
22
|
+
expect(screen.getByText('Test')).toHaveClass('custom-class');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('Renders with class name pf-m-sticky when "sticky" is passed to variant prop', () => {
|
|
26
|
+
render(<SidebarPanel variant="sticky">Test</SidebarPanel>);
|
|
27
|
+
expect(screen.getByText('Test')).toHaveClass('pf-m-sticky');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('Renders with class name pf-m-static when "static" is passed to variant prop', () => {
|
|
31
|
+
render(<SidebarPanel variant="static">Test</SidebarPanel>);
|
|
32
|
+
expect(screen.getByText('Test')).toHaveClass('pf-m-static');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('Renders with class name pf-m-no-background when hasNoBackground prop is passed', () => {
|
|
36
|
+
render(<SidebarPanel hasNoBackground>Test</SidebarPanel>);
|
|
37
|
+
expect(screen.getByText('Test')).toHaveClass('pf-m-no-background');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
['width_25', 'width_33', 'width_50', 'width_66', 'width_75', 'width_100'].forEach(widthType => {
|
|
41
|
+
test(`Renders with appropriate class names when ${widthType} is passed to each breakpoint of width prop`, () => {
|
|
42
|
+
render(
|
|
43
|
+
<SidebarPanel
|
|
44
|
+
width={{
|
|
45
|
+
default: `${widthType as SidebarPanelWidthType}`,
|
|
46
|
+
sm: `${widthType as SidebarPanelWidthType}`,
|
|
47
|
+
md: `${widthType as SidebarPanelWidthType}`,
|
|
48
|
+
lg: `${widthType as SidebarPanelWidthType}`,
|
|
49
|
+
xl: `${widthType as SidebarPanelWidthType}`,
|
|
50
|
+
'2xl': `${widthType as SidebarPanelWidthType}`
|
|
51
|
+
}}
|
|
52
|
+
>
|
|
53
|
+
Test
|
|
54
|
+
</SidebarPanel>
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const className = widthType.replace('_', '-');
|
|
58
|
+
expect(screen.getByText('Test')).toHaveClass(`pf-m-${className}`);
|
|
59
|
+
expect(screen.getByText('Test')).toHaveClass(`pf-m-${className}-on-sm`);
|
|
60
|
+
expect(screen.getByText('Test')).toHaveClass(`pf-m-${className}-on-md`);
|
|
61
|
+
expect(screen.getByText('Test')).toHaveClass(`pf-m-${className}-on-lg`);
|
|
62
|
+
expect(screen.getByText('Test')).toHaveClass(`pf-m-${className}-on-xl`);
|
|
63
|
+
expect(screen.getByText('Test')).toHaveClass(`pf-m-${className}-on-2xl`);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('Renders with inherited element props spread to the component', () => {
|
|
68
|
+
render(<SidebarPanel aria-label="Test label">Test</SidebarPanel>);
|
|
69
|
+
expect(screen.getByText('Test')).toHaveAccessibleName('Test label');
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test('Matches the snapshot', () => {
|
|
73
|
+
const { asFragment } = render(<SidebarPanel>Test</SidebarPanel>);
|
|
74
|
+
expect(asFragment()).toMatchSnapshot();
|
|
75
|
+
});
|