@patternfly/react-core 4.266.0 → 4.266.1
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 +8 -0
- 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/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/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,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
|
+
});
|