@patternfly/react-core 4.202.16 → 4.202.19
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 +24 -0
- package/dist/esm/components/CalendarMonth/CalendarMonth.d.ts.map +1 -1
- package/dist/esm/components/CalendarMonth/CalendarMonth.js +12 -4
- package/dist/esm/components/CalendarMonth/CalendarMonth.js.map +1 -1
- package/dist/js/components/CalendarMonth/CalendarMonth.d.ts.map +1 -1
- package/dist/js/components/CalendarMonth/CalendarMonth.js +12 -4
- package/dist/js/components/CalendarMonth/CalendarMonth.js.map +1 -1
- package/dist/umd/react-core.js +12 -4
- package/dist/umd/react-core.min.css +460 -460
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +5 -5
- package/src/components/CalendarMonth/CalendarMonth.tsx +10 -4
- package/src/components/CalendarMonth/examples/CalendarMonth.md +9 -0
- package/src/components/CalendarMonth/examples/CalendarMonthDateRange.tsx +10 -0
- package/src/components/ContextSelector/examples/ContextSelector.md +3 -279
- package/src/components/ContextSelector/examples/ContextSelectorBasic.tsx +84 -0
- package/src/components/ContextSelector/examples/ContextSelectorPlainText.tsx +85 -0
- package/src/components/ContextSelector/examples/ContextSelectorWithFooter.tsx +91 -0
- package/src/components/DescriptionList/examples/DescriptionList.md +22 -930
- package/src/components/DescriptionList/examples/DescriptionListAutoFitBasic.tsx +40 -0
- package/src/components/DescriptionList/examples/DescriptionListAutoFitMinWidthModified.tsx +40 -0
- package/src/components/DescriptionList/examples/DescriptionListAutoFitMinWidthResponsive.tsx +40 -0
- package/src/components/DescriptionList/examples/DescriptionListBasic.tsx +40 -0
- package/src/components/DescriptionList/examples/DescriptionListColumnFill.tsx +42 -0
- package/src/components/DescriptionList/examples/DescriptionListCompact.tsx +40 -0
- package/src/components/DescriptionList/examples/DescriptionListCompactHorizontal.tsx +40 -0
- package/src/components/DescriptionList/examples/DescriptionListDefaultAutoColumn.tsx +40 -0
- package/src/components/DescriptionList/examples/DescriptionListDefaultInlineGrid.tsx +40 -0
- package/src/components/DescriptionList/examples/DescriptionListDefaultResponsiveColumns.tsx +40 -0
- package/src/components/DescriptionList/examples/DescriptionListDefaultThreeColLg.tsx +40 -0
- package/src/components/DescriptionList/examples/DescriptionListDefaultTwoCol.tsx +44 -0
- package/src/components/DescriptionList/examples/DescriptionListFluidHorizontal.tsx +40 -0
- package/src/components/DescriptionList/examples/DescriptionListHorizontal.tsx +40 -0
- package/src/components/DescriptionList/examples/DescriptionListHorizontalAutoColumn.tsx +40 -0
- package/src/components/DescriptionList/examples/DescriptionListHorizontalCustomTermWidth.tsx +50 -0
- package/src/components/DescriptionList/examples/DescriptionListHorizontalResponsiveColumns.tsx +40 -0
- package/src/components/DescriptionList/examples/DescriptionListHorizontalThreeColLg.tsx +40 -0
- package/src/components/DescriptionList/examples/DescriptionListHorizontalTwoCol.tsx +40 -0
- package/src/components/DescriptionList/examples/DescriptionListIconsOnTerms.tsx +45 -0
- package/src/components/DescriptionList/examples/DescriptionListResponsiveHoriVertGroup.tsx +48 -0
- package/src/components/DescriptionList/examples/DescriptionListWithTermHelpText.tsx +62 -0
- package/src/components/Divider/examples/Divider.md +15 -68
- package/src/components/Divider/examples/DividerInsetMedium.tsx +4 -0
- package/src/components/Divider/examples/DividerInsetVariousBreakpoints.tsx +13 -0
- package/src/components/Divider/examples/DividerUsingDiv.tsx +4 -0
- package/src/components/Divider/examples/DividerUsingHr.tsx +4 -0
- package/src/components/Divider/examples/DividerUsingLi.tsx +10 -0
- package/src/components/Divider/examples/DividerVerticalFlex.tsx +10 -0
- package/src/components/Divider/examples/DividerVerticalFlexInsetMedium.tsx +10 -0
- package/src/components/Divider/examples/DividerVerticalFlexInsetVariousBreakpoints.tsx +18 -0
- package/src/components/FormSelect/__tests__/FormSelect.test.tsx +0 -1
- package/src/components/List/__tests__/List.test.tsx +33 -33
- package/src/components/List/__tests__/__snapshots__/List.test.tsx.snap +33 -64
- package/src/components/Menu/__tests__/Menu.test.tsx +37 -33
- package/src/components/Menu/__tests__/__snapshots__/Menu.test.tsx.snap +3 -36
- package/src/components/Modal/__tests__/Modal.test.tsx +65 -67
- package/src/components/Modal/__tests__/ModalBoxCloseButton.test.tsx +13 -10
- package/src/components/Nav/__tests__/Nav.test.tsx +185 -214
- package/src/components/Nav/__tests__/__snapshots__/Nav.test.tsx.snap +877 -1729
- package/src/components/NotificationDrawer/__tests__/NotificationDrawer.test.tsx +13 -15
- package/src/components/NotificationDrawer/__tests__/NotificationDrawerBody.test.tsx +13 -15
- package/src/components/NotificationDrawer/__tests__/NotificationDrawerGroup.test.tsx +21 -27
- package/src/components/NotificationDrawer/__tests__/NotificationDrawerGroupList.test.tsx +13 -15
- package/src/components/NotificationDrawer/__tests__/NotificationDrawerHeader.test.tsx +25 -27
- package/src/components/NotificationDrawer/__tests__/NotificationDrawerList.test.tsx +17 -19
- package/src/components/NotificationDrawer/__tests__/NotificationDrawerListItem.test.tsx +20 -27
- package/src/components/NotificationDrawer/__tests__/NotificationDrawerListItemBody.test.tsx +17 -13
- package/src/components/NotificationDrawer/__tests__/NotificationDrawerListItemHeader.test.tsx +30 -25
- package/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawer.test.tsx.snap +3 -5
- package/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerBody.test.tsx.snap +3 -5
- package/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerGroup.test.tsx.snap +9 -11
- package/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerGroupList.test.tsx.snap +3 -5
- package/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerHeader.test.tsx.snap +16 -18
- package/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerList.test.tsx.snap +7 -8
- package/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerListItem.test.tsx.snap +3 -5
- package/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerListItemBody.test.tsx.snap +6 -8
- package/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerListItemHeader.test.tsx.snap +12 -14
- package/src/components/OverflowMenu/__tests__/OverflowMenu.test.tsx +15 -12
- package/src/components/OverflowMenu/__tests__/OverflowMenuControl.test.tsx +9 -8
- package/src/components/OverflowMenu/__tests__/OverflowMenuGroup.test.tsx +17 -18
- package/src/components/OverflowMenu/__tests__/OverflowMenuItem.test.tsx +10 -9
- package/src/components/OverflowMenu/__tests__/__snapshots__/OverflowMenu.test.tsx.snap +6 -16
- package/src/components/OverflowMenu/__tests__/__snapshots__/OverflowMenuControl.test.tsx.snap +3 -15
- package/src/components/OverflowMenu/__tests__/__snapshots__/OverflowMenuItem.test.tsx.snap +3 -17
- package/src/components/Modal/__tests__/__snapshots__/ModalBoxCloseButton.test.tsx.snap +0 -16
- package/src/components/OverflowMenu/__tests__/__snapshots__/OverflowMenuGroup.test.tsx.snap +0 -33
|
@@ -1,120 +1,120 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
2
|
+
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import '@testing-library/jest-dom';
|
|
5
|
+
|
|
6
6
|
import BookOpen from '@patternfly/react-icons/dist/esm/icons/book-open-icon';
|
|
7
7
|
import Key from '@patternfly/react-icons/dist/esm/icons/key-icon';
|
|
8
8
|
import Desktop from '@patternfly/react-icons/dist/esm/icons/desktop-icon';
|
|
9
|
+
import { List, ListVariant, ListComponent, OrderType } from '../List';
|
|
10
|
+
import { ListItem } from '../ListItem';
|
|
9
11
|
|
|
10
12
|
const ListItems = () => (
|
|
11
|
-
<
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
</List>
|
|
17
|
-
</React.Fragment>
|
|
13
|
+
<List>
|
|
14
|
+
<ListItem>First</ListItem>
|
|
15
|
+
<ListItem>Second</ListItem>
|
|
16
|
+
<ListItem>Third</ListItem>
|
|
17
|
+
</List>
|
|
18
18
|
);
|
|
19
19
|
|
|
20
|
-
describe('
|
|
20
|
+
describe('List', () => {
|
|
21
21
|
test('simple list', () => {
|
|
22
|
-
const
|
|
22
|
+
const { asFragment } = render(
|
|
23
23
|
<List>
|
|
24
24
|
<ListItems />
|
|
25
25
|
</List>
|
|
26
26
|
);
|
|
27
|
-
expect(
|
|
27
|
+
expect(asFragment()).toMatchSnapshot();
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
test('inline list', () => {
|
|
31
|
-
const
|
|
31
|
+
const { asFragment } = render(
|
|
32
32
|
<List variant={ListVariant.inline}>
|
|
33
33
|
<ListItems />
|
|
34
34
|
</List>
|
|
35
35
|
);
|
|
36
|
-
expect(
|
|
36
|
+
expect(asFragment()).toMatchSnapshot();
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
test('ordered list', () => {
|
|
40
|
-
const
|
|
40
|
+
const { asFragment } = render(
|
|
41
41
|
<List component={ListComponent.ol}>
|
|
42
42
|
<ListItem>Apple</ListItem>
|
|
43
43
|
<ListItem>Banana</ListItem>
|
|
44
44
|
<ListItem>Orange</ListItem>
|
|
45
45
|
</List>
|
|
46
46
|
);
|
|
47
|
-
expect(
|
|
47
|
+
expect(asFragment()).toMatchSnapshot();
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
test('ordered list starts with 2nd item', () => {
|
|
51
|
-
|
|
51
|
+
render(
|
|
52
52
|
<List component={ListComponent.ol} start={2}>
|
|
53
53
|
<ListItem>Banana</ListItem>
|
|
54
54
|
<ListItem>Orange</ListItem>
|
|
55
55
|
</List>
|
|
56
56
|
);
|
|
57
|
-
expect(
|
|
57
|
+
expect(screen.getByRole('list')).toHaveAttribute('start', '2');
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
test('ordered list items will be numbered with uppercase letters', () => {
|
|
61
|
-
|
|
61
|
+
render(
|
|
62
62
|
<List component={ListComponent.ol} type={OrderType.uppercaseLetter}>
|
|
63
63
|
<ListItem>Banana</ListItem>
|
|
64
64
|
<ListItem>Orange</ListItem>
|
|
65
65
|
</List>
|
|
66
66
|
);
|
|
67
|
-
expect(
|
|
67
|
+
expect(screen.getByRole('list')).toHaveAttribute('type', 'A');
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
test('inlined ordered list', () => {
|
|
71
|
-
|
|
71
|
+
render(
|
|
72
72
|
<List variant={ListVariant.inline} component={ListComponent.ol}>
|
|
73
73
|
<ListItem>Apple</ListItem>
|
|
74
74
|
<ListItem>Banana</ListItem>
|
|
75
75
|
<ListItem>Orange</ListItem>
|
|
76
76
|
</List>
|
|
77
77
|
);
|
|
78
|
-
expect(
|
|
78
|
+
expect(screen.getByRole('list')).toHaveClass('pf-m-inline');
|
|
79
79
|
});
|
|
80
80
|
|
|
81
81
|
test('bordered list', () => {
|
|
82
|
-
|
|
82
|
+
render(
|
|
83
83
|
<List isBordered>
|
|
84
84
|
<ListItems />
|
|
85
85
|
</List>
|
|
86
86
|
);
|
|
87
|
-
expect(
|
|
87
|
+
expect(screen.getAllByRole('list')[0]).toHaveClass('pf-m-bordered');
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
test('plain list', () => {
|
|
91
|
-
|
|
91
|
+
render(
|
|
92
92
|
<List isPlain>
|
|
93
93
|
<ListItems />
|
|
94
94
|
</List>
|
|
95
95
|
);
|
|
96
|
-
expect(
|
|
96
|
+
expect(screen.getAllByRole('list')[0]).toHaveClass('pf-m-plain');
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
test('icon list', () => {
|
|
100
|
-
const
|
|
100
|
+
const { asFragment } = render(
|
|
101
101
|
<List isPlain>
|
|
102
102
|
<ListItem icon={<BookOpen />}>Apple</ListItem>
|
|
103
103
|
<ListItem icon={<Key />}>Banana</ListItem>
|
|
104
104
|
<ListItem icon={<Desktop />}>Orange</ListItem>
|
|
105
105
|
</List>
|
|
106
106
|
);
|
|
107
|
-
expect(
|
|
107
|
+
expect(asFragment()).toMatchSnapshot();
|
|
108
108
|
});
|
|
109
109
|
|
|
110
110
|
test('icon large list', () => {
|
|
111
|
-
const
|
|
112
|
-
<List iconSize=
|
|
111
|
+
const { asFragment } = render(
|
|
112
|
+
<List iconSize="large">
|
|
113
113
|
<ListItem icon={<BookOpen />}>Apple</ListItem>
|
|
114
114
|
<ListItem icon={<Key />}>Banana</ListItem>
|
|
115
115
|
<ListItem icon={<Desktop />}>Orange</ListItem>
|
|
116
116
|
</List>
|
|
117
117
|
);
|
|
118
|
-
expect(
|
|
118
|
+
expect(asFragment()).toMatchSnapshot();
|
|
119
119
|
});
|
|
120
120
|
});
|
|
@@ -1,35 +1,7 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`
|
|
4
|
-
<
|
|
5
|
-
<ul
|
|
6
|
-
class="pf-c-list pf-m-bordered"
|
|
7
|
-
>
|
|
8
|
-
<ul
|
|
9
|
-
class="pf-c-list"
|
|
10
|
-
>
|
|
11
|
-
<li
|
|
12
|
-
class=""
|
|
13
|
-
>
|
|
14
|
-
First
|
|
15
|
-
</li>
|
|
16
|
-
<li
|
|
17
|
-
class=""
|
|
18
|
-
>
|
|
19
|
-
Second
|
|
20
|
-
</li>
|
|
21
|
-
<li
|
|
22
|
-
class=""
|
|
23
|
-
>
|
|
24
|
-
Third
|
|
25
|
-
</li>
|
|
26
|
-
</ul>
|
|
27
|
-
</ul>
|
|
28
|
-
</div>
|
|
29
|
-
`;
|
|
30
|
-
|
|
31
|
-
exports[`list icon large list 1`] = `
|
|
32
|
-
<div>
|
|
3
|
+
exports[`List icon large list 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
33
5
|
<ul
|
|
34
6
|
class="pf-c-list pf-m-icon-lg"
|
|
35
7
|
>
|
|
@@ -100,11 +72,11 @@ exports[`list icon large list 1`] = `
|
|
|
100
72
|
Orange
|
|
101
73
|
</li>
|
|
102
74
|
</ul>
|
|
103
|
-
</
|
|
75
|
+
</DocumentFragment>
|
|
104
76
|
`;
|
|
105
77
|
|
|
106
|
-
exports[`
|
|
107
|
-
<
|
|
78
|
+
exports[`List icon list 1`] = `
|
|
79
|
+
<DocumentFragment>
|
|
108
80
|
<ul
|
|
109
81
|
class="pf-c-list pf-m-plain"
|
|
110
82
|
>
|
|
@@ -175,11 +147,11 @@ exports[`list icon list 1`] = `
|
|
|
175
147
|
Orange
|
|
176
148
|
</li>
|
|
177
149
|
</ul>
|
|
178
|
-
</
|
|
150
|
+
</DocumentFragment>
|
|
179
151
|
`;
|
|
180
152
|
|
|
181
|
-
exports[`
|
|
182
|
-
<
|
|
153
|
+
exports[`List inline list 1`] = `
|
|
154
|
+
<DocumentFragment>
|
|
183
155
|
<ul
|
|
184
156
|
class="pf-c-list pf-m-inline"
|
|
185
157
|
>
|
|
@@ -203,39 +175,36 @@ exports[`list inline list 1`] = `
|
|
|
203
175
|
</li>
|
|
204
176
|
</ul>
|
|
205
177
|
</ul>
|
|
206
|
-
</
|
|
178
|
+
</DocumentFragment>
|
|
207
179
|
`;
|
|
208
180
|
|
|
209
|
-
exports[`
|
|
210
|
-
<
|
|
211
|
-
<
|
|
212
|
-
class="pf-c-list
|
|
181
|
+
exports[`List ordered list 1`] = `
|
|
182
|
+
<DocumentFragment>
|
|
183
|
+
<ol
|
|
184
|
+
class="pf-c-list"
|
|
185
|
+
type="1"
|
|
213
186
|
>
|
|
214
|
-
<
|
|
215
|
-
class="
|
|
187
|
+
<li
|
|
188
|
+
class=""
|
|
216
189
|
>
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
</li>
|
|
232
|
-
</ul>
|
|
233
|
-
</ul>
|
|
234
|
-
</div>
|
|
190
|
+
Apple
|
|
191
|
+
</li>
|
|
192
|
+
<li
|
|
193
|
+
class=""
|
|
194
|
+
>
|
|
195
|
+
Banana
|
|
196
|
+
</li>
|
|
197
|
+
<li
|
|
198
|
+
class=""
|
|
199
|
+
>
|
|
200
|
+
Orange
|
|
201
|
+
</li>
|
|
202
|
+
</ol>
|
|
203
|
+
</DocumentFragment>
|
|
235
204
|
`;
|
|
236
205
|
|
|
237
|
-
exports[`
|
|
238
|
-
<
|
|
206
|
+
exports[`List simple list 1`] = `
|
|
207
|
+
<DocumentFragment>
|
|
239
208
|
<ul
|
|
240
209
|
class="pf-c-list"
|
|
241
210
|
>
|
|
@@ -259,5 +228,5 @@ exports[`list simple list 1`] = `
|
|
|
259
228
|
</li>
|
|
260
229
|
</ul>
|
|
261
230
|
</ul>
|
|
262
|
-
</
|
|
231
|
+
</DocumentFragment>
|
|
263
232
|
`;
|
|
@@ -1,46 +1,50 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {
|
|
2
|
+
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import "@testing-library/jest-dom";
|
|
5
|
+
|
|
4
6
|
import { Menu } from '../Menu';
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
describe('Menu', () => {
|
|
9
|
+
test('should render Menu successfully', () => {
|
|
10
|
+
const { asFragment } = render(
|
|
11
|
+
<Menu activeItemId={0} onSelect={jest.fn()}>
|
|
12
|
+
content
|
|
13
|
+
</Menu>
|
|
11
14
|
);
|
|
12
|
-
expect(
|
|
13
|
-
});
|
|
15
|
+
expect(asFragment()).toMatchSnapshot();
|
|
16
|
+
});
|
|
14
17
|
|
|
15
|
-
describe('with isPlain', () => {
|
|
18
|
+
describe('with isPlain', () => {
|
|
16
19
|
test('should render Menu with plain styles applied', () => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
render(
|
|
21
|
+
<Menu activeItemId={0} onSelect={jest.fn()} isPlain>
|
|
22
|
+
content
|
|
23
|
+
</Menu>
|
|
24
|
+
);
|
|
25
|
+
expect(screen.getByText('content')).toHaveClass('pf-m-plain');
|
|
23
26
|
});
|
|
24
|
-
});
|
|
27
|
+
});
|
|
25
28
|
|
|
26
|
-
describe('with isScrollable', () => {
|
|
29
|
+
describe('with isScrollable', () => {
|
|
27
30
|
test('should render Menu with scrollable styles applied', () => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
render(
|
|
32
|
+
<Menu activeItemId={0} onSelect={jest.fn()} isScrollable>
|
|
33
|
+
content
|
|
34
|
+
</Menu>
|
|
35
|
+
);
|
|
36
|
+
expect(screen.getByText('content')).toHaveClass('pf-m-scrollable');
|
|
34
37
|
});
|
|
35
|
-
});
|
|
38
|
+
});
|
|
36
39
|
|
|
37
|
-
describe('with isNavFlyout', () => {
|
|
40
|
+
describe('with isNavFlyout', () => {
|
|
38
41
|
test('should render Menu with nav flyout styles applied', () => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
render(
|
|
43
|
+
<Menu activeItemId={0} onSelect={jest.fn()} isNavFlyout>
|
|
44
|
+
content
|
|
45
|
+
</Menu>
|
|
46
|
+
);
|
|
47
|
+
expect(screen.getByText('content')).toHaveClass('pf-m-nav');
|
|
45
48
|
});
|
|
46
|
-
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`should render Menu successfully 1`] = `
|
|
4
|
-
<
|
|
3
|
+
exports[`Menu should render Menu successfully 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
5
|
<div
|
|
6
6
|
class="pf-c-menu"
|
|
7
7
|
data-ouia-component-id="OUIA-Generated-Menu-1"
|
|
@@ -10,38 +10,5 @@ exports[`should render Menu successfully 1`] = `
|
|
|
10
10
|
>
|
|
11
11
|
content
|
|
12
12
|
</div>
|
|
13
|
-
</
|
|
14
|
-
`;
|
|
15
|
-
|
|
16
|
-
exports[`with isNavFlyout should render Menu with nav flyout styles applied 1`] = `
|
|
17
|
-
<div
|
|
18
|
-
className="pf-c-menu pf-m-nav"
|
|
19
|
-
data-ouia-component-id="OUIA-Generated-Menu-4"
|
|
20
|
-
data-ouia-component-type="PF4/Menu"
|
|
21
|
-
data-ouia-safe={true}
|
|
22
|
-
>
|
|
23
|
-
content
|
|
24
|
-
</div>
|
|
25
|
-
`;
|
|
26
|
-
|
|
27
|
-
exports[`with isPlain should render Menu with plain styles applied 1`] = `
|
|
28
|
-
<div
|
|
29
|
-
className="pf-c-menu pf-m-plain"
|
|
30
|
-
data-ouia-component-id="OUIA-Generated-Menu-2"
|
|
31
|
-
data-ouia-component-type="PF4/Menu"
|
|
32
|
-
data-ouia-safe={true}
|
|
33
|
-
>
|
|
34
|
-
content
|
|
35
|
-
</div>
|
|
36
|
-
`;
|
|
37
|
-
|
|
38
|
-
exports[`with isScrollable should render Menu with scrollable styles applied 1`] = `
|
|
39
|
-
<div
|
|
40
|
-
className="pf-c-menu pf-m-scrollable"
|
|
41
|
-
data-ouia-component-id="OUIA-Generated-Menu-3"
|
|
42
|
-
data-ouia-component-type="PF4/Menu"
|
|
43
|
-
data-ouia-safe={true}
|
|
44
|
-
>
|
|
45
|
-
content
|
|
46
|
-
</div>
|
|
13
|
+
</DocumentFragment>
|
|
47
14
|
`;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
import {
|
|
2
|
+
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
5
|
+
import '@testing-library/jest-dom';
|
|
6
|
+
|
|
4
7
|
import { css } from '../../../../../react-styles/dist/js';
|
|
5
8
|
import styles from '@patternfly/react-styles/css/components/Backdrop/backdrop';
|
|
6
9
|
|
|
@@ -16,76 +19,71 @@ const props = {
|
|
|
16
19
|
children: 'modal content'
|
|
17
20
|
};
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
22
|
+
describe('Modal', () => {
|
|
23
|
+
test('Modal creates a container element once for div', () => {
|
|
24
|
+
render(<Modal {...props} />);
|
|
25
|
+
expect(document.createElement).toBeCalledWith('div');
|
|
26
|
+
});
|
|
25
27
|
|
|
26
|
-
test('modal closes with escape', () => {
|
|
27
|
-
|
|
28
|
-
const mock: any = (document.body.addEventListener as any).mock;
|
|
29
|
-
const [event, handler] = mock.calls[0];
|
|
30
|
-
expect(event).toBe('keydown');
|
|
31
|
-
handler({ keyCode: KEY_CODES.ESCAPE_KEY });
|
|
32
|
-
expect(props.onClose).toBeCalled();
|
|
33
|
-
});
|
|
28
|
+
test('modal closes with escape', () => {
|
|
29
|
+
render(<Modal {...props} isOpen appendTo={document.body} />);
|
|
34
30
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const [event, handler] = mock.calls[0];
|
|
39
|
-
expect(event).toBe('keydown');
|
|
40
|
-
handler({ keyCode: KEY_CODES.ESCAPE_KEY });
|
|
41
|
-
expect(props.onClose).not.toBeCalled();
|
|
42
|
-
});
|
|
31
|
+
userEvent.type(screen.getByText(props.title), '{esc}');
|
|
32
|
+
expect(props.onClose).toBeCalled();
|
|
33
|
+
});
|
|
43
34
|
|
|
44
|
-
test('
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
35
|
+
test('modal does not call onClose for esc key if it is not open', () => {
|
|
36
|
+
render(<Modal {...props} />);
|
|
37
|
+
expect(screen.queryByRole('dialog')).toBeNull();
|
|
38
|
+
expect(props.onClose).not.toBeCalled();
|
|
39
|
+
});
|
|
49
40
|
|
|
50
|
-
test('modal
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
view.setProps({ isOpen: false });
|
|
55
|
-
view.update();
|
|
56
|
-
expect(document.body.className).not.toContain(css(styles.backdropOpen));
|
|
57
|
-
});
|
|
41
|
+
test('modal has body backdropOpen class when open', () => {
|
|
42
|
+
render(<Modal {...props} isOpen />);
|
|
43
|
+
expect(document.body).toHaveClass(css(styles.backdropOpen));
|
|
44
|
+
});
|
|
58
45
|
|
|
59
|
-
test('modal
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
view.setProps({ showClose: false });
|
|
64
|
-
view.update();
|
|
65
|
-
expect(view.exists('.pf-c-modal-box .pf-c-button')).toBeFalsy();
|
|
66
|
-
});
|
|
46
|
+
test('modal has no body backdropOpen class when not open', () => {
|
|
47
|
+
render(<Modal {...props} />);
|
|
48
|
+
expect(document.body).not.toHaveClass(css(styles.backdropOpen));
|
|
49
|
+
});
|
|
67
50
|
|
|
68
|
-
test('modal
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
51
|
+
test('modal shows the close button when showClose is true (true by default)', () => {
|
|
52
|
+
render(<Modal {...props} isOpen />);
|
|
53
|
+
expect(screen.getByRole('button', { name: 'Close' })).toBeInTheDocument();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('modal does not show the close button when showClose is false', () => {
|
|
57
|
+
render(<Modal {...props} isOpen showClose={false} tabIndex={0} />);
|
|
58
|
+
expect(screen.queryByRole('button', { name: 'Close' })).toBeNull();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('modal generates console error when no accessible name is provided', () => {
|
|
62
|
+
const props = {
|
|
63
|
+
onClose: jest.fn(),
|
|
64
|
+
isOpen: true,
|
|
65
|
+
children: 'modal content'
|
|
66
|
+
};
|
|
67
|
+
const consoleErrorMock = jest.fn();
|
|
68
|
+
global.console = { error: consoleErrorMock } as any;
|
|
69
|
+
|
|
70
|
+
render(<Modal {...props} />);
|
|
71
|
+
|
|
72
|
+
expect(consoleErrorMock).toBeCalled();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('modal generates console warning when conflicting accessible name strategies are provided', () => {
|
|
76
|
+
const props = {
|
|
77
|
+
hasNoBodyWrapper: true,
|
|
78
|
+
onClose: jest.fn(),
|
|
79
|
+
isOpen: true,
|
|
80
|
+
children: 'modal content'
|
|
81
|
+
};
|
|
82
|
+
const consoleErrorMock = jest.fn();
|
|
83
|
+
global.console = { error: consoleErrorMock } as any;
|
|
84
|
+
|
|
85
|
+
render(<Modal {...props} />);
|
|
79
86
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
hasNoBodyWrapper: true,
|
|
83
|
-
onClose: jest.fn(),
|
|
84
|
-
isOpen: true,
|
|
85
|
-
children: 'modal content'
|
|
86
|
-
};
|
|
87
|
-
const consoleErrorMock = jest.fn();
|
|
88
|
-
global.console = { error: consoleErrorMock } as any;
|
|
89
|
-
shallow(<Modal {...props} />);
|
|
90
|
-
expect(consoleErrorMock).toBeCalled();
|
|
87
|
+
expect(consoleErrorMock).toBeCalled();
|
|
88
|
+
});
|
|
91
89
|
});
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
5
|
+
|
|
3
6
|
import { ModalBoxCloseButton } from '../ModalBoxCloseButton';
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
.
|
|
12
|
-
.
|
|
13
|
-
|
|
8
|
+
describe('ModalBoxCloseButton', () => {
|
|
9
|
+
test('onClose called when clicked', () => {
|
|
10
|
+
const onClose = jest.fn();
|
|
11
|
+
|
|
12
|
+
render(<ModalBoxCloseButton className="test-box-close-button-class" onClose={onClose} />);
|
|
13
|
+
|
|
14
|
+
userEvent.click(screen.getByRole('button'));
|
|
15
|
+
expect(onClose).toHaveBeenCalledTimes(1);
|
|
16
|
+
});
|
|
14
17
|
});
|