@patternfly/react-core 4.202.28 → 4.202.31
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/JumpLinks/JumpLinksItem.d.ts.map +1 -1
- package/dist/esm/components/JumpLinks/JumpLinksItem.js +1 -1
- package/dist/esm/components/JumpLinks/JumpLinksItem.js.map +1 -1
- package/dist/esm/components/ProgressStepper/ProgressStep.d.ts +3 -0
- package/dist/esm/components/ProgressStepper/ProgressStep.d.ts.map +1 -1
- package/dist/esm/components/ProgressStepper/ProgressStep.js +2 -2
- package/dist/esm/components/ProgressStepper/ProgressStep.js.map +1 -1
- package/dist/esm/components/Tabs/Tab.d.ts.map +1 -1
- package/dist/esm/components/Tabs/Tab.js +2 -2
- package/dist/esm/components/Tabs/Tab.js.map +1 -1
- package/dist/esm/components/Tabs/Tabs.d.ts +1 -1
- package/dist/esm/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/esm/components/Tabs/Tabs.js +1 -1
- package/dist/esm/components/Tabs/Tabs.js.map +1 -1
- package/dist/esm/helpers/Popper/Popper.d.ts.map +1 -1
- package/dist/esm/helpers/Popper/Popper.js +1 -7
- package/dist/esm/helpers/Popper/Popper.js.map +1 -1
- package/dist/js/components/JumpLinks/JumpLinksItem.d.ts.map +1 -1
- package/dist/js/components/JumpLinks/JumpLinksItem.js +1 -1
- package/dist/js/components/JumpLinks/JumpLinksItem.js.map +1 -1
- package/dist/js/components/ProgressStepper/ProgressStep.d.ts +3 -0
- package/dist/js/components/ProgressStepper/ProgressStep.d.ts.map +1 -1
- package/dist/js/components/ProgressStepper/ProgressStep.js +2 -2
- package/dist/js/components/ProgressStepper/ProgressStep.js.map +1 -1
- package/dist/js/components/Tabs/Tab.d.ts.map +1 -1
- package/dist/js/components/Tabs/Tab.js +2 -2
- package/dist/js/components/Tabs/Tab.js.map +1 -1
- package/dist/js/components/Tabs/Tabs.d.ts +1 -1
- package/dist/js/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/js/components/Tabs/Tabs.js +1 -1
- package/dist/js/components/Tabs/Tabs.js.map +1 -1
- package/dist/js/helpers/Popper/Popper.d.ts.map +1 -1
- package/dist/js/helpers/Popper/Popper.js +1 -7
- package/dist/js/helpers/Popper/Popper.js.map +1 -1
- package/dist/umd/react-core.js +7 -13
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +5 -5
- package/src/components/Dropdown/__tests__/DropdownToggleCheckbox.test.tsx +1 -1
- package/src/components/ExpandableSection/examples/ExpandableSection.md +1 -1
- package/src/components/JumpLinks/JumpLinksItem.tsx +5 -1
- package/src/components/JumpLinks/__tests__/__snapshots__/JumpLinks.test.tsx.snap +5 -0
- package/src/components/Page/__tests__/Page.test.tsx +225 -205
- package/src/components/Page/__tests__/__snapshots__/Page.test.tsx.snap +1088 -2059
- package/src/components/Pagination/__tests__/Pagination.test.tsx +235 -283
- package/src/components/Pagination/__tests__/__snapshots__/Pagination.test.tsx.snap +143 -577
- package/src/components/ProgressStepper/ProgressStep.tsx +6 -0
- package/src/components/ProgressStepper/__tests__/__snapshots__/ProgressStepper.test.tsx.snap +1 -0
- package/src/components/ProgressStepper/examples/ProgressStepper.md +9 -9
- package/src/components/Radio/__tests__/Radio.test.tsx +38 -44
- package/src/components/Radio/__tests__/__snapshots__/Radio.test.tsx.snap +30 -30
- package/src/components/SearchInput/__tests__/SearchInput.test.tsx +87 -68
- package/src/components/SearchInput/__tests__/__snapshots__/SearchInput.test.tsx.snap +230 -137
- package/src/components/Select/__tests__/Select.test.tsx +238 -195
- package/src/components/Select/__tests__/SelectToggle.test.tsx +68 -130
- package/src/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +978 -2149
- package/src/components/Select/__tests__/__snapshots__/SelectToggle.test.tsx.snap +3 -3
- package/src/components/SimpleList/__tests__/SimpleList.test.tsx +29 -32
- package/src/components/SimpleList/__tests__/__snapshots__/SimpleList.test.tsx.snap +4 -366
- package/src/components/Switch/__tests__/Switch.test.tsx +85 -75
- package/src/components/Switch/__tests__/__snapshots__/Switch.test.tsx.snap +30 -40
- package/src/components/Tabs/Tab.tsx +6 -1
- package/src/components/Tabs/Tabs.tsx +2 -2
- package/src/components/Tabs/__tests__/Generated/__snapshots__/Tabs.test.tsx.snap +1 -0
- package/src/components/Tabs/__tests__/__snapshots__/Tab.test.tsx.snap +3 -0
- package/src/components/Tabs/__tests__/__snapshots__/Tabs.test.tsx.snap +135 -0
- package/src/components/Tabs/examples/Tabs.md +32 -26
- package/src/components/TextArea/__tests__/TextArea.test.tsx +98 -103
- package/src/components/TextArea/__tests__/__snapshots__/TextArea.test.tsx.snap +24 -103
- package/src/components/TextInput/__tests__/TextInput.test.tsx +71 -70
- package/src/components/TextInput/__tests__/__snapshots__/TextInput.test.tsx.snap +15 -103
- package/src/components/TextInputGroup/__tests__/TextInputGroup.test.tsx +65 -39
- package/src/components/TextInputGroup/__tests__/__snapshots__/TextInputGroup.test.tsx.snap +53 -14
- package/src/components/TimePicker/__tests__/TimePicker.test.tsx +113 -110
- package/src/components/Title/__tests__/Title.test.tsx +21 -20
- package/src/components/Title/__tests__/__snapshots__/Title.test.tsx.snap +24 -30
- package/src/components/ToggleGroup/__tests__/ToggleGroup.test.tsx +43 -39
- package/src/components/ToggleGroup/__tests__/__snapshots__/ToggleGroup.test.tsx.snap +20 -19
- package/src/components/Wizard/__tests__/Wizard.test.tsx +195 -189
- package/src/components/Wizard/__tests__/__snapshots__/Wizard.test.tsx.snap +131 -10
- package/src/helpers/Popper/Popper.tsx +5 -7
- package/src/helpers/__tests__/util.test.ts +113 -0
- package/src/layouts/Bullseye/__tests__/Bullseye.test.tsx +25 -25
- package/src/layouts/Bullseye/__tests__/__snapshots__/Bullseye.test.tsx.snap +3 -5
- package/src/layouts/Flex/__tests__/Flex.test.tsx +159 -96
- package/src/layouts/Flex/__tests__/__snapshots__/Flex.test.tsx.snap +9 -17
- package/src/components/Page/__tests__/Generated/Page.test.tsx +0 -28
- package/src/components/Page/__tests__/Generated/__snapshots__/Page.test.tsx.snap +0 -19
- package/src/components/Pagination/__tests__/Generated/Pagination.test.tsx +0 -58
- package/src/components/Pagination/__tests__/Generated/__snapshots__/Pagination.test.tsx.snap +0 -205
- package/src/components/Radio/__tests__/Generated/Radio.test.tsx +0 -29
- package/src/components/Radio/__tests__/Generated/__snapshots__/Radio.test.tsx.snap +0 -36
- package/src/components/Select/__tests__/Generated/Select.test.tsx +0 -49
- package/src/components/Select/__tests__/Generated/SelectToggle.test.tsx +0 -34
- package/src/components/Select/__tests__/Generated/__snapshots__/Select.test.tsx.snap +0 -48
- package/src/components/Select/__tests__/Generated/__snapshots__/SelectToggle.test.tsx.snap +0 -36
- package/src/components/SimpleList/__tests__/Generated/SimpleList.test.tsx +0 -22
- package/src/components/SimpleList/__tests__/Generated/__snapshots__/SimpleList.test.tsx.snap +0 -13
- package/src/components/Switch/__tests__/Generated/Switch.test.tsx +0 -24
- package/src/components/Switch/__tests__/Generated/__snapshots__/Switch.test.tsx.snap +0 -36
- package/src/components/TextArea/__tests__/Generated/TextArea.test.tsx +0 -23
- package/src/components/TextArea/__tests__/Generated/__snapshots__/TextArea.test.tsx.snap +0 -13
- package/src/components/Title/__tests__/Generated/Title.test.tsx +0 -13
- package/src/components/Title/__tests__/Generated/__snapshots__/Title.test.tsx.snap +0 -12
- package/src/helpers/__tests__/util.test.js +0 -235
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`state active 1`] = `
|
|
4
|
-
<
|
|
3
|
+
exports[`SelectToggle state active 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
5
|
<button
|
|
6
6
|
aria-expanded="false"
|
|
7
7
|
aria-haspopup="listbox"
|
|
@@ -30,5 +30,5 @@ exports[`state active 1`] = `
|
|
|
30
30
|
</svg>
|
|
31
31
|
</span>
|
|
32
32
|
</button>
|
|
33
|
-
</
|
|
33
|
+
</DocumentFragment>
|
|
34
34
|
`;
|
|
@@ -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 { SimpleList } from '../SimpleList';
|
|
5
8
|
import { SimpleListGroup } from '../SimpleListGroup';
|
|
6
9
|
import { SimpleListItem } from '../SimpleListItem';
|
|
@@ -25,64 +28,58 @@ const anchors = [
|
|
|
25
28
|
|
|
26
29
|
describe('SimpleList', () => {
|
|
27
30
|
test('renders content', () => {
|
|
28
|
-
const
|
|
29
|
-
expect(
|
|
31
|
+
const { asFragment } = render(<SimpleList>{items}</SimpleList>);
|
|
32
|
+
expect(asFragment()).toMatchSnapshot();
|
|
30
33
|
});
|
|
31
34
|
|
|
32
35
|
test('renders grouped content', () => {
|
|
33
|
-
const
|
|
36
|
+
const { asFragment } = render(
|
|
34
37
|
<SimpleList>
|
|
35
38
|
<SimpleListGroup title="Group 1">{items}</SimpleListGroup>
|
|
36
39
|
</SimpleList>
|
|
37
40
|
);
|
|
38
|
-
expect(
|
|
41
|
+
expect(asFragment()).toMatchSnapshot();
|
|
39
42
|
});
|
|
40
43
|
|
|
41
44
|
test('onSelect is called when item is selected', () => {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
view.update();
|
|
49
|
-
expect(selectSpy).toBeCalled();
|
|
50
|
-
expect(view).toMatchSnapshot();
|
|
45
|
+
const onSelect = jest.fn();
|
|
46
|
+
|
|
47
|
+
render(<SimpleList onSelect={onSelect}>{items}</SimpleList>);
|
|
48
|
+
|
|
49
|
+
userEvent.click(screen.getByText('Item 1'));
|
|
50
|
+
expect(onSelect).toBeCalled();
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
test('renders anchor content', () => {
|
|
54
|
-
|
|
55
|
-
expect(
|
|
54
|
+
render(<SimpleList>{anchors}</SimpleList>);
|
|
55
|
+
expect(screen.getAllByRole('link').length).toEqual(3);
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
test('onSelect is called when anchor item is selected', () => {
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
view.update();
|
|
66
|
-
expect(selectSpy).toBeCalled();
|
|
67
|
-
expect(view).toMatchSnapshot();
|
|
59
|
+
const onSelect = jest.fn();
|
|
60
|
+
|
|
61
|
+
render(<SimpleList onSelect={onSelect}>{anchors}</SimpleList>);
|
|
62
|
+
|
|
63
|
+
userEvent.click(screen.getByText('Item 1'));
|
|
64
|
+
expect(onSelect).toBeCalled();
|
|
68
65
|
});
|
|
69
66
|
});
|
|
70
67
|
|
|
71
68
|
describe('SimpleListGroup', () => {
|
|
72
69
|
test('renders content', () => {
|
|
73
|
-
|
|
74
|
-
expect(
|
|
70
|
+
render(<SimpleListGroup title="Group 1">{items}</SimpleListGroup>);
|
|
71
|
+
expect(screen.getByText('Group 1')).toBeInTheDocument();
|
|
75
72
|
});
|
|
76
73
|
});
|
|
77
74
|
|
|
78
75
|
describe('SimpleListItem', () => {
|
|
79
76
|
test('renders content', () => {
|
|
80
|
-
|
|
81
|
-
expect(
|
|
77
|
+
render(<SimpleListItem>Item 1</SimpleListItem>);
|
|
78
|
+
expect(screen.getByText('Item 1')).toBeInTheDocument();
|
|
82
79
|
});
|
|
83
80
|
|
|
84
81
|
test('renders anchor', () => {
|
|
85
|
-
|
|
86
|
-
expect(
|
|
82
|
+
render(<SimpleListItem component="a">Item 1</SimpleListItem>);
|
|
83
|
+
expect(screen.getByText('Item 1')).toBeInTheDocument();
|
|
87
84
|
});
|
|
88
85
|
});
|
|
@@ -1,287 +1,7 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`SimpleList onSelect is called when anchor item is selected 1`] = `
|
|
4
|
-
<SimpleList
|
|
5
|
-
className=""
|
|
6
|
-
isControlled={true}
|
|
7
|
-
onSelect={
|
|
8
|
-
[MockFunction] {
|
|
9
|
-
"calls": Array [
|
|
10
|
-
Array [
|
|
11
|
-
Object {
|
|
12
|
-
"current": <a
|
|
13
|
-
class="pf-c-simple-list__item-link pf-m-current"
|
|
14
|
-
href=""
|
|
15
|
-
tabindex="0"
|
|
16
|
-
>
|
|
17
|
-
Item 1
|
|
18
|
-
</a>,
|
|
19
|
-
},
|
|
20
|
-
Object {
|
|
21
|
-
"children": "Item 1",
|
|
22
|
-
"className": "",
|
|
23
|
-
"component": "a",
|
|
24
|
-
"componentClassName": "",
|
|
25
|
-
"href": "",
|
|
26
|
-
"isActive": false,
|
|
27
|
-
"isCurrent": false,
|
|
28
|
-
"onClick": [Function],
|
|
29
|
-
"type": "button",
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
],
|
|
33
|
-
"results": Array [
|
|
34
|
-
Object {
|
|
35
|
-
"type": "return",
|
|
36
|
-
"value": undefined,
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
>
|
|
42
|
-
<div
|
|
43
|
-
className="pf-c-simple-list"
|
|
44
|
-
>
|
|
45
|
-
<ul>
|
|
46
|
-
<SimpleListItem
|
|
47
|
-
className=""
|
|
48
|
-
component="a"
|
|
49
|
-
componentClassName=""
|
|
50
|
-
href=""
|
|
51
|
-
isActive={false}
|
|
52
|
-
isCurrent={false}
|
|
53
|
-
key="i1"
|
|
54
|
-
onClick={[Function]}
|
|
55
|
-
type="button"
|
|
56
|
-
>
|
|
57
|
-
<li
|
|
58
|
-
className=""
|
|
59
|
-
>
|
|
60
|
-
<a
|
|
61
|
-
className="pf-c-simple-list__item-link pf-m-current"
|
|
62
|
-
href=""
|
|
63
|
-
onClick={[Function]}
|
|
64
|
-
tabIndex={0}
|
|
65
|
-
>
|
|
66
|
-
Item 1
|
|
67
|
-
</a>
|
|
68
|
-
</li>
|
|
69
|
-
</SimpleListItem>
|
|
70
|
-
<SimpleListItem
|
|
71
|
-
className=""
|
|
72
|
-
component="a"
|
|
73
|
-
componentClassName=""
|
|
74
|
-
href=""
|
|
75
|
-
isActive={false}
|
|
76
|
-
isCurrent={false}
|
|
77
|
-
key="i2"
|
|
78
|
-
onClick={[Function]}
|
|
79
|
-
type="button"
|
|
80
|
-
>
|
|
81
|
-
<li
|
|
82
|
-
className=""
|
|
83
|
-
>
|
|
84
|
-
<a
|
|
85
|
-
className="pf-c-simple-list__item-link"
|
|
86
|
-
href=""
|
|
87
|
-
onClick={[Function]}
|
|
88
|
-
tabIndex={0}
|
|
89
|
-
>
|
|
90
|
-
Item 2
|
|
91
|
-
</a>
|
|
92
|
-
</li>
|
|
93
|
-
</SimpleListItem>
|
|
94
|
-
<SimpleListItem
|
|
95
|
-
className=""
|
|
96
|
-
component="a"
|
|
97
|
-
componentClassName=""
|
|
98
|
-
href=""
|
|
99
|
-
isActive={false}
|
|
100
|
-
isCurrent={false}
|
|
101
|
-
key="i3"
|
|
102
|
-
onClick={[Function]}
|
|
103
|
-
type="button"
|
|
104
|
-
>
|
|
105
|
-
<li
|
|
106
|
-
className=""
|
|
107
|
-
>
|
|
108
|
-
<a
|
|
109
|
-
className="pf-c-simple-list__item-link"
|
|
110
|
-
href=""
|
|
111
|
-
onClick={[Function]}
|
|
112
|
-
tabIndex={0}
|
|
113
|
-
>
|
|
114
|
-
Item 3
|
|
115
|
-
</a>
|
|
116
|
-
</li>
|
|
117
|
-
</SimpleListItem>
|
|
118
|
-
</ul>
|
|
119
|
-
</div>
|
|
120
|
-
</SimpleList>
|
|
121
|
-
`;
|
|
122
|
-
|
|
123
|
-
exports[`SimpleList onSelect is called when item is selected 1`] = `
|
|
124
|
-
<SimpleList
|
|
125
|
-
className=""
|
|
126
|
-
isControlled={true}
|
|
127
|
-
onSelect={
|
|
128
|
-
[MockFunction] {
|
|
129
|
-
"calls": Array [
|
|
130
|
-
Array [
|
|
131
|
-
Object {
|
|
132
|
-
"current": <button
|
|
133
|
-
class="pf-c-simple-list__item-link pf-m-current"
|
|
134
|
-
type="button"
|
|
135
|
-
>
|
|
136
|
-
Item 1
|
|
137
|
-
</button>,
|
|
138
|
-
},
|
|
139
|
-
Object {
|
|
140
|
-
"children": "Item 1",
|
|
141
|
-
"className": "",
|
|
142
|
-
"component": "button",
|
|
143
|
-
"componentClassName": "",
|
|
144
|
-
"href": "",
|
|
145
|
-
"isActive": false,
|
|
146
|
-
"isCurrent": false,
|
|
147
|
-
"onClick": [Function],
|
|
148
|
-
"type": "button",
|
|
149
|
-
},
|
|
150
|
-
],
|
|
151
|
-
],
|
|
152
|
-
"results": Array [
|
|
153
|
-
Object {
|
|
154
|
-
"type": "return",
|
|
155
|
-
"value": undefined,
|
|
156
|
-
},
|
|
157
|
-
],
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
>
|
|
161
|
-
<div
|
|
162
|
-
className="pf-c-simple-list"
|
|
163
|
-
>
|
|
164
|
-
<ul>
|
|
165
|
-
<SimpleListItem
|
|
166
|
-
className=""
|
|
167
|
-
component="button"
|
|
168
|
-
componentClassName=""
|
|
169
|
-
href=""
|
|
170
|
-
isActive={false}
|
|
171
|
-
isCurrent={false}
|
|
172
|
-
key="i1"
|
|
173
|
-
onClick={[Function]}
|
|
174
|
-
type="button"
|
|
175
|
-
>
|
|
176
|
-
<li
|
|
177
|
-
className=""
|
|
178
|
-
>
|
|
179
|
-
<button
|
|
180
|
-
className="pf-c-simple-list__item-link pf-m-current"
|
|
181
|
-
onClick={[Function]}
|
|
182
|
-
type="button"
|
|
183
|
-
>
|
|
184
|
-
Item 1
|
|
185
|
-
</button>
|
|
186
|
-
</li>
|
|
187
|
-
</SimpleListItem>
|
|
188
|
-
<SimpleListItem
|
|
189
|
-
className=""
|
|
190
|
-
component="button"
|
|
191
|
-
componentClassName=""
|
|
192
|
-
href=""
|
|
193
|
-
isActive={false}
|
|
194
|
-
isCurrent={false}
|
|
195
|
-
key="i2"
|
|
196
|
-
onClick={[Function]}
|
|
197
|
-
type="button"
|
|
198
|
-
>
|
|
199
|
-
<li
|
|
200
|
-
className=""
|
|
201
|
-
>
|
|
202
|
-
<button
|
|
203
|
-
className="pf-c-simple-list__item-link"
|
|
204
|
-
onClick={[Function]}
|
|
205
|
-
type="button"
|
|
206
|
-
>
|
|
207
|
-
Item 2
|
|
208
|
-
</button>
|
|
209
|
-
</li>
|
|
210
|
-
</SimpleListItem>
|
|
211
|
-
<SimpleListItem
|
|
212
|
-
className=""
|
|
213
|
-
component="button"
|
|
214
|
-
componentClassName=""
|
|
215
|
-
href=""
|
|
216
|
-
isActive={false}
|
|
217
|
-
isCurrent={false}
|
|
218
|
-
key="i3"
|
|
219
|
-
onClick={[Function]}
|
|
220
|
-
type="button"
|
|
221
|
-
>
|
|
222
|
-
<li
|
|
223
|
-
className=""
|
|
224
|
-
>
|
|
225
|
-
<button
|
|
226
|
-
className="pf-c-simple-list__item-link"
|
|
227
|
-
onClick={[Function]}
|
|
228
|
-
type="button"
|
|
229
|
-
>
|
|
230
|
-
Item 3
|
|
231
|
-
</button>
|
|
232
|
-
</li>
|
|
233
|
-
</SimpleListItem>
|
|
234
|
-
</ul>
|
|
235
|
-
</div>
|
|
236
|
-
</SimpleList>
|
|
237
|
-
`;
|
|
238
|
-
|
|
239
|
-
exports[`SimpleList renders anchor content 1`] = `
|
|
240
|
-
<div>
|
|
241
|
-
<div
|
|
242
|
-
class="pf-c-simple-list"
|
|
243
|
-
>
|
|
244
|
-
<ul>
|
|
245
|
-
<li
|
|
246
|
-
class=""
|
|
247
|
-
>
|
|
248
|
-
<a
|
|
249
|
-
class="pf-c-simple-list__item-link"
|
|
250
|
-
href=""
|
|
251
|
-
tabindex="0"
|
|
252
|
-
>
|
|
253
|
-
Item 1
|
|
254
|
-
</a>
|
|
255
|
-
</li>
|
|
256
|
-
<li
|
|
257
|
-
class=""
|
|
258
|
-
>
|
|
259
|
-
<a
|
|
260
|
-
class="pf-c-simple-list__item-link"
|
|
261
|
-
href=""
|
|
262
|
-
tabindex="0"
|
|
263
|
-
>
|
|
264
|
-
Item 2
|
|
265
|
-
</a>
|
|
266
|
-
</li>
|
|
267
|
-
<li
|
|
268
|
-
class=""
|
|
269
|
-
>
|
|
270
|
-
<a
|
|
271
|
-
class="pf-c-simple-list__item-link"
|
|
272
|
-
href=""
|
|
273
|
-
tabindex="0"
|
|
274
|
-
>
|
|
275
|
-
Item 3
|
|
276
|
-
</a>
|
|
277
|
-
</li>
|
|
278
|
-
</ul>
|
|
279
|
-
</div>
|
|
280
|
-
</div>
|
|
281
|
-
`;
|
|
282
|
-
|
|
283
3
|
exports[`SimpleList renders content 1`] = `
|
|
284
|
-
<
|
|
4
|
+
<DocumentFragment>
|
|
285
5
|
<div
|
|
286
6
|
class="pf-c-simple-list"
|
|
287
7
|
>
|
|
@@ -318,11 +38,11 @@ exports[`SimpleList renders content 1`] = `
|
|
|
318
38
|
</li>
|
|
319
39
|
</ul>
|
|
320
40
|
</div>
|
|
321
|
-
</
|
|
41
|
+
</DocumentFragment>
|
|
322
42
|
`;
|
|
323
43
|
|
|
324
44
|
exports[`SimpleList renders grouped content 1`] = `
|
|
325
|
-
<
|
|
45
|
+
<DocumentFragment>
|
|
326
46
|
<div
|
|
327
47
|
class="pf-c-simple-list"
|
|
328
48
|
>
|
|
@@ -373,87 +93,5 @@ exports[`SimpleList renders grouped content 1`] = `
|
|
|
373
93
|
</ul>
|
|
374
94
|
</section>
|
|
375
95
|
</div>
|
|
376
|
-
</
|
|
377
|
-
`;
|
|
378
|
-
|
|
379
|
-
exports[`SimpleListGroup renders content 1`] = `
|
|
380
|
-
<div>
|
|
381
|
-
<section
|
|
382
|
-
class="pf-c-simple-list__section"
|
|
383
|
-
>
|
|
384
|
-
<h2
|
|
385
|
-
aria-hidden="true"
|
|
386
|
-
class="pf-c-simple-list__title"
|
|
387
|
-
id=""
|
|
388
|
-
>
|
|
389
|
-
Group 1
|
|
390
|
-
</h2>
|
|
391
|
-
<ul
|
|
392
|
-
aria-labelledby=""
|
|
393
|
-
class=""
|
|
394
|
-
>
|
|
395
|
-
<li
|
|
396
|
-
class=""
|
|
397
|
-
>
|
|
398
|
-
<button
|
|
399
|
-
class="pf-c-simple-list__item-link"
|
|
400
|
-
type="button"
|
|
401
|
-
>
|
|
402
|
-
Item 1
|
|
403
|
-
</button>
|
|
404
|
-
</li>
|
|
405
|
-
<li
|
|
406
|
-
class=""
|
|
407
|
-
>
|
|
408
|
-
<button
|
|
409
|
-
class="pf-c-simple-list__item-link"
|
|
410
|
-
type="button"
|
|
411
|
-
>
|
|
412
|
-
Item 2
|
|
413
|
-
</button>
|
|
414
|
-
</li>
|
|
415
|
-
<li
|
|
416
|
-
class=""
|
|
417
|
-
>
|
|
418
|
-
<button
|
|
419
|
-
class="pf-c-simple-list__item-link"
|
|
420
|
-
type="button"
|
|
421
|
-
>
|
|
422
|
-
Item 3
|
|
423
|
-
</button>
|
|
424
|
-
</li>
|
|
425
|
-
</ul>
|
|
426
|
-
</section>
|
|
427
|
-
</div>
|
|
428
|
-
`;
|
|
429
|
-
|
|
430
|
-
exports[`SimpleListItem renders anchor 1`] = `
|
|
431
|
-
<div>
|
|
432
|
-
<li
|
|
433
|
-
class=""
|
|
434
|
-
>
|
|
435
|
-
<a
|
|
436
|
-
class="pf-c-simple-list__item-link"
|
|
437
|
-
href=""
|
|
438
|
-
tabindex="0"
|
|
439
|
-
>
|
|
440
|
-
Item 1
|
|
441
|
-
</a>
|
|
442
|
-
</li>
|
|
443
|
-
</div>
|
|
444
|
-
`;
|
|
445
|
-
|
|
446
|
-
exports[`SimpleListItem renders content 1`] = `
|
|
447
|
-
<div>
|
|
448
|
-
<li
|
|
449
|
-
class=""
|
|
450
|
-
>
|
|
451
|
-
<button
|
|
452
|
-
class="pf-c-simple-list__item-link"
|
|
453
|
-
type="button"
|
|
454
|
-
>
|
|
455
|
-
Item 1
|
|
456
|
-
</button>
|
|
457
|
-
</li>
|
|
458
|
-
</div>
|
|
96
|
+
</DocumentFragment>
|
|
459
97
|
`;
|
|
@@ -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 { Switch } from '../Switch';
|
|
5
8
|
|
|
6
9
|
const props = {
|
|
@@ -8,90 +11,97 @@ const props = {
|
|
|
8
11
|
isChecked: false
|
|
9
12
|
};
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
expect(view.find('label').prop('htmlFor')).toBe('foo');
|
|
15
|
-
});
|
|
14
|
+
describe('Switch', () => {
|
|
15
|
+
test('switch label for attribute equals input id attribute', () => {
|
|
16
|
+
render(<Switch id="foo" aria-label="Switch label" />);
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
const view = mount(<Switch aria-label="..." />);
|
|
19
|
-
expect(view.find('input').prop('id')).toBeDefined();
|
|
20
|
-
});
|
|
18
|
+
const switchElement = screen.getByLabelText('Switch label');
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
20
|
+
expect(switchElement).toHaveAttribute('id', 'foo');
|
|
21
|
+
expect(switchElement.parentElement).toHaveAttribute('for', 'foo');
|
|
22
|
+
});
|
|
26
23
|
|
|
27
|
-
test('switch is
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
24
|
+
test('switch label id is auto generated', () => {
|
|
25
|
+
render(<Switch aria-label="Switch label" />);
|
|
26
|
+
expect(screen.getByLabelText('Switch label')).toHaveAttribute('id');
|
|
27
|
+
});
|
|
31
28
|
|
|
32
|
-
test('switch
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
});
|
|
29
|
+
test('switch is checked', () => {
|
|
30
|
+
const { asFragment } = render(<Switch id="switch-is-checked" label="On" labelOff="Off" isChecked aria-label="Switch label" />);
|
|
31
|
+
expect(asFragment()).toMatchSnapshot();
|
|
32
|
+
});
|
|
37
33
|
|
|
38
|
-
test('switch
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
34
|
+
test('switch is not checked', () => {
|
|
35
|
+
const { asFragment } = render(<Switch id="switch-is-not-checked" label="On" labelOff="Off" isChecked={false} aria-label="Switch label" />);
|
|
36
|
+
expect(asFragment()).toMatchSnapshot();
|
|
37
|
+
});
|
|
43
38
|
|
|
44
|
-
test('
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
});
|
|
39
|
+
test('switch with only label is checked', () => {
|
|
40
|
+
const { asFragment } = render(<Switch id="switch-is-checked" label="On" isChecked={true} />);
|
|
41
|
+
expect(asFragment()).toMatchSnapshot();
|
|
42
|
+
});
|
|
48
43
|
|
|
49
|
-
test('
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
});
|
|
44
|
+
test('switch with only label is not checked', () => {
|
|
45
|
+
const { asFragment } = render(<Switch id="switch-is-not-checked" label="Off" isChecked={false} />);
|
|
46
|
+
expect(asFragment()).toMatchSnapshot();
|
|
47
|
+
});
|
|
53
48
|
|
|
54
|
-
test('switch is checked
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
});
|
|
49
|
+
test('no label switch is checked', () => {
|
|
50
|
+
const { asFragment } = render(<Switch id="no-label-switch-is-checked" isChecked aria-label="Switch label" />);
|
|
51
|
+
expect(asFragment()).toMatchSnapshot();
|
|
52
|
+
});
|
|
58
53
|
|
|
59
|
-
test('switch is not checked
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
});
|
|
54
|
+
test('no label switch is not checked', () => {
|
|
55
|
+
const { asFragment } = render(<Switch id="no-label-switch-is-not-checked" isChecked={false} aria-label="Switch label" />);
|
|
56
|
+
expect(asFragment()).toMatchSnapshot();
|
|
57
|
+
});
|
|
63
58
|
|
|
64
|
-
test('switch
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
input.simulate('change', { target: { checked: true } });
|
|
69
|
-
expect(props.onChange.mock.calls[0][0]).toBe(true);
|
|
70
|
-
});
|
|
59
|
+
test('switch is checked and disabled', () => {
|
|
60
|
+
const { asFragment } = render(<Switch id="switch-is-checked-and-disabled" isChecked isDisabled aria-label="Switch label" />);
|
|
61
|
+
expect(asFragment()).toMatchSnapshot();
|
|
62
|
+
});
|
|
71
63
|
|
|
72
|
-
test('
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
expect(myMock).toBeCalled();
|
|
77
|
-
});
|
|
64
|
+
test('switch is not checked and disabled', () => {
|
|
65
|
+
const { asFragment } = render(<Switch id="switch-is-not-checked-and-disabled" isChecked={false} isDisabled aria-label="Switch label" />);
|
|
66
|
+
expect(asFragment()).toMatchSnapshot();
|
|
67
|
+
});
|
|
78
68
|
|
|
79
|
-
test('
|
|
80
|
-
|
|
81
|
-
global.console = { ...global.console, error: myMock };
|
|
82
|
-
mount(<Switch {...props} label="test switch" />);
|
|
83
|
-
expect(myMock).not.toBeCalled();
|
|
84
|
-
});
|
|
69
|
+
test('switch passes value and event to onChange handler', () => {
|
|
70
|
+
render(<Switch id="onChange-switch" {...props} aria-label="Switch label" />);
|
|
85
71
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
72
|
+
userEvent.click(screen.getByLabelText('Switch label'));
|
|
73
|
+
expect(props.onChange).toHaveBeenCalledWith(true, expect.any(Object));
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('should throw console error when no aria-label or label is given', () => {
|
|
77
|
+
const myMock = jest.fn();
|
|
78
|
+
|
|
79
|
+
global.console = { ...global.console, error: myMock };
|
|
80
|
+
|
|
81
|
+
render(<Switch {...props} />);
|
|
82
|
+
expect(myMock).toBeCalled();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('should not throw console error when label is given but no aria-label', () => {
|
|
86
|
+
const myMock = jest.fn();
|
|
87
|
+
global.console = { ...global.console, error: myMock };
|
|
92
88
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
89
|
+
render(<Switch {...props} label="test switch" />);
|
|
90
|
+
|
|
91
|
+
expect(myMock).not.toBeCalled();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test('should not throw console error when aria-label is given but no label', () => {
|
|
95
|
+
const myMock = jest.fn();
|
|
96
|
+
global.console = { ...global.console, error: myMock };
|
|
97
|
+
|
|
98
|
+
render(<Switch {...props} aria-label="test switch" />);
|
|
99
|
+
|
|
100
|
+
expect(myMock).not.toBeCalled();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('should apply reversed modifier', () => {
|
|
104
|
+
render(<Switch id="reversed-switch" label="reversed switch" isReversed aria-label="Switch label" />);
|
|
105
|
+
expect(screen.getByLabelText('Switch label').parentElement).toHaveClass('pf-m-reverse');
|
|
106
|
+
});
|
|
107
|
+
});
|