@patternfly/react-core 4.202.10 → 4.202.13

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 (84) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/esm/components/Drawer/Drawer.d.ts +1 -0
  3. package/dist/esm/components/Drawer/Drawer.d.ts.map +1 -1
  4. package/dist/esm/components/Drawer/Drawer.js +3 -2
  5. package/dist/esm/components/Drawer/Drawer.js.map +1 -1
  6. package/dist/esm/components/Drawer/DrawerContent.d.ts.map +1 -1
  7. package/dist/esm/components/Drawer/DrawerContent.js +3 -2
  8. package/dist/esm/components/Drawer/DrawerContent.js.map +1 -1
  9. package/dist/esm/components/Drawer/DrawerPanelContent.d.ts +2 -2
  10. package/dist/esm/components/Drawer/DrawerPanelContent.d.ts.map +1 -1
  11. package/dist/esm/components/Drawer/DrawerPanelContent.js +65 -37
  12. package/dist/esm/components/Drawer/DrawerPanelContent.js.map +1 -1
  13. package/dist/esm/components/LoginPage/LoginFooterItem.d.ts.map +1 -1
  14. package/dist/esm/components/LoginPage/LoginFooterItem.js +1 -3
  15. package/dist/esm/components/LoginPage/LoginFooterItem.js.map +1 -1
  16. package/dist/esm/components/TextInput/TextInput.d.ts +1 -0
  17. package/dist/esm/components/TextInput/TextInput.d.ts.map +1 -1
  18. package/dist/esm/components/TextInput/TextInput.js +2 -1
  19. package/dist/esm/components/TextInput/TextInput.js.map +1 -1
  20. package/dist/js/components/Drawer/Drawer.d.ts +1 -0
  21. package/dist/js/components/Drawer/Drawer.d.ts.map +1 -1
  22. package/dist/js/components/Drawer/Drawer.js +3 -2
  23. package/dist/js/components/Drawer/Drawer.js.map +1 -1
  24. package/dist/js/components/Drawer/DrawerContent.d.ts.map +1 -1
  25. package/dist/js/components/Drawer/DrawerContent.js +3 -2
  26. package/dist/js/components/Drawer/DrawerContent.js.map +1 -1
  27. package/dist/js/components/Drawer/DrawerPanelContent.d.ts +2 -2
  28. package/dist/js/components/Drawer/DrawerPanelContent.d.ts.map +1 -1
  29. package/dist/js/components/Drawer/DrawerPanelContent.js +65 -37
  30. package/dist/js/components/Drawer/DrawerPanelContent.js.map +1 -1
  31. package/dist/js/components/LoginPage/LoginFooterItem.d.ts.map +1 -1
  32. package/dist/js/components/LoginPage/LoginFooterItem.js +1 -3
  33. package/dist/js/components/LoginPage/LoginFooterItem.js.map +1 -1
  34. package/dist/js/components/TextInput/TextInput.d.ts +1 -0
  35. package/dist/js/components/TextInput/TextInput.d.ts.map +1 -1
  36. package/dist/js/components/TextInput/TextInput.js +2 -1
  37. package/dist/js/components/TextInput/TextInput.js.map +1 -1
  38. package/dist/styles/assets/pficon/pficon.scss +6 -0
  39. package/dist/styles/assets/pficon/pficon.woff +0 -0
  40. package/dist/styles/assets/pficon/pficon.woff2 +0 -0
  41. package/dist/styles/base-no-reset.css +5 -0
  42. package/dist/styles/base.css +5 -0
  43. package/dist/umd/react-core.css +2 -1
  44. package/dist/umd/react-core.js +73 -45
  45. package/dist/umd/react-core.min.css +2 -1
  46. package/dist/umd/react-core.min.js +2 -2
  47. package/package.json +6 -6
  48. package/src/components/Drawer/Drawer.tsx +4 -2
  49. package/src/components/Drawer/DrawerContent.tsx +19 -15
  50. package/src/components/Drawer/DrawerPanelContent.tsx +110 -75
  51. package/src/components/Drawer/__tests__/Generated/DrawerContent.test.tsx +2 -2
  52. package/src/components/Drawer/__tests__/Generated/__snapshots__/DrawerContent.test.tsx.snap +88 -9
  53. package/src/components/Drawer/__tests__/Generated/__snapshots__/DrawerPanelContent.test.tsx.snap +1 -0
  54. package/src/components/Drawer/__tests__/__snapshots__/Drawer.test.tsx.snap +15 -2
  55. package/src/components/EmptyState/__tests__/EmptyState.test.tsx +46 -42
  56. package/src/components/EmptyState/__tests__/__snapshots__/EmptyState.test.tsx.snap +5 -130
  57. package/src/components/Form/__tests__/FormGroup.test.tsx +82 -57
  58. package/src/components/Form/__tests__/FormHelperText.test.tsx +42 -28
  59. package/src/components/Form/__tests__/__snapshots__/FormGroup.test.tsx.snap +51 -250
  60. package/src/components/Form/__tests__/__snapshots__/FormHelperText.test.tsx.snap +4 -44
  61. package/src/components/FormSelect/__tests__/FormSelect.test.tsx +131 -122
  62. package/src/components/FormSelect/__tests__/__snapshots__/FormSelect.test.tsx.snap +9 -301
  63. package/src/components/InputGroup/__tests__/InputGroup.test.tsx +17 -41
  64. package/src/components/InputGroup/__tests__/InputGroupText.test.tsx +17 -0
  65. package/src/components/Label/__tests__/Label.test.tsx +127 -68
  66. package/src/components/Label/__tests__/__snapshots__/Label.test.tsx.snap +26 -828
  67. package/src/components/LabelGroup/__tests__/LabelGroup.test.tsx +24 -20
  68. package/src/components/LabelGroup/__tests__/__snapshots__/LabelGroup.test.tsx.snap +10 -12
  69. package/src/components/LoginPage/LoginFooterItem.tsx +0 -2
  70. package/src/components/LoginPage/__tests__/LoginFooterItem.test.tsx +23 -24
  71. package/src/components/LoginPage/__tests__/LoginForm.test.tsx +40 -33
  72. package/src/components/LoginPage/__tests__/LoginMainBody.test.tsx +10 -16
  73. package/src/components/LoginPage/__tests__/LoginMainFooter.test.tsx +11 -17
  74. package/src/components/LoginPage/__tests__/LoginMainFooterBandItem.test.tsx +23 -24
  75. package/src/components/LoginPage/__tests__/LoginMainFooterLinksItem.test.tsx +20 -24
  76. package/src/components/LoginPage/__tests__/LoginMainHeader.test.tsx +14 -20
  77. package/src/components/LoginPage/__tests__/__snapshots__/LoginFooterItem.test.tsx.snap +3 -13
  78. package/src/components/LoginPage/__tests__/__snapshots__/LoginForm.test.tsx.snap +3 -415
  79. package/src/components/LoginPage/__tests__/__snapshots__/LoginMainBody.test.tsx.snap +2 -8
  80. package/src/components/LoginPage/__tests__/__snapshots__/LoginMainFooter.test.tsx.snap +2 -8
  81. package/src/components/LoginPage/__tests__/__snapshots__/LoginMainFooterBandItem.test.tsx.snap +3 -17
  82. package/src/components/LoginPage/__tests__/__snapshots__/LoginMainFooterLinksItem.test.tsx.snap +3 -31
  83. package/src/components/LoginPage/__tests__/__snapshots__/LoginMainHeader.test.tsx.snap +3 -12
  84. package/src/components/TextInput/TextInput.tsx +4 -1
@@ -1,6 +1,10 @@
1
1
  import React from 'react';
2
- import { render } from '@testing-library/react';
3
- import { shallow } 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
+
7
+ import { Form } from '../../Form';
4
8
  import { FormSelect } from '../FormSelect';
5
9
  import { FormSelectOption } from '../FormSelectOption';
6
10
  import { FormSelectOptionGroup } from '../FormSelectOptionGroup';
@@ -49,136 +53,141 @@ const groupedProps = {
49
53
  value: '2'
50
54
  };
51
55
 
52
- test('Simple FormSelect input', () => {
53
- const view = render(
54
- <FormSelect value={props.value} aria-label="simple FormSelect">
55
- {props.options.map((option, index) => (
56
- <FormSelectOption isDisabled={option.disabled} key={index} value={option.value} label={option.label} />
57
- ))}
58
- </FormSelect>
59
- );
60
- expect(view.container).toMatchSnapshot();
61
- });
56
+ describe('FormSelect', () => {
57
+ test('Simple FormSelect input', () => {
58
+ render(
59
+ <FormSelect value={props.value} aria-label="simple FormSelect">
60
+ {props.options.map((option, index) => (
61
+ <FormSelectOption isDisabled={option.disabled} key={index} value={option.value} label={option.label} />
62
+ ))}
63
+ </FormSelect>
64
+ );
65
+ expect(screen.getByLabelText('simple FormSelect').outerHTML).toMatchSnapshot();
66
+ });
62
67
 
63
- test('Grouped FormSelect input', () => {
64
- const view = render(
65
- <FormSelect value={groupedProps.value} aria-label=" grouped FormSelect">
66
- {groupedProps.groups.map((group, index) => (
67
- <FormSelectOptionGroup isDisabled={group.disabled} key={index} label={group.groupLabel}>
68
- {group.options.map((option, i) => (
69
- <FormSelectOption isDisabled={option.disabled} key={i} value={option.value} label={option.label} />
70
- ))}
71
- </FormSelectOptionGroup>
72
- ))}
73
- </FormSelect>
74
- );
75
- expect(view.container).toMatchSnapshot();
76
- });
68
+ test('Grouped FormSelect input', () => {
69
+ render(
70
+ <FormSelect value={groupedProps.value} aria-label="grouped FormSelect">
71
+ {groupedProps.groups.map((group, index) => (
72
+ <FormSelectOptionGroup isDisabled={group.disabled} key={index} label={group.groupLabel}>
73
+ {group.options.map((option, i) => (
74
+ <FormSelectOption isDisabled={option.disabled} key={i} value={option.value} label={option.label} />
75
+ ))}
76
+ </FormSelectOptionGroup>
77
+ ))}
78
+ </FormSelect>
79
+ );
80
+ expect(screen.getByLabelText('grouped FormSelect').outerHTML).toMatchSnapshot();
81
+ });
77
82
 
78
- test('Disabled FormSelect input ', () => {
79
- const view = render(
80
- <FormSelect isDisabled aria-label="disabled FormSelect">
81
- <FormSelectOption key={1} value={props.options[1].value} label={props.options[1].label} />
82
- </FormSelect>
83
- );
84
- expect(view.container).toMatchSnapshot();
85
- });
83
+ test('Disabled FormSelect input ', () => {
84
+ render(
85
+ <FormSelect isDisabled aria-label="disabled FormSelect">
86
+ <FormSelectOption key={1} value={props.options[1].value} label={props.options[1].label} />
87
+ </FormSelect>
88
+ );
89
+ expect(screen.getByLabelText('disabled FormSelect').outerHTML).toMatchSnapshot();
90
+ });
86
91
 
87
- test('FormSelect input with aria-label does not generate console error', () => {
88
- const myMock = jest.fn() as any;
89
- global.console = { error: myMock } as any;
90
- const view = render(
91
- <FormSelect aria-label="FormSelect with aria-label">
92
- <FormSelectOption key={1} value={props.options[1].value} label={props.options[1].label} />
93
- </FormSelect>
94
- );
95
- expect(view.container).toMatchSnapshot();
96
- expect(myMock).not.toBeCalled();
97
- });
92
+ test('FormSelect input with aria-label does not generate console error', () => {
93
+ const myMock = jest.fn() as any;
94
+ global.console = { error: myMock } as any;
98
95
 
99
- test('FormSelect input with id does not generate console error', () => {
100
- const myMock = jest.fn() as any;
101
- global.console = { error: myMock } as any;
102
- const view = render(
103
- <FormSelect id="id">
104
- <FormSelectOption key={1} value={props.options[1].value} label={props.options[1].label} />
105
- </FormSelect>
106
- );
107
- expect(view.container).toMatchSnapshot();
108
- expect(myMock).not.toBeCalled();
109
- });
96
+ render(
97
+ <FormSelect aria-label="label">
98
+ <FormSelectOption key={1} value={props.options[1].value} label={props.options[1].label} />
99
+ </FormSelect>
100
+ );
110
101
 
111
- test('FormSelect input with no aria-label or id generates console error', () => {
112
- const myMock = jest.fn() as any;
113
- global.console = { error: myMock } as any;
114
- const view = render(
115
- <FormSelect>
116
- <FormSelectOption key={1} value={props.options[1].value} label={props.options[1].label} />
117
- </FormSelect>
118
- );
119
- expect(view.container).toMatchSnapshot();
120
- expect(myMock).toBeCalled();
121
- });
102
+ expect(screen.getByLabelText('label').outerHTML).toMatchSnapshot();
103
+ expect(myMock).not.toBeCalled();
104
+ });
122
105
 
123
- test('invalid FormSelect input', () => {
124
- const view = render(
125
- <FormSelect validated={'error'} aria-label="invalid FormSelect">
126
- <FormSelectOption key={1} value={props.options[1].value} label={props.options[1].label} />
127
- </FormSelect>
128
- );
129
- expect(view.container).toMatchSnapshot();
130
- });
106
+ test('FormSelect input with id does not generate console error', () => {
107
+ const myMock = jest.fn() as any;
108
+ global.console = { error: myMock } as any;
131
109
 
132
- test('validated success FormSelect input', () => {
133
- const view = shallow(
134
- <FormSelect validated={ValidatedOptions.success} aria-label="validated FormSelect">
135
- <FormSelectOption key={1} value={props.options[1].value} label={props.options[1].label} />
136
- </FormSelect>
137
- );
138
- expect(view.find('.pf-c-form-control.pf-m-success').length).toBe(1);
139
- expect(view).toMatchSnapshot();
140
- });
110
+ render(
111
+ <FormSelect id="id" aria-label="label">
112
+ <FormSelectOption key={1} value={props.options[1].value} label={props.options[1].label} />
113
+ </FormSelect>
114
+ );
141
115
 
142
- test('validated error FormSelect input', () => {
143
- const view = render(
144
- <FormSelect validated={ValidatedOptions.error} aria-label="validated FormSelect">
145
- <FormSelectOption key={1} value={props.options[1].value} label={props.options[1].label} />
146
- </FormSelect>
147
- );
148
- expect(view.container).toMatchSnapshot();
149
- });
116
+ expect(screen.getByLabelText('label').outerHTML).toMatchSnapshot();
117
+ expect(myMock).not.toBeCalled();
118
+ });
150
119
 
151
- test('validated warning FormSelect input', () => {
152
- const view = shallow(
153
- <FormSelect validated={ValidatedOptions.warning} aria-label="validated FormSelect">
154
- <FormSelectOption key={1} value={props.options[1].value} label={props.options[1].label} />
155
- </FormSelect>
156
- );
157
- expect(view.find('.pf-c-form-control.pf-m-warning').length).toBe(1);
158
- expect(view).toMatchSnapshot();
159
- });
120
+ test('FormSelect input with no aria-label or id generates console error', () => {
121
+ const myMock = jest.fn() as any;
122
+ global.console = { error: myMock } as any;
160
123
 
124
+ render(
125
+ <FormSelect data-testid="test-id">
126
+ <FormSelectOption key={1} value={props.options[1].value} label={props.options[1].label} />
127
+ </FormSelect>
128
+ );
161
129
 
162
- test('required FormSelect input', () => {
163
- const view = render(
164
- <FormSelect required aria-label="required FormSelect">
165
- <FormSelectOption key={1} value={props.options[1].value} label={props.options[1].label} />
166
- </FormSelect>
167
- );
168
- expect(view.container).toMatchSnapshot();
169
- });
130
+ expect(screen.getByTestId('test-id').outerHTML).toMatchSnapshot();
131
+ expect(myMock).toBeCalled();
132
+ });
133
+
134
+ test('invalid FormSelect input', () => {
135
+ render(
136
+ <FormSelect validated="error" aria-label="invalid FormSelect">
137
+ <FormSelectOption key={1} value={props.options[1].value} label={props.options[1].label} />
138
+ </FormSelect>
139
+ );
140
+ expect(screen.getByLabelText('invalid FormSelect').outerHTML).toMatchSnapshot();
141
+ });
142
+
143
+ test('validated success FormSelect input', () => {
144
+ render(
145
+ <FormSelect validated={ValidatedOptions.success} aria-label="validated FormSelect">
146
+ <FormSelectOption key={1} value={props.options[1].value} label={props.options[1].label} />
147
+ </FormSelect>
148
+ );
149
+
150
+ const formSelect = screen.getByLabelText('validated FormSelect');
151
+
152
+ expect(formSelect.className).toContain('pf-m-success');
153
+ expect(formSelect.outerHTML).toMatchSnapshot();
154
+ });
155
+
156
+ test('validated warning FormSelect input', () => {
157
+ render(
158
+ <FormSelect validated={ValidatedOptions.warning} aria-label="validated FormSelect">
159
+ <FormSelectOption key={1} value={props.options[1].value} label={props.options[1].label} />
160
+ </FormSelect>
161
+ );
162
+
163
+ const formSelect = screen.getByLabelText('validated FormSelect');
164
+
165
+ expect(formSelect.className).toContain('pf-m-warning');
166
+ expect(formSelect.outerHTML).toMatchSnapshot();
167
+ });
168
+
169
+ test('required FormSelect input', () => {
170
+ render(
171
+ <FormSelect isRequired aria-label="required FormSelect">
172
+ <FormSelectOption key={1} value={props.options[1].value} label={props.options[1].label} />
173
+ </FormSelect>
174
+ );
175
+
176
+ expect(screen.getByLabelText('required FormSelect')).toHaveAttribute('required');
177
+ });
178
+
179
+ test('FormSelect passes value and event to onChange handler', () => {
180
+ const myMock = jest.fn();
181
+
182
+ render(
183
+ <FormSelect onChange={myMock} aria-label="Some label">
184
+ <FormSelectOption key={1} value={props.options[1].value} label={props.options[1].label} />
185
+ </FormSelect>
186
+ );
187
+
188
+ userEvent.selectOptions(screen.getByLabelText('Some label'), 'Mr');
170
189
 
171
- test('FormSelect passes value and event to onChange handler', () => {
172
- const myMock = jest.fn();
173
- const newValue = 1;
174
- const event = {
175
- currentTarget: { value: newValue }
176
- };
177
- const view = shallow(
178
- <FormSelect onChange={myMock} aria-label="onchange FormSelect">
179
- <FormSelectOption key={1} value={props.options[1].value} label={props.options[1].label} />
180
- </FormSelect>
181
- );
182
- view.find('select').simulate('change', event);
183
- expect(myMock).toBeCalledWith(newValue, event);
190
+ expect(myMock).toBeCalled();
191
+ expect(myMock.mock.calls[0][0]).toEqual('mr');
192
+ });
184
193
  });
@@ -1,311 +1,19 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`Disabled FormSelect input 1`] = `
4
- <div>
5
- <select
6
- aria-invalid="false"
7
- aria-label="disabled FormSelect"
8
- class="pf-c-form-control"
9
- data-ouia-component-id="OUIA-Generated-FormSelect-default-3"
10
- data-ouia-component-type="PF4/FormSelect"
11
- data-ouia-safe="true"
12
- disabled=""
13
- >
14
- <option
15
- class=""
16
- value="mr"
17
- >
18
- Mr
19
- </option>
20
- </select>
21
- </div>
22
- `;
3
+ exports[`FormSelect Disabled FormSelect input 1`] = `"<select aria-label=\\"disabled FormSelect\\" class=\\"pf-c-form-control\\" aria-invalid=\\"false\\" data-ouia-component-type=\\"PF4/FormSelect\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-FormSelect-default-3\\" disabled=\\"\\"><option class=\\"\\" value=\\"mr\\">Mr</option></select>"`;
23
4
 
24
- exports[`FormSelect input with aria-label does not generate console error 1`] = `
25
- <div>
26
- <select
27
- aria-invalid="false"
28
- aria-label="FormSelect with aria-label"
29
- class="pf-c-form-control"
30
- data-ouia-component-id="OUIA-Generated-FormSelect-default-4"
31
- data-ouia-component-type="PF4/FormSelect"
32
- data-ouia-safe="true"
33
- >
34
- <option
35
- class=""
36
- value="mr"
37
- >
38
- Mr
39
- </option>
40
- </select>
41
- </div>
42
- `;
5
+ exports[`FormSelect FormSelect input with aria-label does not generate console error 1`] = `"<select aria-label=\\"label\\" class=\\"pf-c-form-control\\" aria-invalid=\\"false\\" data-ouia-component-type=\\"PF4/FormSelect\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-FormSelect-default-4\\"><option class=\\"\\" value=\\"mr\\">Mr</option></select>"`;
43
6
 
44
- exports[`FormSelect input with id does not generate console error 1`] = `
45
- <div>
46
- <select
47
- aria-invalid="false"
48
- class="pf-c-form-control"
49
- data-ouia-component-id="OUIA-Generated-FormSelect-default-5"
50
- data-ouia-component-type="PF4/FormSelect"
51
- data-ouia-safe="true"
52
- id="id"
53
- >
54
- <option
55
- class=""
56
- value="mr"
57
- >
58
- Mr
59
- </option>
60
- </select>
61
- </div>
62
- `;
7
+ exports[`FormSelect FormSelect input with id does not generate console error 1`] = `"<select id=\\"id\\" aria-label=\\"label\\" class=\\"pf-c-form-control\\" aria-invalid=\\"false\\" data-ouia-component-type=\\"PF4/FormSelect\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-FormSelect-default-5\\"><option class=\\"\\" value=\\"mr\\">Mr</option></select>"`;
63
8
 
64
- exports[`FormSelect input with no aria-label or id generates console error 1`] = `
65
- <div>
66
- <select
67
- aria-invalid="false"
68
- class="pf-c-form-control"
69
- data-ouia-component-id="OUIA-Generated-FormSelect-default-6"
70
- data-ouia-component-type="PF4/FormSelect"
71
- data-ouia-safe="true"
72
- >
73
- <option
74
- class=""
75
- value="mr"
76
- >
77
- Mr
78
- </option>
79
- </select>
80
- </div>
81
- `;
9
+ exports[`FormSelect FormSelect input with no aria-label or id generates console error 1`] = `"<select data-testid=\\"test-id\\" class=\\"pf-c-form-control\\" aria-invalid=\\"false\\" data-ouia-component-type=\\"PF4/FormSelect\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-FormSelect-default-6\\"><option class=\\"\\" value=\\"mr\\">Mr</option></select>"`;
82
10
 
83
- exports[`Grouped FormSelect input 1`] = `
84
- <div>
85
- <select
86
- aria-invalid="false"
87
- aria-label=" grouped FormSelect"
88
- class="pf-c-form-control"
89
- data-ouia-component-id="OUIA-Generated-FormSelect-default-2"
90
- data-ouia-component-type="PF4/FormSelect"
91
- data-ouia-safe="true"
92
- >
93
- <optgroup
94
- class=""
95
- label="Group1"
96
- >
97
- <option
98
- class=""
99
- value="1"
100
- >
101
- The First Option
102
- </option>
103
- <option
104
- class=""
105
- value="2"
106
- >
107
- Second option is selected by default
108
- </option>
109
- </optgroup>
110
- <optgroup
111
- class=""
112
- label="Group2"
113
- >
114
- <option
115
- class=""
116
- value="3"
117
- >
118
- The Third Option
119
- </option>
120
- <option
121
- class=""
122
- value="4"
123
- >
124
- The Fourth option
125
- </option>
126
- </optgroup>
127
- <optgroup
128
- class=""
129
- disabled=""
130
- label="Group3"
131
- >
132
- <option
133
- class=""
134
- value="5"
135
- >
136
- The Fifth Option
137
- </option>
138
- <option
139
- class=""
140
- value="6"
141
- >
142
- The Sixth option
143
- </option>
144
- </optgroup>
145
- </select>
146
- </div>
147
- `;
11
+ exports[`FormSelect Grouped FormSelect input 1`] = `"<select aria-label=\\"grouped FormSelect\\" class=\\"pf-c-form-control\\" aria-invalid=\\"false\\" data-ouia-component-type=\\"PF4/FormSelect\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-FormSelect-default-2\\"><optgroup class=\\"\\" label=\\"Group1\\"><option class=\\"\\" value=\\"1\\">The First Option</option><option class=\\"\\" value=\\"2\\">Second option is selected by default</option></optgroup><optgroup class=\\"\\" label=\\"Group2\\"><option class=\\"\\" value=\\"3\\">The Third Option</option><option class=\\"\\" value=\\"4\\">The Fourth option</option></optgroup><optgroup disabled=\\"\\" class=\\"\\" label=\\"Group3\\"><option class=\\"\\" value=\\"5\\">The Fifth Option</option><option class=\\"\\" value=\\"6\\">The Sixth option</option></optgroup></select>"`;
148
12
 
149
- exports[`Simple FormSelect input 1`] = `
150
- <div>
151
- <select
152
- aria-invalid="false"
153
- aria-label="simple FormSelect"
154
- class="pf-c-form-control"
155
- data-ouia-component-id="OUIA-Generated-FormSelect-default-1"
156
- data-ouia-component-type="PF4/FormSelect"
157
- data-ouia-safe="true"
158
- >
159
- <option
160
- class=""
161
- disabled=""
162
- value="please choose"
163
- >
164
- Please Choose
165
- </option>
166
- <option
167
- class=""
168
- value="mr"
169
- >
170
- Mr
171
- </option>
172
- <option
173
- class=""
174
- value="miss"
175
- >
176
- Miss
177
- </option>
178
- <option
179
- class=""
180
- value="mrs"
181
- >
182
- Mrs
183
- </option>
184
- <option
185
- class=""
186
- value="ms"
187
- >
188
- Ms
189
- </option>
190
- <option
191
- class=""
192
- value="dr"
193
- >
194
- Dr
195
- </option>
196
- <option
197
- class=""
198
- disabled=""
199
- value="other"
200
- >
201
- Other
202
- </option>
203
- </select>
204
- </div>
205
- `;
13
+ exports[`FormSelect Simple FormSelect input 1`] = `"<select aria-label=\\"simple FormSelect\\" class=\\"pf-c-form-control\\" aria-invalid=\\"false\\" data-ouia-component-type=\\"PF4/FormSelect\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-FormSelect-default-1\\"><option class=\\"\\" value=\\"please choose\\" disabled=\\"\\">Please Choose</option><option class=\\"\\" value=\\"mr\\">Mr</option><option class=\\"\\" value=\\"miss\\">Miss</option><option class=\\"\\" value=\\"mrs\\">Mrs</option><option class=\\"\\" value=\\"ms\\">Ms</option><option class=\\"\\" value=\\"dr\\">Dr</option><option class=\\"\\" value=\\"other\\" disabled=\\"\\">Other</option></select>"`;
206
14
 
207
- exports[`invalid FormSelect input 1`] = `
208
- <div>
209
- <select
210
- aria-invalid="true"
211
- aria-label="invalid FormSelect"
212
- class="pf-c-form-control"
213
- data-ouia-component-id="OUIA-Generated-FormSelect-error-1"
214
- data-ouia-component-type="PF4/FormSelect"
215
- data-ouia-safe="true"
216
- >
217
- <option
218
- class=""
219
- value="mr"
220
- >
221
- Mr
222
- </option>
223
- </select>
224
- </div>
225
- `;
15
+ exports[`FormSelect invalid FormSelect input 1`] = `"<select aria-label=\\"invalid FormSelect\\" class=\\"pf-c-form-control\\" aria-invalid=\\"true\\" data-ouia-component-type=\\"PF4/FormSelect\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-FormSelect-error-1\\"><option class=\\"\\" value=\\"mr\\">Mr</option></select>"`;
226
16
 
227
- exports[`required FormSelect input 1`] = `
228
- <div>
229
- <select
230
- aria-invalid="false"
231
- aria-label="required FormSelect"
232
- class="pf-c-form-control"
233
- data-ouia-component-id="OUIA-Generated-FormSelect-default-7"
234
- data-ouia-component-type="PF4/FormSelect"
235
- data-ouia-safe="true"
236
- >
237
- <option
238
- class=""
239
- value="mr"
240
- >
241
- Mr
242
- </option>
243
- </select>
244
- </div>
245
- `;
17
+ exports[`FormSelect validated success FormSelect input 1`] = `"<select aria-label=\\"validated FormSelect\\" class=\\"pf-c-form-control pf-m-success\\" aria-invalid=\\"false\\" data-ouia-component-type=\\"PF4/FormSelect\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-FormSelect-success-1\\"><option class=\\"\\" value=\\"mr\\">Mr</option></select>"`;
246
18
 
247
- exports[`validated error FormSelect input 1`] = `
248
- <div>
249
- <select
250
- aria-invalid="true"
251
- aria-label="validated FormSelect"
252
- class="pf-c-form-control"
253
- data-ouia-component-id="OUIA-Generated-FormSelect-error-2"
254
- data-ouia-component-type="PF4/FormSelect"
255
- data-ouia-safe="true"
256
- >
257
- <option
258
- class=""
259
- value="mr"
260
- >
261
- Mr
262
- </option>
263
- </select>
264
- </div>
265
- `;
266
-
267
- exports[`validated success FormSelect input 1`] = `
268
- <select
269
- aria-invalid={false}
270
- aria-label="validated FormSelect"
271
- className="pf-c-form-control pf-m-success"
272
- data-ouia-component-id="OUIA-Generated-FormSelect-success-1"
273
- data-ouia-component-type="PF4/FormSelect"
274
- data-ouia-safe={true}
275
- disabled={false}
276
- onBlur={[Function]}
277
- onChange={[Function]}
278
- onFocus={[Function]}
279
- required={false}
280
- value=""
281
- >
282
- <FormSelectOption
283
- key="1"
284
- label="Mr"
285
- value="mr"
286
- />
287
- </select>
288
- `;
289
-
290
- exports[`validated warning FormSelect input 1`] = `
291
- <select
292
- aria-invalid={false}
293
- aria-label="validated FormSelect"
294
- className="pf-c-form-control pf-m-warning"
295
- data-ouia-component-id="OUIA-Generated-FormSelect-warning-1"
296
- data-ouia-component-type="PF4/FormSelect"
297
- data-ouia-safe={true}
298
- disabled={false}
299
- onBlur={[Function]}
300
- onChange={[Function]}
301
- onFocus={[Function]}
302
- required={false}
303
- value=""
304
- >
305
- <FormSelectOption
306
- key="1"
307
- label="Mr"
308
- value="mr"
309
- />
310
- </select>
311
- `;
19
+ exports[`FormSelect validated warning FormSelect input 1`] = `"<select aria-label=\\"validated FormSelect\\" class=\\"pf-c-form-control pf-m-warning\\" aria-invalid=\\"false\\" data-ouia-component-type=\\"PF4/FormSelect\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-FormSelect-warning-1\\"><option class=\\"\\" value=\\"mr\\">Mr</option></select>"`;
@@ -1,47 +1,23 @@
1
1
  import React from 'react';
2
- import { shallow } from 'enzyme';
2
+
3
+ import { render, screen } from '@testing-library/react';
4
+
3
5
  import { InputGroup } from '../InputGroup';
4
- import { InputGroupText, InputGroupTextVariant } from '../InputGroupText';
5
6
  import { Button } from '../../Button';
6
7
  import { TextInput } from '../../TextInput';
7
8
 
8
- test('InputGroupText', () => {
9
- const view = shallow(
10
- <InputGroupText className="inpt-grp-text" variant={InputGroupTextVariant.plain} id="email-npt-grp">
11
- @
12
- </InputGroupText>
13
- );
14
- expect(view.find('span')).toHaveLength(1);
15
- const spanProps = view.find('span').props();
16
- expect(spanProps.className).toEqual(expect.stringContaining('inpt-grp-text'));
17
- expect(spanProps.className).toEqual(expect.stringContaining('pf-m-plain'));
18
- expect(spanProps.id).toBe('email-npt-grp');
19
- expect(view.text()).toBe('@');
20
- });
21
-
22
- test('InputGroup', () => {
23
- const view = shallow(
24
- <InputGroup className="text-verify-cls" id="text-1">
25
- <TextInput value="this is text" aria-label="data text" />
26
- </InputGroup>
27
- );
28
-
29
- expect(view.find('div')).toHaveLength(1);
30
- const divProps = view.find('div').props();
31
- expect(divProps.className).toEqual(expect.stringContaining('text-verify-cls'));
32
- expect(divProps.id).toBe('text-1');
33
- });
34
-
35
- test('add aria-describedby to form-control if one of the non form-controls has id', () => {
36
- // In this test, TextInput is a form-control component and Button is not.
37
- // If Button has an id props, this should be used in aria-describedby.
38
- const view = shallow(
39
- <InputGroup>
40
- <TextInput value="some data" aria-label="some text" />
41
- <Button variant="primary" id="button-id">
42
- hello
43
- </Button>
44
- </InputGroup>
45
- );
46
- expect(view.find(TextInput).props()['aria-describedby']).toBe('button-id');
9
+ describe('InputGroup', () => {
10
+ test('add aria-describedby to form-control if one of the non form-controls has id', () => {
11
+ // In this test, TextInput is a form-control component and Button is not.
12
+ // If Button has an id props, this should be used in aria-describedby.
13
+ render(
14
+ <InputGroup data-testid="input-group-test-id">
15
+ <TextInput value="some data" aria-label="some text" />
16
+ <Button variant="primary" id="button-id">
17
+ hello
18
+ </Button>
19
+ </InputGroup>
20
+ );
21
+ expect(screen.getByLabelText('some text').getAttribute('aria-describedby')).toEqual('button-id');
22
+ });
47
23
  });