@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.
Files changed (105) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/esm/components/JumpLinks/JumpLinksItem.d.ts.map +1 -1
  3. package/dist/esm/components/JumpLinks/JumpLinksItem.js +1 -1
  4. package/dist/esm/components/JumpLinks/JumpLinksItem.js.map +1 -1
  5. package/dist/esm/components/ProgressStepper/ProgressStep.d.ts +3 -0
  6. package/dist/esm/components/ProgressStepper/ProgressStep.d.ts.map +1 -1
  7. package/dist/esm/components/ProgressStepper/ProgressStep.js +2 -2
  8. package/dist/esm/components/ProgressStepper/ProgressStep.js.map +1 -1
  9. package/dist/esm/components/Tabs/Tab.d.ts.map +1 -1
  10. package/dist/esm/components/Tabs/Tab.js +2 -2
  11. package/dist/esm/components/Tabs/Tab.js.map +1 -1
  12. package/dist/esm/components/Tabs/Tabs.d.ts +1 -1
  13. package/dist/esm/components/Tabs/Tabs.d.ts.map +1 -1
  14. package/dist/esm/components/Tabs/Tabs.js +1 -1
  15. package/dist/esm/components/Tabs/Tabs.js.map +1 -1
  16. package/dist/esm/helpers/Popper/Popper.d.ts.map +1 -1
  17. package/dist/esm/helpers/Popper/Popper.js +1 -7
  18. package/dist/esm/helpers/Popper/Popper.js.map +1 -1
  19. package/dist/js/components/JumpLinks/JumpLinksItem.d.ts.map +1 -1
  20. package/dist/js/components/JumpLinks/JumpLinksItem.js +1 -1
  21. package/dist/js/components/JumpLinks/JumpLinksItem.js.map +1 -1
  22. package/dist/js/components/ProgressStepper/ProgressStep.d.ts +3 -0
  23. package/dist/js/components/ProgressStepper/ProgressStep.d.ts.map +1 -1
  24. package/dist/js/components/ProgressStepper/ProgressStep.js +2 -2
  25. package/dist/js/components/ProgressStepper/ProgressStep.js.map +1 -1
  26. package/dist/js/components/Tabs/Tab.d.ts.map +1 -1
  27. package/dist/js/components/Tabs/Tab.js +2 -2
  28. package/dist/js/components/Tabs/Tab.js.map +1 -1
  29. package/dist/js/components/Tabs/Tabs.d.ts +1 -1
  30. package/dist/js/components/Tabs/Tabs.d.ts.map +1 -1
  31. package/dist/js/components/Tabs/Tabs.js +1 -1
  32. package/dist/js/components/Tabs/Tabs.js.map +1 -1
  33. package/dist/js/helpers/Popper/Popper.d.ts.map +1 -1
  34. package/dist/js/helpers/Popper/Popper.js +1 -7
  35. package/dist/js/helpers/Popper/Popper.js.map +1 -1
  36. package/dist/umd/react-core.js +7 -13
  37. package/dist/umd/react-core.min.js +1 -1
  38. package/package.json +5 -5
  39. package/src/components/Dropdown/__tests__/DropdownToggleCheckbox.test.tsx +1 -1
  40. package/src/components/ExpandableSection/examples/ExpandableSection.md +1 -1
  41. package/src/components/JumpLinks/JumpLinksItem.tsx +5 -1
  42. package/src/components/JumpLinks/__tests__/__snapshots__/JumpLinks.test.tsx.snap +5 -0
  43. package/src/components/Page/__tests__/Page.test.tsx +225 -205
  44. package/src/components/Page/__tests__/__snapshots__/Page.test.tsx.snap +1088 -2059
  45. package/src/components/Pagination/__tests__/Pagination.test.tsx +235 -283
  46. package/src/components/Pagination/__tests__/__snapshots__/Pagination.test.tsx.snap +143 -577
  47. package/src/components/ProgressStepper/ProgressStep.tsx +6 -0
  48. package/src/components/ProgressStepper/__tests__/__snapshots__/ProgressStepper.test.tsx.snap +1 -0
  49. package/src/components/ProgressStepper/examples/ProgressStepper.md +9 -9
  50. package/src/components/Radio/__tests__/Radio.test.tsx +38 -44
  51. package/src/components/Radio/__tests__/__snapshots__/Radio.test.tsx.snap +30 -30
  52. package/src/components/SearchInput/__tests__/SearchInput.test.tsx +87 -68
  53. package/src/components/SearchInput/__tests__/__snapshots__/SearchInput.test.tsx.snap +230 -137
  54. package/src/components/Select/__tests__/Select.test.tsx +238 -195
  55. package/src/components/Select/__tests__/SelectToggle.test.tsx +68 -130
  56. package/src/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +978 -2149
  57. package/src/components/Select/__tests__/__snapshots__/SelectToggle.test.tsx.snap +3 -3
  58. package/src/components/SimpleList/__tests__/SimpleList.test.tsx +29 -32
  59. package/src/components/SimpleList/__tests__/__snapshots__/SimpleList.test.tsx.snap +4 -366
  60. package/src/components/Switch/__tests__/Switch.test.tsx +85 -75
  61. package/src/components/Switch/__tests__/__snapshots__/Switch.test.tsx.snap +30 -40
  62. package/src/components/Tabs/Tab.tsx +6 -1
  63. package/src/components/Tabs/Tabs.tsx +2 -2
  64. package/src/components/Tabs/__tests__/Generated/__snapshots__/Tabs.test.tsx.snap +1 -0
  65. package/src/components/Tabs/__tests__/__snapshots__/Tab.test.tsx.snap +3 -0
  66. package/src/components/Tabs/__tests__/__snapshots__/Tabs.test.tsx.snap +135 -0
  67. package/src/components/Tabs/examples/Tabs.md +32 -26
  68. package/src/components/TextArea/__tests__/TextArea.test.tsx +98 -103
  69. package/src/components/TextArea/__tests__/__snapshots__/TextArea.test.tsx.snap +24 -103
  70. package/src/components/TextInput/__tests__/TextInput.test.tsx +71 -70
  71. package/src/components/TextInput/__tests__/__snapshots__/TextInput.test.tsx.snap +15 -103
  72. package/src/components/TextInputGroup/__tests__/TextInputGroup.test.tsx +65 -39
  73. package/src/components/TextInputGroup/__tests__/__snapshots__/TextInputGroup.test.tsx.snap +53 -14
  74. package/src/components/TimePicker/__tests__/TimePicker.test.tsx +113 -110
  75. package/src/components/Title/__tests__/Title.test.tsx +21 -20
  76. package/src/components/Title/__tests__/__snapshots__/Title.test.tsx.snap +24 -30
  77. package/src/components/ToggleGroup/__tests__/ToggleGroup.test.tsx +43 -39
  78. package/src/components/ToggleGroup/__tests__/__snapshots__/ToggleGroup.test.tsx.snap +20 -19
  79. package/src/components/Wizard/__tests__/Wizard.test.tsx +195 -189
  80. package/src/components/Wizard/__tests__/__snapshots__/Wizard.test.tsx.snap +131 -10
  81. package/src/helpers/Popper/Popper.tsx +5 -7
  82. package/src/helpers/__tests__/util.test.ts +113 -0
  83. package/src/layouts/Bullseye/__tests__/Bullseye.test.tsx +25 -25
  84. package/src/layouts/Bullseye/__tests__/__snapshots__/Bullseye.test.tsx.snap +3 -5
  85. package/src/layouts/Flex/__tests__/Flex.test.tsx +159 -96
  86. package/src/layouts/Flex/__tests__/__snapshots__/Flex.test.tsx.snap +9 -17
  87. package/src/components/Page/__tests__/Generated/Page.test.tsx +0 -28
  88. package/src/components/Page/__tests__/Generated/__snapshots__/Page.test.tsx.snap +0 -19
  89. package/src/components/Pagination/__tests__/Generated/Pagination.test.tsx +0 -58
  90. package/src/components/Pagination/__tests__/Generated/__snapshots__/Pagination.test.tsx.snap +0 -205
  91. package/src/components/Radio/__tests__/Generated/Radio.test.tsx +0 -29
  92. package/src/components/Radio/__tests__/Generated/__snapshots__/Radio.test.tsx.snap +0 -36
  93. package/src/components/Select/__tests__/Generated/Select.test.tsx +0 -49
  94. package/src/components/Select/__tests__/Generated/SelectToggle.test.tsx +0 -34
  95. package/src/components/Select/__tests__/Generated/__snapshots__/Select.test.tsx.snap +0 -48
  96. package/src/components/Select/__tests__/Generated/__snapshots__/SelectToggle.test.tsx.snap +0 -36
  97. package/src/components/SimpleList/__tests__/Generated/SimpleList.test.tsx +0 -22
  98. package/src/components/SimpleList/__tests__/Generated/__snapshots__/SimpleList.test.tsx.snap +0 -13
  99. package/src/components/Switch/__tests__/Generated/Switch.test.tsx +0 -24
  100. package/src/components/Switch/__tests__/Generated/__snapshots__/Switch.test.tsx.snap +0 -36
  101. package/src/components/TextArea/__tests__/Generated/TextArea.test.tsx +0 -23
  102. package/src/components/TextArea/__tests__/Generated/__snapshots__/TextArea.test.tsx.snap +0 -13
  103. package/src/components/Title/__tests__/Generated/Title.test.tsx +0 -13
  104. package/src/components/Title/__tests__/Generated/__snapshots__/Title.test.tsx.snap +0 -12
  105. package/src/helpers/__tests__/util.test.js +0 -235
@@ -26,6 +26,9 @@ export interface ProgressStepProps
26
26
  popover?: React.ReactNode;
27
27
  /** @hide Forwarded reference to title container */
28
28
  innerRef?: React.Ref<any>;
29
+ /** Accessible label for the progress step. Should communicate all information being communicated by the progress
30
+ * step's icon, including the variant and the completed status. */
31
+ 'aria-label'?: string;
29
32
  }
30
33
 
31
34
  const variantIcons = {
@@ -56,6 +59,7 @@ const ProgressStepBase: React.FunctionComponent<ProgressStepProps> = ({
56
59
  titleId,
57
60
  popover,
58
61
  innerRef,
62
+ 'aria-label': ariaLabel,
59
63
  ...props
60
64
  }: ProgressStepProps) => {
61
65
  const _icon = icon !== undefined ? icon : variantIcons[variant];
@@ -76,6 +80,8 @@ const ProgressStepBase: React.FunctionComponent<ProgressStepProps> = ({
76
80
  isCurrent && styles.modifiers.current,
77
81
  className
78
82
  )}
83
+ aria-label={ariaLabel}
84
+ {...(isCurrent && { 'aria-current': 'step' })}
79
85
  {...props}
80
86
  >
81
87
  <div className={css(styles.progressStepperStepConnector)}>
@@ -28,6 +28,7 @@ exports[`ProgressStep renders content 1`] = `
28
28
  exports[`ProgressStep renders current 1`] = `
29
29
  <div>
30
30
  <li
31
+ aria-current="step"
31
32
  class="pf-c-progress-stepper__step pf-m-current"
32
33
  >
33
34
  <div
@@ -33,7 +33,7 @@ import { ProgressStepper, ProgressStep } from '@patternfly/react-core';
33
33
  isCurrent
34
34
  id="basic-step2"
35
35
  titleId="basic-step2-title"
36
- aria-label="current step, step with info"
36
+ aria-label="step with info"
37
37
  >
38
38
  Second step
39
39
  </ProgressStep>
@@ -65,7 +65,7 @@ import { ProgressStepper, ProgressStep } from '@patternfly/react-core';
65
65
  description="This is the second thing to happen"
66
66
  id="basic-desc-step2"
67
67
  titleId="basic-desc-step2-title"
68
- aria-label="current step, step with info"
68
+ aria-label="step with info"
69
69
  >
70
70
  Second step
71
71
  </ProgressStep>
@@ -103,7 +103,7 @@ import { ProgressStepper, ProgressStep } from '@patternfly/react-core';
103
103
  description="This is the second thing to happen"
104
104
  id="center-desc-step2"
105
105
  titleId="center-desc-step2-title"
106
- aria-label="current step, step with info"
106
+ aria-label="step with info"
107
107
  >
108
108
  Second step
109
109
  </ProgressStep>
@@ -141,7 +141,7 @@ import { ProgressStepper, ProgressStep } from '@patternfly/react-core';
141
141
  description="This is the second thing to happen"
142
142
  id="vertical-desc-step2"
143
143
  titleId="vertical-desc-step2-title"
144
- aria-label="current step, step with info"
144
+ aria-label="step with info"
145
145
  >
146
146
  Second step
147
147
  </ProgressStep>
@@ -179,7 +179,7 @@ import { ProgressStepper, ProgressStep } from '@patternfly/react-core';
179
179
  isCurrent
180
180
  id="compact-step2"
181
181
  titleId="compact-step2-title"
182
- aria-label="current step, step with info"
182
+ aria-label="step with info"
183
183
  >
184
184
  Second step
185
185
  </ProgressStep>
@@ -225,7 +225,7 @@ import { ProgressStepper, ProgressStep } from '@patternfly/react-core';
225
225
  isCurrent
226
226
  id="basic-with-issue-step4"
227
227
  titleId="basic-with-issue-step4-title"
228
- aria-label="current step, step with info"
228
+ aria-label="step with info"
229
229
  >
230
230
  Fourth step
231
231
  </ProgressStep>
@@ -276,7 +276,7 @@ import { ProgressStepper, ProgressStep } from '@patternfly/react-core';
276
276
  isCurrent
277
277
  id="basic-with-failure-step4"
278
278
  titleId="basic-with-failure-step4-title"
279
- aria-label="current step, step with danger"
279
+ aria-label="step with danger"
280
280
  >
281
281
  Fourth step
282
282
  </ProgressStep>
@@ -313,7 +313,7 @@ import PendingIcon from '@patternfly/react-icons/dist/esm/icons/pending-icon';
313
313
  icon={<InProgressIcon />}
314
314
  id="custom-step2"
315
315
  titleId="custom-step2-title"
316
- aria-label="current step"
316
+ aria-label="in progress"
317
317
  >
318
318
  In process
319
319
  </ProgressStep>
@@ -384,7 +384,7 @@ PopoverProgressStep = () => {
384
384
  variant="info"
385
385
  id="popover-step3"
386
386
  titleId="popover-step3-title"
387
- aria-label="current step with popover"
387
+ aria-label="step with popover"
388
388
  popover={
389
389
  <Popover
390
390
  aria-label="Third step help"
@@ -1,96 +1,90 @@
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 { Radio } from '../Radio';
5
8
 
6
9
  const props = {
7
10
  onChange: jest.fn()
8
11
  };
9
12
 
10
- describe('Radio check component', () => {
13
+ describe('Radio', () => {
11
14
  test('controlled', () => {
12
- const view = render(<Radio isChecked id="check" aria-label="check" name="check" />);
13
- expect(view.container).toMatchSnapshot();
15
+ const { asFragment } = render(<Radio isChecked id="check" aria-label="check" name="check" />);
16
+ expect(asFragment()).toMatchSnapshot();
14
17
  });
15
18
 
16
19
  test('uncontrolled', () => {
17
- const view = render(<Radio id="check" aria-label="check" name="check" />);
18
- expect(view.container).toMatchSnapshot();
20
+ const { asFragment } = render(<Radio id="check" aria-label="check" name="check" />);
21
+ expect(asFragment()).toMatchSnapshot();
19
22
  });
20
23
 
21
24
  test('isDisabled', () => {
22
- const view = render(<Radio id="check" isDisabled aria-label="check" name="check" />);
23
- expect(view.container).toMatchSnapshot();
25
+ const { asFragment } = render(<Radio id="check" isDisabled aria-label="check" name="check" />);
26
+ expect(asFragment()).toMatchSnapshot();
24
27
  });
25
28
 
26
29
  test('isLabelBeforeButton', () => {
27
- const view = render(<Radio id="check" isLabelBeforeButton label="Radio label" aria-label="check" name="check" />);
28
- expect(view.container).toMatchSnapshot();
30
+ const { asFragment } = render(<Radio id="check" isLabelBeforeButton label="Radio label" aria-label="check" name="check" />);
31
+ expect(asFragment()).toMatchSnapshot();
29
32
  });
30
33
 
31
34
  test('isLabelWrapped', () => {
32
- const view = render(<Radio id="check" isLabelWrapped label="Radio label" aria-label="check" name="check" />);
33
- expect(view.container).toMatchSnapshot();
35
+ const { asFragment } = render(<Radio id="check" isLabelWrapped label="Radio label" aria-label="check" name="check" />);
36
+ expect(asFragment()).toMatchSnapshot();
34
37
  });
35
38
 
36
39
  test('label is string', () => {
37
- const view = render(<Radio label="Label" id="check" isChecked aria-label="check" name="check" />);
38
- expect(view.container).toMatchSnapshot();
40
+ const { asFragment } = render(<Radio label="Label" id="check" isChecked aria-label="check" name="check" />);
41
+ expect(asFragment()).toMatchSnapshot();
39
42
  });
40
43
 
41
44
  test('label is function', () => {
42
45
  const functionLabel = () => <h1>Header</h1>;
43
- const view = render(<Radio label={functionLabel()} id="check" isChecked aria-label="check" name="check" />);
44
- expect(view.container).toMatchSnapshot();
46
+ const { asFragment } = render(<Radio label={functionLabel()} id="check" isChecked aria-label="check" name="check" />);
47
+ expect(asFragment()).toMatchSnapshot();
45
48
  });
46
49
 
47
50
  test('label is node', () => {
48
- const view = render(<Radio label={<h1>Header</h1>} id="check" isChecked aria-label="check" name="check" />);
49
- expect(view.container).toMatchSnapshot();
51
+ const { asFragment } = render(<Radio label={<h1>Header</h1>} id="check" isChecked aria-label="check" name="check" />);
52
+ expect(asFragment()).toMatchSnapshot();
50
53
  });
51
54
 
52
55
  test('passing class', () => {
53
- const view = render(
54
- <Radio label="label" className="class-123" id="check" isChecked aria-label="check" name="check" />
55
- );
56
- expect(view.container).toMatchSnapshot();
56
+ const { asFragment } = render(<Radio label="label" className="class-123" id="check" isChecked aria-label="check" name="check" />);
57
+ expect(asFragment()).toMatchSnapshot();
57
58
  });
58
59
 
59
60
  test('passing HTML attribute', () => {
60
- const view = render(
61
- <Radio label="label" aria-labelledby="labelId" id="check" isChecked aria-label="check" name="check" />
62
- );
63
- expect(view.container).toMatchSnapshot();
61
+ const { asFragment } = render(<Radio label="label" aria-labelledby="labelId" id="check" isChecked aria-label="check" name="check" />);
62
+ expect(asFragment()).toMatchSnapshot();
64
63
  });
65
64
 
66
65
  test('Radio passes value and event to onChange handler', () => {
67
- const newValue = true;
68
- const event = {
69
- currentTarget: { checked: newValue }
70
- };
71
- const view = shallow(<Radio id="check" {...props} aria-label="check" name="check" />);
72
- view.find('input').simulate('change', event);
73
- expect(props.onChange).toBeCalledWith(newValue, event);
66
+ render(<Radio id="check" {...props} aria-label="check" name="check" />);
67
+
68
+ userEvent.click(screen.getByRole('radio'));
69
+ expect(props.onChange).toHaveBeenCalledWith(true, expect.any(Object));
74
70
  });
75
71
 
76
72
  test('Radio description', () => {
77
- const view = shallow(<Radio id="check" name="check" aria-label="check" description="Text description..." />);
78
- const descriptionEl = view.find('span[className="pf-c-radio__description"]');
79
- expect(descriptionEl.length).toBe(1);
80
- expect(descriptionEl.text()).toBe('Text description...');
73
+ render(<Radio id="check" name="check" aria-label="check" description="Text description..." />);
74
+ expect(screen.getByText('Text description...')).toBeInTheDocument();
81
75
  });
82
76
 
83
77
  test('Radio body', () => {
84
- const view = shallow(<Radio id="check" name="check" aria-label="check" body="Text body..." />);
85
- const bodyEl = view.find('span[className="pf-c-radio__body"]');
86
- expect(bodyEl.length).toBe(1);
87
- expect(bodyEl.text()).toBe('Text body...');
78
+ render(<Radio id="check" name="check" aria-label="check" body="Text body..." />);
79
+ expect(screen.getByText('Text body...')).toBeInTheDocument();
88
80
  });
89
81
 
90
82
  test('should throw console error when no id is given', () => {
91
83
  const myMock = jest.fn();
92
84
  global.console = { ...global.console, error: myMock };
93
- shallow(<Radio name="check" aria-label="check" description="Text description..." />);
85
+
86
+ render(<Radio id={undefined} name="check" aria-label="check" description="Text description..." />);
87
+
94
88
  expect(myMock).toBeCalled();
95
89
  });
96
90
  });
@@ -1,7 +1,7 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`Radio check component controlled 1`] = `
4
- <div>
3
+ exports[`Radio controlled 1`] = `
4
+ <DocumentFragment>
5
5
  <div
6
6
  class="pf-c-radio pf-m-standalone"
7
7
  >
@@ -18,11 +18,11 @@ exports[`Radio check component controlled 1`] = `
18
18
  type="radio"
19
19
  />
20
20
  </div>
21
- </div>
21
+ </DocumentFragment>
22
22
  `;
23
23
 
24
- exports[`Radio check component isDisabled 1`] = `
25
- <div>
24
+ exports[`Radio isDisabled 1`] = `
25
+ <DocumentFragment>
26
26
  <div
27
27
  class="pf-c-radio pf-m-standalone"
28
28
  >
@@ -39,11 +39,11 @@ exports[`Radio check component isDisabled 1`] = `
39
39
  type="radio"
40
40
  />
41
41
  </div>
42
- </div>
42
+ </DocumentFragment>
43
43
  `;
44
44
 
45
- exports[`Radio check component isLabelBeforeButton 1`] = `
46
- <div>
45
+ exports[`Radio isLabelBeforeButton 1`] = `
46
+ <DocumentFragment>
47
47
  <div
48
48
  class="pf-c-radio"
49
49
  >
@@ -64,11 +64,11 @@ exports[`Radio check component isLabelBeforeButton 1`] = `
64
64
  type="radio"
65
65
  />
66
66
  </div>
67
- </div>
67
+ </DocumentFragment>
68
68
  `;
69
69
 
70
- exports[`Radio check component isLabelWrapped 1`] = `
71
- <div>
70
+ exports[`Radio isLabelWrapped 1`] = `
71
+ <DocumentFragment>
72
72
  <label
73
73
  class="pf-c-radio"
74
74
  for="check"
@@ -89,11 +89,11 @@ exports[`Radio check component isLabelWrapped 1`] = `
89
89
  Radio label
90
90
  </span>
91
91
  </label>
92
- </div>
92
+ </DocumentFragment>
93
93
  `;
94
94
 
95
- exports[`Radio check component label is function 1`] = `
96
- <div>
95
+ exports[`Radio label is function 1`] = `
96
+ <DocumentFragment>
97
97
  <div
98
98
  class="pf-c-radio"
99
99
  >
@@ -117,11 +117,11 @@ exports[`Radio check component label is function 1`] = `
117
117
  </h1>
118
118
  </label>
119
119
  </div>
120
- </div>
120
+ </DocumentFragment>
121
121
  `;
122
122
 
123
- exports[`Radio check component label is node 1`] = `
124
- <div>
123
+ exports[`Radio label is node 1`] = `
124
+ <DocumentFragment>
125
125
  <div
126
126
  class="pf-c-radio"
127
127
  >
@@ -145,11 +145,11 @@ exports[`Radio check component label is node 1`] = `
145
145
  </h1>
146
146
  </label>
147
147
  </div>
148
- </div>
148
+ </DocumentFragment>
149
149
  `;
150
150
 
151
- exports[`Radio check component label is string 1`] = `
152
- <div>
151
+ exports[`Radio label is string 1`] = `
152
+ <DocumentFragment>
153
153
  <div
154
154
  class="pf-c-radio"
155
155
  >
@@ -171,11 +171,11 @@ exports[`Radio check component label is string 1`] = `
171
171
  Label
172
172
  </label>
173
173
  </div>
174
- </div>
174
+ </DocumentFragment>
175
175
  `;
176
176
 
177
- exports[`Radio check component passing HTML attribute 1`] = `
178
- <div>
177
+ exports[`Radio passing HTML attribute 1`] = `
178
+ <DocumentFragment>
179
179
  <div
180
180
  class="pf-c-radio"
181
181
  >
@@ -198,11 +198,11 @@ exports[`Radio check component passing HTML attribute 1`] = `
198
198
  label
199
199
  </label>
200
200
  </div>
201
- </div>
201
+ </DocumentFragment>
202
202
  `;
203
203
 
204
- exports[`Radio check component passing class 1`] = `
205
- <div>
204
+ exports[`Radio passing class 1`] = `
205
+ <DocumentFragment>
206
206
  <div
207
207
  class="pf-c-radio class-123"
208
208
  >
@@ -224,11 +224,11 @@ exports[`Radio check component passing class 1`] = `
224
224
  label
225
225
  </label>
226
226
  </div>
227
- </div>
227
+ </DocumentFragment>
228
228
  `;
229
229
 
230
- exports[`Radio check component uncontrolled 1`] = `
231
- <div>
230
+ exports[`Radio uncontrolled 1`] = `
231
+ <DocumentFragment>
232
232
  <div
233
233
  class="pf-c-radio pf-m-standalone"
234
234
  >
@@ -244,5 +244,5 @@ exports[`Radio check component uncontrolled 1`] = `
244
244
  type="radio"
245
245
  />
246
246
  </div>
247
- </div>
247
+ </DocumentFragment>
248
248
  `;
@@ -1,6 +1,9 @@
1
1
  import React from 'react';
2
- import { render } from '@testing-library/react';
3
- import { mount } from 'enzyme';
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 { SearchInput } from '../SearchInput';
5
8
  import { FormGroup } from '../../Form';
6
9
  import { Button } from '../../Button';
@@ -15,76 +18,92 @@ const props = {
15
18
  onSearch: jest.fn()
16
19
  };
17
20
 
18
- test('simple search input', () => {
19
- const view = render(<SearchInput {...props} aria-label="simple text input" />);
20
- expect(view.container).toMatchSnapshot();
21
- });
21
+ describe('SearchInput', () => {
22
+ test('simple search input', () => {
23
+ const { asFragment } = render(<SearchInput {...props} aria-label="simple text input" />);
24
+ expect(asFragment()).toMatchSnapshot();
25
+ });
22
26
 
23
- test('search input with hint', () => {
24
- const view = render(<SearchInput {...props} hint="test hint" aria-label="simple text input" />);
25
- expect(view.container).toMatchSnapshot();
26
- });
27
+ test('search input with hint', () => {
28
+ const { asFragment } = render(<SearchInput {...props} hint="test hint" aria-label="simple text input" />);
29
+ expect(asFragment()).toMatchSnapshot();
30
+ });
27
31
 
28
- test('result count', () => {
29
- const view = mount(<SearchInput {...props} resultsCount={3} aria-label="simple text input" />);
30
- expect(view.find('.pf-c-badge')).toMatchSnapshot();
31
- });
32
+ test('result count', () => {
33
+ render(<SearchInput {...props} resultsCount={3} aria-label="simple text input" data-testid="test-id" />);
34
+ expect(screen.getByTestId('test-id').querySelector('.pf-c-badge')).toBeInTheDocument();
35
+ });
32
36
 
33
- test('navigable search results', () => {
34
- const view = mount(
35
- <SearchInput
36
- {...props}
37
- resultsCount='3 / 7'
38
- aria-label="simple text input"
39
- />);
40
- expect(view.find('.pf-c-search-input__nav')).toMatchSnapshot();
41
- expect(view.find('.pf-c-badge')).toMatchSnapshot();
42
-
43
- view.find('.pf-c-button').at(0).simulate('click', {});
44
- expect(props.onPreviousClick).toBeCalled();
45
- view.find('.pf-c-button').at(1).simulate('click', {});
46
- expect(props.onNextClick).toBeCalled();
47
- view.find('.pf-c-button').at(2).simulate('click', {});
48
- expect(props.onClear).toBeCalled();
49
- });
37
+ test('navigable search results', () => {
38
+ render(<SearchInput {...props} resultsCount="3 / 7" aria-label="simple text input" data-testid="test-id" />);
50
39
 
51
- test('hide clear button', () => {
52
- const { onClear, ...testProps } = props;
53
- const view = mount(
54
- <SearchInput {...testProps} resultsCount='3' aria-label="simple text input without on clear" />
55
- );
56
- expect(view.find('.pf-c-search-input__clear').length).toBe(0);
57
- });
40
+ const input = screen.getByTestId('test-id');
41
+ expect(input.querySelector('.pf-c-search-input__nav')).toBeInTheDocument();
42
+ expect(input.querySelector('.pf-c-badge')).toBeInTheDocument();
58
43
 
59
- test('advanced search', () => {
60
- const view = mount(
61
- <SearchInput
62
- attributes={[{attr:"username", display:"Username"}, {attr: "firstname", display: "First name"}]}
63
- advancedSearchDelimiter=":"
64
- value='username:player firstname:john'
65
- onChange={props.onChange}
66
- onSearch={props.onSearch}
67
- onClear={props.onClear}
68
- />
69
- );
70
- view.find('.pf-c-button').at(2).simulate('click', {});
71
- expect(props.onSearch).toBeCalled();
72
- expect(view.find('input')).toMatchSnapshot();
73
- });
44
+ userEvent.click(screen.getByRole('button', { name: 'Previous' }));
45
+ expect(props.onPreviousClick).toBeCalled();
46
+
47
+ userEvent.click(screen.getByRole('button', { name: 'Next' }));
48
+ expect(props.onNextClick).toBeCalled();
49
+
50
+ userEvent.click(screen.getByRole('button', { name: 'Reset' }));
51
+ expect(props.onClear).toBeCalled();
52
+ });
53
+
54
+ test('hide clear button', () => {
55
+ const { onClear, ...testProps } = props;
56
+
57
+ render(<SearchInput {...testProps} resultsCount="3" aria-label="simple text input without on clear" />);
58
+ expect(screen.queryByRole('button', { name: 'Reset' })).not.toBeInTheDocument();
59
+ });
60
+
61
+ test('advanced search', () => {
62
+ const { asFragment } = render(
63
+ <SearchInput
64
+ attributes={[
65
+ { attr: 'username', display: 'Username' },
66
+ { attr: 'firstname', display: 'First name' }
67
+ ]}
68
+ advancedSearchDelimiter=":"
69
+ value="username:player firstname:john"
70
+ onChange={props.onChange}
71
+ onSearch={props.onSearch}
72
+ onClear={props.onClear}
73
+ />
74
+ );
75
+
76
+ userEvent.click(screen.getByRole('button', { name: 'Search' }));
77
+
78
+ expect(props.onSearch).toBeCalled();
79
+ expect(asFragment()).toMatchSnapshot();
80
+ });
81
+
82
+ test('advanced search with custom attributes', () => {
83
+ const { asFragment } = render(
84
+ <SearchInput
85
+ attributes={[
86
+ { attr: 'username', display: 'Username' },
87
+ { attr: 'firstname', display: 'First name' }
88
+ ]}
89
+ advancedSearchDelimiter=":"
90
+ formAdditionalItems={
91
+ <FormGroup fieldId="test-form-group">
92
+ <Button variant="link" isInline icon={<ExternalLinkSquareAltIcon />} iconPosition="right">
93
+ Link
94
+ </Button>
95
+ </FormGroup>
96
+ }
97
+ value="username:player firstname:john"
98
+ onChange={props.onChange}
99
+ onSearch={props.onSearch}
100
+ onClear={props.onClear}
101
+ />
102
+ );
103
+
104
+ userEvent.click(screen.getByRole('button', { name: 'Search' }));
74
105
 
75
- test('advanced search with custom attributes', () => {
76
- const view = mount(
77
- <SearchInput
78
- attributes={[{attr:"username", display:"Username"}, {attr: "firstname", display: "First name"}]}
79
- advancedSearchDelimiter=":"
80
- formAdditionalItems={<FormGroup fieldId='test-form-group'><Button variant="link" isInline icon={<ExternalLinkSquareAltIcon />} iconPosition="right">Link</Button></FormGroup>}
81
- value='username:player firstname:john'
82
- onChange={props.onChange}
83
- onSearch={props.onSearch}
84
- onClear={props.onClear}
85
- />
86
- );
87
- view.find('.pf-c-button').at(2).simulate('click', {});
88
- expect(props.onSearch).toBeCalled();
89
- expect(view.find('input')).toMatchSnapshot();
106
+ expect(props.onSearch).toBeCalled();
107
+ expect(asFragment()).toMatchSnapshot();
108
+ });
90
109
  });