@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.266.
|
|
3
|
+
"version": "4.266.1",
|
|
4
4
|
"description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"react": "^16.8 || ^17 || ^18",
|
|
78
78
|
"react-dom": "^16.8 || ^17 || ^18"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "e8e88bf93618d03c99fd94996f0e7db9de6400cd"
|
|
81
81
|
}
|
|
@@ -1,62 +1,100 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
3
|
import { Panel } from '../Panel';
|
|
4
4
|
import { PanelMain } from '../PanelMain';
|
|
5
5
|
import { PanelMainBody } from '../PanelMainBody';
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
6
|
+
import userEvent from '@testing-library/user-event';
|
|
7
|
+
import { useEffect } from 'react';
|
|
8
|
+
|
|
9
|
+
test('Renders without children', () => {
|
|
10
|
+
render(
|
|
11
|
+
<div data-testid="panel">
|
|
12
|
+
<Panel />
|
|
13
|
+
</div>
|
|
14
|
+
);
|
|
15
|
+
expect(screen.getByTestId('panel').firstChild).toBeVisible();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('Renders children', () => {
|
|
19
|
+
render(<Panel>Test</Panel>);
|
|
20
|
+
expect(screen.getByText('Test')).toBeVisible();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('Renders with the class pf-c-panel', () => {
|
|
24
|
+
render(<Panel>Test</Panel>);
|
|
25
|
+
expect(screen.getByText('Test')).toHaveClass('pf-c-panel');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('Renders with only the class pf-c-panel by default', () => {
|
|
29
|
+
render(<Panel>Test</Panel>);
|
|
30
|
+
expect(screen.getByText('Test')).toHaveClass('pf-c-panel', { exact: true });
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('Renders with custom class name when className prop is passed', () => {
|
|
34
|
+
render(<Panel className="test-class">Test</Panel>);
|
|
35
|
+
expect(screen.getByText('Test')).toHaveClass('test-class');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('Renders with class name pf-m-raised when variant is raised', () => {
|
|
39
|
+
render(<Panel variant="raised">Test</Panel>);
|
|
40
|
+
expect(screen.getByText('Test')).toHaveClass('pf-m-raised');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('Renders with class name pf-m-bordered when variant is bordered', () => {
|
|
44
|
+
render(<Panel variant="bordered">Test</Panel>);
|
|
45
|
+
expect(screen.getByText('Test')).toHaveClass('pf-m-bordered');
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('Renders with class name pf-m-scrollable when isScrollable is true', () => {
|
|
49
|
+
render(<Panel isScrollable>Test</Panel>);
|
|
50
|
+
expect(screen.getByText('Test')).toHaveClass('pf-m-scrollable');
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('Renders with ref', async () => {
|
|
54
|
+
const user = userEvent.setup();
|
|
55
|
+
const panelRef: React.RefObject<HTMLDivElement> = React.createRef();
|
|
56
|
+
|
|
57
|
+
const BasicPanel = () => {
|
|
58
|
+
const [lastClickWasInPanel, setLastClickWasInPanel] = React.useState(false);
|
|
59
|
+
|
|
60
|
+
const handleClick = event => {
|
|
61
|
+
if (panelRef.current && panelRef.current.contains(event.target)) {
|
|
62
|
+
setLastClickWasInPanel(true);
|
|
63
|
+
} else {
|
|
64
|
+
setLastClickWasInPanel(false);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
document.addEventListener('click', handleClick);
|
|
70
|
+
}, []);
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<div>
|
|
74
|
+
<Panel ref={panelRef}>
|
|
75
|
+
<PanelMain>
|
|
76
|
+
<PanelMainBody>Main content</PanelMainBody>
|
|
77
|
+
</PanelMain>
|
|
78
|
+
</Panel>
|
|
79
|
+
<p>Last click was in panel: {lastClickWasInPanel ? 'true' : 'false'}</p>
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
render(<BasicPanel />);
|
|
85
|
+
|
|
86
|
+
await user.click(document.body);
|
|
87
|
+
expect(screen.getByText('Last click was in panel: false')).toBeVisible;
|
|
88
|
+
await user.click(screen.getByText('Main content'));
|
|
89
|
+
expect(screen.getByText('Last click was in panel: true')).toBeVisible;
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('Renders with the inherited element props spread to the component', () => {
|
|
93
|
+
render(<Panel aria-label="this is a simple panel">Test</Panel>);
|
|
94
|
+
expect(screen.getByText('Test')).toHaveAccessibleName('this is a simple panel');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('Matches the snapshot', () => {
|
|
98
|
+
const { asFragment } = render(<Panel>Test</Panel>);
|
|
99
|
+
expect(asFragment()).toMatchSnapshot();
|
|
62
100
|
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { PanelFooter } from '../PanelFooter';
|
|
4
|
+
|
|
5
|
+
test('Renders without children', () => {
|
|
6
|
+
render(
|
|
7
|
+
<div data-testid="panelFooter">
|
|
8
|
+
<PanelFooter />
|
|
9
|
+
</div>
|
|
10
|
+
);
|
|
11
|
+
expect(screen.getByTestId('panelFooter').firstChild).toBeVisible();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('Renders children', () => {
|
|
15
|
+
render(<PanelFooter>Test</PanelFooter>);
|
|
16
|
+
expect(screen.getByText('Test')).toBeVisible();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('Renders with the class pf-c-panel__footer', () => {
|
|
20
|
+
render(<PanelFooter>Test</PanelFooter>);
|
|
21
|
+
expect(screen.getByText('Test')).toHaveClass('pf-c-panel__footer');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('Renders with only the class pf-c-panel__footer by default', () => {
|
|
25
|
+
render(<PanelFooter>Test</PanelFooter>);
|
|
26
|
+
expect(screen.getByText('Test')).toHaveClass('pf-c-panel__footer', { exact: true });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('Renders with custom class name when className prop is passed', () => {
|
|
30
|
+
render(<PanelFooter className="test-class">Test</PanelFooter>);
|
|
31
|
+
expect(screen.getByText('Test')).toHaveClass('test-class');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('Renders with the inherited element props spread to the component', () => {
|
|
35
|
+
render(<PanelFooter aria-label="this is a simple panel footer">Test</PanelFooter>);
|
|
36
|
+
expect(screen.getByText('Test')).toHaveAccessibleName('this is a simple panel footer');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('Matches the snapshot', () => {
|
|
40
|
+
const { asFragment } = render(<PanelFooter>Test</PanelFooter>);
|
|
41
|
+
expect(asFragment()).toMatchSnapshot();
|
|
42
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { PanelHeader } from '../PanelHeader';
|
|
4
|
+
|
|
5
|
+
test('Renders without children', () => {
|
|
6
|
+
render(
|
|
7
|
+
<div data-testid="panelHeader">
|
|
8
|
+
<PanelHeader />
|
|
9
|
+
</div>
|
|
10
|
+
);
|
|
11
|
+
expect(screen.getByTestId('panelHeader').firstChild).toBeVisible();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('Renders children', () => {
|
|
15
|
+
render(<PanelHeader>Test</PanelHeader>);
|
|
16
|
+
expect(screen.getByText('Test')).toBeVisible();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('Renders with the class pf-c-panel__header', () => {
|
|
20
|
+
render(<PanelHeader>Test</PanelHeader>);
|
|
21
|
+
expect(screen.getByText('Test')).toHaveClass('pf-c-panel__header');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('Renders with only the class pf-c-panel__header by default', () => {
|
|
25
|
+
render(<PanelHeader>Test</PanelHeader>);
|
|
26
|
+
expect(screen.getByText('Test')).toHaveClass('pf-c-panel__header', { exact: true });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('Renders with custom class name when className prop is passed', () => {
|
|
30
|
+
render(<PanelHeader className="test-class">Test</PanelHeader>);
|
|
31
|
+
expect(screen.getByText('Test')).toHaveClass('test-class');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('Renders with the inherited element props spread to the component', () => {
|
|
35
|
+
render(<PanelHeader aria-label="this is a simple panel header">Test</PanelHeader>);
|
|
36
|
+
expect(screen.getByText('Test')).toHaveAccessibleName('this is a simple panel header');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('Matches the snapshot', () => {
|
|
40
|
+
const { asFragment } = render(<PanelHeader>Test</PanelHeader>);
|
|
41
|
+
expect(asFragment()).toMatchSnapshot();
|
|
42
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { PanelMain } from '../PanelMain';
|
|
4
|
+
|
|
5
|
+
test('Renders without children', () => {
|
|
6
|
+
render(
|
|
7
|
+
<div data-testid="panelMain">
|
|
8
|
+
<PanelMain />
|
|
9
|
+
</div>
|
|
10
|
+
);
|
|
11
|
+
expect(screen.getByTestId('panelMain').firstChild).toBeVisible();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('Renders children', () => {
|
|
15
|
+
render(<PanelMain>Test</PanelMain>);
|
|
16
|
+
expect(screen.getByText('Test')).toBeVisible();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('Renders with the class pf-c-panel__main', () => {
|
|
20
|
+
render(<PanelMain>Test</PanelMain>);
|
|
21
|
+
expect(screen.getByText('Test')).toHaveClass('pf-c-panel__main');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('Renders with only the class pf-c-panel__main by default', () => {
|
|
25
|
+
render(<PanelMain>Test</PanelMain>);
|
|
26
|
+
expect(screen.getByText('Test')).toHaveClass('pf-c-panel__main', { exact: true });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('Renders with custom class name when className prop is passed', () => {
|
|
30
|
+
render(<PanelMain className="test-class">Test</PanelMain>);
|
|
31
|
+
expect(screen.getByText('Test')).toHaveClass('test-class');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('Renders with custom max height name when maxHeight prop is passed', () => {
|
|
35
|
+
render(<PanelMain maxHeight="100px">Test</PanelMain>);
|
|
36
|
+
const styles = getComputedStyle(screen.getByText('Test'));
|
|
37
|
+
expect(styles.getPropertyValue('--pf-c-panel__main--MaxHeight')).toBe('100px');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('Renders with the inherited element props spread to the component', () => {
|
|
41
|
+
render(<PanelMain aria-label="this is a simple panel main">Test</PanelMain>);
|
|
42
|
+
expect(screen.getByText('Test')).toHaveAccessibleName('this is a simple panel main');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('Matches the snapshot', () => {
|
|
46
|
+
const { asFragment } = render(<PanelMain>Test</PanelMain>);
|
|
47
|
+
expect(asFragment()).toMatchSnapshot();
|
|
48
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { PanelMainBody } from '../PanelMainBody';
|
|
4
|
+
|
|
5
|
+
test('Renders without children', () => {
|
|
6
|
+
render(
|
|
7
|
+
<div data-testid="panelMainBody">
|
|
8
|
+
<PanelMainBody />
|
|
9
|
+
</div>
|
|
10
|
+
);
|
|
11
|
+
expect(screen.getByTestId('panelMainBody').firstChild).toBeVisible();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('Renders children', () => {
|
|
15
|
+
render(<PanelMainBody>Test</PanelMainBody>);
|
|
16
|
+
expect(screen.getByText('Test')).toBeVisible();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('Renders with the class pf-c-panel__main-body', () => {
|
|
20
|
+
render(<PanelMainBody>Test</PanelMainBody>);
|
|
21
|
+
expect(screen.getByText('Test')).toHaveClass('pf-c-panel__main-body');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('Renders with only the class pf-c-panel__main-body by default', () => {
|
|
25
|
+
render(<PanelMainBody>Test</PanelMainBody>);
|
|
26
|
+
expect(screen.getByText('Test')).toHaveClass('pf-c-panel__main-body', { exact: true });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('Renders with custom class name when className prop is passed', () => {
|
|
30
|
+
render(<PanelMainBody className="test-class">Test</PanelMainBody>);
|
|
31
|
+
expect(screen.getByText('Test')).toHaveClass('test-class');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('Renders with the inherited element props spread to the component', () => {
|
|
35
|
+
render(<PanelMainBody aria-label="this is a simple panel main body">Test</PanelMainBody>);
|
|
36
|
+
expect(screen.getByText('Test')).toHaveAccessibleName('this is a simple panel main body');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('Matches the snapshot', () => {
|
|
40
|
+
const { asFragment } = render(<PanelMainBody>Test</PanelMainBody>);
|
|
41
|
+
expect(asFragment()).toMatchSnapshot();
|
|
42
|
+
});
|
|
@@ -1,92 +1,12 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`
|
|
3
|
+
exports[`Matches the snapshot 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
5
5
|
<div
|
|
6
6
|
class="pf-c-panel"
|
|
7
7
|
>
|
|
8
|
-
|
|
8
|
+
Test
|
|
9
9
|
</div>
|
|
10
10
|
</DocumentFragment>
|
|
11
11
|
`;
|
|
12
12
|
|
|
13
|
-
exports[`Panel renders content with bordered styling 1`] = `
|
|
14
|
-
<DocumentFragment>
|
|
15
|
-
<div
|
|
16
|
-
class="pf-c-panel pf-m-bordered"
|
|
17
|
-
>
|
|
18
|
-
Foo
|
|
19
|
-
</div>
|
|
20
|
-
</DocumentFragment>
|
|
21
|
-
`;
|
|
22
|
-
|
|
23
|
-
exports[`Panel renders content with raised styling 1`] = `
|
|
24
|
-
<DocumentFragment>
|
|
25
|
-
<div
|
|
26
|
-
class="pf-c-panel pf-m-raised"
|
|
27
|
-
>
|
|
28
|
-
Foo
|
|
29
|
-
</div>
|
|
30
|
-
</DocumentFragment>
|
|
31
|
-
`;
|
|
32
|
-
|
|
33
|
-
exports[`Panel renders content with scrollable styling 1`] = `
|
|
34
|
-
<DocumentFragment>
|
|
35
|
-
<div
|
|
36
|
-
class="pf-c-panel pf-m-scrollable"
|
|
37
|
-
>
|
|
38
|
-
Foo
|
|
39
|
-
</div>
|
|
40
|
-
</DocumentFragment>
|
|
41
|
-
`;
|
|
42
|
-
|
|
43
|
-
exports[`PanelFooter renders content 1`] = `
|
|
44
|
-
<DocumentFragment>
|
|
45
|
-
<div
|
|
46
|
-
class="pf-c-panel__footer"
|
|
47
|
-
>
|
|
48
|
-
Foo
|
|
49
|
-
</div>
|
|
50
|
-
</DocumentFragment>
|
|
51
|
-
`;
|
|
52
|
-
|
|
53
|
-
exports[`PanelHeader renders content 1`] = `
|
|
54
|
-
<DocumentFragment>
|
|
55
|
-
<div
|
|
56
|
-
class="pf-c-panel__header"
|
|
57
|
-
>
|
|
58
|
-
Foo
|
|
59
|
-
</div>
|
|
60
|
-
</DocumentFragment>
|
|
61
|
-
`;
|
|
62
|
-
|
|
63
|
-
exports[`PanelMain renders content 1`] = `
|
|
64
|
-
<DocumentFragment>
|
|
65
|
-
<div
|
|
66
|
-
class="pf-c-panel__main"
|
|
67
|
-
>
|
|
68
|
-
Foo
|
|
69
|
-
</div>
|
|
70
|
-
</DocumentFragment>
|
|
71
|
-
`;
|
|
72
|
-
|
|
73
|
-
exports[`PanelMain renders content with the set maximum height 1`] = `
|
|
74
|
-
<DocumentFragment>
|
|
75
|
-
<div
|
|
76
|
-
class="pf-c-panel__main"
|
|
77
|
-
style="--pf-c-panel__main--MaxHeight: 80px;"
|
|
78
|
-
>
|
|
79
|
-
Foo
|
|
80
|
-
</div>
|
|
81
|
-
</DocumentFragment>
|
|
82
|
-
`;
|
|
83
|
-
|
|
84
|
-
exports[`PanelMainBody renders content 1`] = `
|
|
85
|
-
<DocumentFragment>
|
|
86
|
-
<div
|
|
87
|
-
class="pf-c-panel__main-body"
|
|
88
|
-
>
|
|
89
|
-
Foo
|
|
90
|
-
</div>
|
|
91
|
-
</DocumentFragment>
|
|
92
|
-
`;
|
|
@@ -3,6 +3,16 @@ import { css } from '@patternfly/react-styles';
|
|
|
3
3
|
import styles from '@patternfly/react-styles/css/components/Sidebar/sidebar';
|
|
4
4
|
import { formatBreakpointMods } from '../../helpers/util';
|
|
5
5
|
|
|
6
|
+
export enum SidebarPanelWidthType {
|
|
7
|
+
default = 'default',
|
|
8
|
+
width25 = 'width_25',
|
|
9
|
+
width33 = 'width_33',
|
|
10
|
+
width50 = 'width_50',
|
|
11
|
+
width66 = 'width_66',
|
|
12
|
+
width75 = 'width_75',
|
|
13
|
+
width100 = 'width_100'
|
|
14
|
+
}
|
|
15
|
+
|
|
6
16
|
export interface SidebarPanelProps extends Omit<React.HTMLProps<HTMLDivElement>, 'width'> {
|
|
7
17
|
children: React.ReactNode;
|
|
8
18
|
/** Indicates whether the panel is positioned statically or sticky to the top. Default is sticky on small screens when the orientation is stack, and static on medium and above screens when the orientation is split. */
|
|
@@ -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
|
+
});
|