@patternfly/react-core 4.199.2 → 4.199.3

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.
Files changed (31) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/umd/react-core.min.css +219 -219
  3. package/package.json +5 -5
  4. package/src/components/AboutModal/__tests__/AboutModal.test.tsx +41 -60
  5. package/src/components/Accordion/__tests__/Accordion.test.tsx +23 -17
  6. package/src/components/Alert/__tests__/Alert.test.tsx +195 -184
  7. package/src/components/Alert/__tests__/Generated/AlertActionCloseButton.test.tsx +19 -17
  8. package/src/components/Alert/__tests__/Generated/__snapshots__/AlertActionCloseButton.test.tsx.snap +26 -4
  9. package/src/components/Alert/__tests__/__snapshots__/Alert.test.tsx.snap +50 -700
  10. package/src/components/AlertGroup/__tests__/AlertGroup.test.tsx +68 -73
  11. package/src/components/AlertGroup/__tests__/__snapshots__/AlertGroup.test.tsx.snap +1 -893
  12. package/src/components/ApplicationLauncher/__tests__/Generated/ApplicationLauncherSeparator.test.tsx +13 -10
  13. package/src/components/ApplicationLauncher/__tests__/Generated/__snapshots__/ApplicationLauncherSeparator.test.tsx.snap +12 -1
  14. package/src/components/Button/__tests__/Button.test.tsx +116 -107
  15. package/src/components/Button/__tests__/__snapshots__/Button.test.tsx.snap +21 -21
  16. package/src/components/Card/__tests__/Card.test.tsx +119 -100
  17. package/src/components/Card/__tests__/CardBody.test.tsx +35 -28
  18. package/src/components/Card/__tests__/CardFooter.test.tsx +28 -24
  19. package/src/components/Card/__tests__/CardHeadMain.test.tsx +19 -14
  20. package/src/components/Card/__tests__/CardHeader.test.tsx +6 -22
  21. package/src/components/Card/__tests__/CardHeaderMain.test.tsx +19 -14
  22. package/src/components/Card/__tests__/CardTitle.test.tsx +25 -0
  23. package/src/components/Card/__tests__/__snapshots__/Card.test.tsx.snap +12 -28
  24. package/src/components/Card/__tests__/__snapshots__/CardBody.test.tsx.snap +2 -4
  25. package/src/components/Card/__tests__/__snapshots__/CardFooter.test.tsx.snap +1 -3
  26. package/src/components/Card/__tests__/__snapshots__/CardHeadMain.test.tsx.snap +1 -11
  27. package/src/components/Card/__tests__/__snapshots__/CardHeader.test.tsx.snap +1 -11
  28. package/src/components/Card/__tests__/__snapshots__/CardHeaderMain.test.tsx.snap +1 -11
  29. package/src/components/Card/__tests__/__snapshots__/CardTitle.test.tsx.snap +3 -0
  30. package/src/components/Checkbox/__tests__/Checkbox.test.tsx +66 -70
  31. package/src/components/Checkbox/__tests__/__snapshots__/Checkbox.test.tsx.snap +9 -204
@@ -1,86 +1,82 @@
1
- import * as React from 'react';
2
- import { render } from '@testing-library/react';
3
- import { shallow } from 'enzyme';
1
+ import React from 'react';
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 { Checkbox } from '../Checkbox';
5
8
 
6
- const props = {
7
- onChange: jest.fn(),
8
- isChecked: false
9
- };
9
+ describe('Checkbox', () => {
10
+ test('controlled', () => {
11
+ render(<Checkbox isChecked id="check" aria-label="check" />);
12
+ expect(screen.getByRole('checkbox').outerHTML).toMatchSnapshot();
13
+ });
10
14
 
11
- test('controlled', () => {
12
- const view = render(<Checkbox isChecked id="check" aria-label="check" />);
13
- expect(view.container).toMatchSnapshot();
14
- });
15
+ test('controlled - 3rd state', () => {
16
+ render(<Checkbox isChecked={null} id="check" aria-label="check" />);
17
+ expect(screen.getByRole('checkbox').outerHTML).toMatchSnapshot();
18
+ });
15
19
 
16
- test('controlled - 3rd state', () => {
17
- const view = render(<Checkbox isChecked={null} id="check" aria-label="check" />);
18
- expect(view.container).toMatchSnapshot();
19
- });
20
+ test('uncontrolled', () => {
21
+ render(<Checkbox id="check" aria-label="check" />);
22
+ expect(screen.getByRole('checkbox').outerHTML).toMatchSnapshot();
23
+ });
20
24
 
21
- test('uncontrolled', () => {
22
- const view = render(<Checkbox id="check" aria-label="check" />);
23
- expect(view.container).toMatchSnapshot();
24
- });
25
+ test('isDisabled', () => {
26
+ render(<Checkbox id="check" isDisabled aria-label="check" />);
27
+ expect(screen.getByRole('checkbox').outerHTML).toMatchSnapshot();
28
+ });
25
29
 
26
- test('isDisabled', () => {
27
- const view = render(<Checkbox id="check" isDisabled aria-label="check" />);
28
- expect(view.container).toMatchSnapshot();
29
- });
30
+ test('label is string', () => {
31
+ render(<Checkbox label="Label" id="check" isChecked aria-label="check" />);
32
+ expect(screen.getByRole('checkbox').outerHTML).toMatchSnapshot();
33
+ });
30
34
 
31
- test('label is string', () => {
32
- const view = render(<Checkbox label="Label" id="check" isChecked aria-label="check" />);
33
- expect(view.container).toMatchSnapshot();
34
- });
35
+ test('label is function', () => {
36
+ const functionLabel = () => <h1>Header</h1>;
37
+ render(<Checkbox label={functionLabel()} id="check" isChecked aria-label="check" />);
38
+ expect(screen.getByRole('checkbox').outerHTML).toMatchSnapshot();
39
+ });
35
40
 
36
- test('label is function', () => {
37
- const functionLabel = () => <h1>Header</h1>;
38
- const view = render(<Checkbox label={functionLabel()} id="check" isChecked aria-label="check" />);
39
- expect(view.container).toMatchSnapshot();
40
- });
41
+ test('label is node', () => {
42
+ render(<Checkbox label={<h1>Header</h1>} id="check" isChecked aria-label="check" />);
43
+ expect(screen.getByRole('checkbox').outerHTML).toMatchSnapshot();
44
+ });
41
45
 
42
- test('label is node', () => {
43
- const view = render(<Checkbox label={<h1>Header</h1>} id="check" isChecked aria-label="check" />);
44
- expect(view.container).toMatchSnapshot();
45
- });
46
+ test('passing class', () => {
47
+ render(<Checkbox label="label" className="class-123" id="check" isChecked aria-label="check" />);
48
+ expect(screen.getByRole('checkbox').outerHTML).toMatchSnapshot();
49
+ });
46
50
 
47
- test('passing class', () => {
48
- const view = render(<Checkbox label="label" className="class-123" id="check" isChecked aria-label="check" />);
49
- expect(view.container).toMatchSnapshot();
50
- });
51
+ test('passing HTML attribute', () => {
52
+ render(<Checkbox label="label" aria-labelledby="labelId" id="check" isChecked aria-label="check" />);
53
+ expect(screen.getByRole('checkbox').outerHTML).toMatchSnapshot();
54
+ });
51
55
 
52
- test('passing HTML attribute', () => {
53
- const view = render(<Checkbox label="label" aria-labelledby="labelId" id="check" isChecked aria-label="check" />);
54
- expect(view.container).toMatchSnapshot();
55
- });
56
+ test('passing description', () => {
57
+ render(<Checkbox id="check" label="checkbox" description="Text description..." />);
58
+ expect(screen.getByText('Text description...')).toBeInTheDocument();
59
+ });
56
60
 
57
- test('passing description', () => {
58
- const view = shallow(<Checkbox id="check" label="checkbox" description="Text description..." />);
59
- const descriptionEl = view.find('span[className="pf-c-check__description"]');
60
- expect(descriptionEl.length).toBe(1);
61
- expect(descriptionEl.text()).toBe('Text description...');
62
- });
61
+ test('passing body', () => {
62
+ render(<Checkbox id="check" label="checkbox" body="This is where custom content goes." />);
63
63
 
64
- test('passing body', () => {
65
- const view = shallow(<Checkbox id="check" label="checkbox" body="This is where custom content goes." />);
66
- const bodyEl = view.find('span[className="pf-c-check__body"]');
67
- expect(bodyEl.length).toBe(1);
68
- expect(bodyEl.text()).toBe('This is where custom content goes.');
69
- });
64
+ expect(screen.getByText('This is where custom content goes.')).toBeInTheDocument();
65
+ });
70
66
 
71
- test('checkbox passes value and event to onChange handler', () => {
72
- const newValue = true;
73
- const event = {
74
- currentTarget: { checked: newValue }
75
- };
76
- const view = shallow(<Checkbox id="check" {...props} aria-label="check" />);
77
- view.find('input').simulate('change', event);
78
- expect(props.onChange).toBeCalledWith(newValue, event);
79
- });
67
+ test('checkbox onChange handler called when component is clicked', () => {
68
+ const onChangeHandler = jest.fn();
69
+ render(<Checkbox id="check" onChange={onChangeHandler} aria-label="check" isChecked={false} />);
70
+
71
+ userEvent.click(screen.getByLabelText('check'));
72
+ expect(onChangeHandler).toBeCalled();
73
+ });
74
+
75
+ test('should throw console error when no id is given', () => {
76
+ const myMock = jest.fn();
77
+ global.console = { ...global.console, error: myMock };
80
78
 
81
- test('should throw console error when no id is given', () => {
82
- const myMock = jest.fn();
83
- global.console = { ...global.console, error: myMock };
84
- render(<Checkbox {...props} />);
85
- expect(myMock).toBeCalled();
79
+ render(<Checkbox id={undefined} />);
80
+ expect(myMock).toBeCalled();
81
+ });
86
82
  });
@@ -1,214 +1,19 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`controlled - 3rd state 1`] = `
4
- <div>
5
- <div
6
- class="pf-c-check pf-m-standalone"
7
- >
8
- <input
9
- aria-invalid="false"
10
- aria-label="check"
11
- class="pf-c-check__input"
12
- data-ouia-component-id="OUIA-Generated-Checkbox-2"
13
- data-ouia-component-type="PF4/Checkbox"
14
- data-ouia-safe="true"
15
- id="check"
16
- type="checkbox"
17
- />
18
- </div>
19
- </div>
20
- `;
3
+ exports[`Checkbox controlled - 3rd state 1`] = `"<input id=\\"check\\" class=\\"pf-c-check__input\\" type=\\"checkbox\\" aria-invalid=\\"false\\" aria-label=\\"check\\" data-ouia-component-type=\\"PF4/Checkbox\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Checkbox-2\\">"`;
21
4
 
22
- exports[`controlled 1`] = `
23
- <div>
24
- <div
25
- class="pf-c-check pf-m-standalone"
26
- >
27
- <input
28
- aria-invalid="false"
29
- aria-label="check"
30
- checked=""
31
- class="pf-c-check__input"
32
- data-ouia-component-id="OUIA-Generated-Checkbox-1"
33
- data-ouia-component-type="PF4/Checkbox"
34
- data-ouia-safe="true"
35
- id="check"
36
- type="checkbox"
37
- />
38
- </div>
39
- </div>
40
- `;
5
+ exports[`Checkbox controlled 1`] = `"<input id=\\"check\\" class=\\"pf-c-check__input\\" type=\\"checkbox\\" aria-invalid=\\"false\\" aria-label=\\"check\\" data-ouia-component-type=\\"PF4/Checkbox\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Checkbox-1\\" checked=\\"\\">"`;
41
6
 
42
- exports[`isDisabled 1`] = `
43
- <div>
44
- <div
45
- class="pf-c-check pf-m-standalone"
46
- >
47
- <input
48
- aria-invalid="false"
49
- aria-label="check"
50
- class="pf-c-check__input"
51
- data-ouia-component-id="OUIA-Generated-Checkbox-4"
52
- data-ouia-component-type="PF4/Checkbox"
53
- data-ouia-safe="true"
54
- disabled=""
55
- id="check"
56
- type="checkbox"
57
- />
58
- </div>
59
- </div>
60
- `;
7
+ exports[`Checkbox isDisabled 1`] = `"<input id=\\"check\\" class=\\"pf-c-check__input\\" type=\\"checkbox\\" aria-invalid=\\"false\\" aria-label=\\"check\\" disabled=\\"\\" data-ouia-component-type=\\"PF4/Checkbox\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Checkbox-4\\">"`;
61
8
 
62
- exports[`label is function 1`] = `
63
- <div>
64
- <div
65
- class="pf-c-check"
66
- >
67
- <input
68
- aria-invalid="false"
69
- aria-label="check"
70
- checked=""
71
- class="pf-c-check__input"
72
- data-ouia-component-id="OUIA-Generated-Checkbox-6"
73
- data-ouia-component-type="PF4/Checkbox"
74
- data-ouia-safe="true"
75
- id="check"
76
- type="checkbox"
77
- />
78
- <label
79
- class="pf-c-check__label"
80
- for="check"
81
- >
82
- <h1>
83
- Header
84
- </h1>
85
- </label>
86
- </div>
87
- </div>
88
- `;
9
+ exports[`Checkbox label is function 1`] = `"<input id=\\"check\\" class=\\"pf-c-check__input\\" type=\\"checkbox\\" aria-invalid=\\"false\\" aria-label=\\"check\\" data-ouia-component-type=\\"PF4/Checkbox\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Checkbox-6\\" checked=\\"\\">"`;
89
10
 
90
- exports[`label is node 1`] = `
91
- <div>
92
- <div
93
- class="pf-c-check"
94
- >
95
- <input
96
- aria-invalid="false"
97
- aria-label="check"
98
- checked=""
99
- class="pf-c-check__input"
100
- data-ouia-component-id="OUIA-Generated-Checkbox-7"
101
- data-ouia-component-type="PF4/Checkbox"
102
- data-ouia-safe="true"
103
- id="check"
104
- type="checkbox"
105
- />
106
- <label
107
- class="pf-c-check__label"
108
- for="check"
109
- >
110
- <h1>
111
- Header
112
- </h1>
113
- </label>
114
- </div>
115
- </div>
116
- `;
11
+ exports[`Checkbox label is node 1`] = `"<input id=\\"check\\" class=\\"pf-c-check__input\\" type=\\"checkbox\\" aria-invalid=\\"false\\" aria-label=\\"check\\" data-ouia-component-type=\\"PF4/Checkbox\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Checkbox-7\\" checked=\\"\\">"`;
117
12
 
118
- exports[`label is string 1`] = `
119
- <div>
120
- <div
121
- class="pf-c-check"
122
- >
123
- <input
124
- aria-invalid="false"
125
- aria-label="check"
126
- checked=""
127
- class="pf-c-check__input"
128
- data-ouia-component-id="OUIA-Generated-Checkbox-5"
129
- data-ouia-component-type="PF4/Checkbox"
130
- data-ouia-safe="true"
131
- id="check"
132
- type="checkbox"
133
- />
134
- <label
135
- class="pf-c-check__label"
136
- for="check"
137
- >
138
- Label
139
- </label>
140
- </div>
141
- </div>
142
- `;
13
+ exports[`Checkbox label is string 1`] = `"<input id=\\"check\\" class=\\"pf-c-check__input\\" type=\\"checkbox\\" aria-invalid=\\"false\\" aria-label=\\"check\\" data-ouia-component-type=\\"PF4/Checkbox\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Checkbox-5\\" checked=\\"\\">"`;
143
14
 
144
- exports[`passing HTML attribute 1`] = `
145
- <div>
146
- <div
147
- class="pf-c-check"
148
- >
149
- <input
150
- aria-invalid="false"
151
- aria-label="check"
152
- aria-labelledby="labelId"
153
- checked=""
154
- class="pf-c-check__input"
155
- data-ouia-component-id="OUIA-Generated-Checkbox-9"
156
- data-ouia-component-type="PF4/Checkbox"
157
- data-ouia-safe="true"
158
- id="check"
159
- type="checkbox"
160
- />
161
- <label
162
- class="pf-c-check__label"
163
- for="check"
164
- >
165
- label
166
- </label>
167
- </div>
168
- </div>
169
- `;
15
+ exports[`Checkbox passing HTML attribute 1`] = `"<input aria-labelledby=\\"labelId\\" id=\\"check\\" class=\\"pf-c-check__input\\" type=\\"checkbox\\" aria-invalid=\\"false\\" aria-label=\\"check\\" data-ouia-component-type=\\"PF4/Checkbox\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Checkbox-9\\" checked=\\"\\">"`;
170
16
 
171
- exports[`passing class 1`] = `
172
- <div>
173
- <div
174
- class="pf-c-check class-123"
175
- >
176
- <input
177
- aria-invalid="false"
178
- aria-label="check"
179
- checked=""
180
- class="pf-c-check__input"
181
- data-ouia-component-id="OUIA-Generated-Checkbox-8"
182
- data-ouia-component-type="PF4/Checkbox"
183
- data-ouia-safe="true"
184
- id="check"
185
- type="checkbox"
186
- />
187
- <label
188
- class="pf-c-check__label"
189
- for="check"
190
- >
191
- label
192
- </label>
193
- </div>
194
- </div>
195
- `;
17
+ exports[`Checkbox passing class 1`] = `"<input id=\\"check\\" class=\\"pf-c-check__input\\" type=\\"checkbox\\" aria-invalid=\\"false\\" aria-label=\\"check\\" data-ouia-component-type=\\"PF4/Checkbox\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Checkbox-8\\" checked=\\"\\">"`;
196
18
 
197
- exports[`uncontrolled 1`] = `
198
- <div>
199
- <div
200
- class="pf-c-check pf-m-standalone"
201
- >
202
- <input
203
- aria-invalid="false"
204
- aria-label="check"
205
- class="pf-c-check__input"
206
- data-ouia-component-id="OUIA-Generated-Checkbox-3"
207
- data-ouia-component-type="PF4/Checkbox"
208
- data-ouia-safe="true"
209
- id="check"
210
- type="checkbox"
211
- />
212
- </div>
213
- </div>
214
- `;
19
+ exports[`Checkbox uncontrolled 1`] = `"<input id=\\"check\\" class=\\"pf-c-check__input\\" type=\\"checkbox\\" aria-invalid=\\"false\\" aria-label=\\"check\\" data-ouia-component-type=\\"PF4/Checkbox\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Checkbox-3\\">"`;