@patternfly/react-core 5.2.0-prerelease.17 → 5.2.0-prerelease.18
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 +6 -0
- package/components/package.json +1 -1
- package/deprecated/package.json +1 -1
- package/dist/dynamic/components/AboutModal/package.json +1 -1
- package/dist/dynamic/components/Accordion/package.json +1 -1
- package/dist/dynamic/components/ActionList/package.json +1 -1
- package/dist/dynamic/components/Alert/package.json +1 -1
- package/dist/dynamic/components/Avatar/package.json +1 -1
- package/dist/dynamic/components/BackToTop/package.json +1 -1
- package/dist/dynamic/components/Backdrop/package.json +1 -1
- package/dist/dynamic/components/BackgroundImage/package.json +1 -1
- package/dist/dynamic/components/Badge/package.json +1 -1
- package/dist/dynamic/components/Banner/package.json +1 -1
- package/dist/dynamic/components/Brand/package.json +1 -1
- package/dist/dynamic/components/Breadcrumb/package.json +1 -1
- package/dist/dynamic/components/Button/package.json +1 -1
- package/dist/dynamic/components/CalendarMonth/package.json +1 -1
- package/dist/dynamic/components/Card/package.json +1 -1
- package/dist/dynamic/components/Checkbox/package.json +1 -1
- package/dist/dynamic/components/Chip/package.json +1 -1
- package/dist/dynamic/components/ClipboardCopy/package.json +1 -1
- package/dist/dynamic/components/CodeBlock/package.json +1 -1
- package/dist/dynamic/components/DataList/package.json +1 -1
- package/dist/dynamic/components/DatePicker/package.json +1 -1
- package/dist/dynamic/components/DescriptionList/package.json +1 -1
- package/dist/dynamic/components/Divider/package.json +1 -1
- package/dist/dynamic/components/DragDrop/package.json +1 -1
- package/dist/dynamic/components/Drawer/package.json +1 -1
- package/dist/dynamic/components/Dropdown/package.json +1 -1
- package/dist/dynamic/components/DualListSelector/package.json +1 -1
- package/dist/dynamic/components/EmptyState/package.json +1 -1
- package/dist/dynamic/components/ExpandableSection/package.json +1 -1
- package/dist/dynamic/components/FileUpload/package.json +1 -1
- package/dist/dynamic/components/Form/package.json +1 -1
- package/dist/dynamic/components/FormSelect/package.json +1 -1
- package/dist/dynamic/components/HelperText/package.json +1 -1
- package/dist/dynamic/components/Hint/package.json +1 -1
- package/dist/dynamic/components/Icon/package.json +1 -1
- package/dist/dynamic/components/InputGroup/package.json +1 -1
- package/dist/dynamic/components/JumpLinks/package.json +1 -1
- package/dist/dynamic/components/Label/package.json +1 -1
- package/dist/dynamic/components/List/package.json +1 -1
- package/dist/dynamic/components/LoginPage/package.json +1 -1
- package/dist/dynamic/components/Masthead/package.json +1 -1
- package/dist/dynamic/components/Menu/package.json +1 -1
- package/dist/dynamic/components/MenuToggle/package.json +1 -1
- package/dist/dynamic/components/Modal/package.json +1 -1
- package/dist/dynamic/components/MultipleFileUpload/package.json +1 -1
- package/dist/dynamic/components/Nav/package.json +1 -1
- package/dist/dynamic/components/NotificationBadge/package.json +1 -1
- package/dist/dynamic/components/NotificationDrawer/package.json +1 -1
- package/dist/dynamic/components/NumberInput/package.json +1 -1
- package/dist/dynamic/components/OverflowMenu/package.json +1 -1
- package/dist/dynamic/components/Page/package.json +1 -1
- package/dist/dynamic/components/Pagination/package.json +1 -1
- package/dist/dynamic/components/Panel/package.json +1 -1
- package/dist/dynamic/components/Popover/package.json +1 -1
- package/dist/dynamic/components/Progress/package.json +1 -1
- package/dist/dynamic/components/ProgressStepper/package.json +1 -1
- package/dist/dynamic/components/Radio/package.json +1 -1
- package/dist/dynamic/components/SearchInput/package.json +1 -1
- package/dist/dynamic/components/Select/package.json +1 -1
- package/dist/dynamic/components/Sidebar/package.json +1 -1
- package/dist/dynamic/components/SimpleList/package.json +1 -1
- package/dist/dynamic/components/Skeleton/package.json +1 -1
- package/dist/dynamic/components/SkipToContent/package.json +1 -1
- package/dist/dynamic/components/Slider/package.json +1 -1
- package/dist/dynamic/components/Spinner/package.json +1 -1
- package/dist/dynamic/components/Switch/package.json +1 -1
- package/dist/dynamic/components/Tabs/package.json +1 -1
- package/dist/dynamic/components/Text/package.json +1 -1
- package/dist/dynamic/components/TextArea/package.json +1 -1
- package/dist/dynamic/components/TextInput/package.json +1 -1
- package/dist/dynamic/components/TextInputGroup/package.json +1 -1
- package/dist/dynamic/components/Tile/package.json +1 -1
- package/dist/dynamic/components/TimePicker/package.json +1 -1
- package/dist/dynamic/components/Timestamp/package.json +1 -1
- package/dist/dynamic/components/Title/package.json +1 -1
- package/dist/dynamic/components/ToggleGroup/package.json +1 -1
- package/dist/dynamic/components/Toolbar/package.json +1 -1
- package/dist/dynamic/components/Tooltip/package.json +1 -1
- package/dist/dynamic/components/TreeView/package.json +1 -1
- package/dist/dynamic/components/Truncate/package.json +1 -1
- package/dist/dynamic/components/Wizard/hooks/package.json +1 -1
- package/dist/dynamic/components/Wizard/package.json +1 -1
- package/dist/dynamic/deprecated/components/ApplicationLauncher/package.json +1 -1
- package/dist/dynamic/deprecated/components/ContextSelector/package.json +1 -1
- package/dist/dynamic/deprecated/components/Dropdown/package.json +1 -1
- package/dist/dynamic/deprecated/components/OptionsMenu/package.json +1 -1
- package/dist/dynamic/deprecated/components/PageHeader/package.json +1 -1
- package/dist/dynamic/deprecated/components/Select/package.json +1 -1
- package/dist/dynamic/deprecated/components/Wizard/package.json +1 -1
- package/dist/dynamic/deprecated/components/package.json +1 -1
- package/dist/dynamic/helpers/FocusTrap/FocusTrap/package.json +1 -1
- package/dist/dynamic/helpers/GenerateId/GenerateId/package.json +1 -1
- package/dist/dynamic/helpers/KeyboardHandler/package.json +1 -1
- package/dist/dynamic/helpers/OUIA/ouia/package.json +1 -1
- package/dist/dynamic/helpers/Popper/Popper/package.json +1 -1
- package/dist/dynamic/helpers/constants/package.json +1 -1
- package/dist/dynamic/helpers/datetimeUtils/package.json +1 -1
- package/dist/dynamic/helpers/favorites/package.json +1 -1
- package/dist/dynamic/helpers/fileUtils/package.json +1 -1
- package/dist/dynamic/helpers/htmlConstants/package.json +1 -1
- package/dist/dynamic/helpers/package.json +1 -1
- package/dist/dynamic/helpers/resizeObserver/package.json +1 -1
- package/dist/dynamic/helpers/typeUtils/package.json +1 -1
- package/dist/dynamic/helpers/useInterval/package.json +1 -1
- package/dist/dynamic/helpers/useIsomorphicLayout/package.json +1 -1
- package/dist/dynamic/helpers/useUnmountEffect/package.json +1 -1
- package/dist/dynamic/helpers/util/package.json +1 -1
- package/dist/dynamic/layouts/Bullseye/package.json +1 -1
- package/dist/dynamic/layouts/Flex/package.json +1 -1
- package/dist/dynamic/layouts/Gallery/package.json +1 -1
- package/dist/dynamic/layouts/Grid/package.json +1 -1
- package/dist/dynamic/layouts/Level/package.json +1 -1
- package/dist/dynamic/layouts/Split/package.json +1 -1
- package/dist/dynamic/layouts/Stack/package.json +1 -1
- package/dist/dynamic/next/components/package.json +1 -1
- package/dist/esm/components/ExpandableSection/ExpandableSection.js +1 -1
- package/dist/esm/components/ExpandableSection/ExpandableSection.js.map +1 -1
- package/dist/js/components/ExpandableSection/ExpandableSection.js +1 -1
- package/dist/js/components/ExpandableSection/ExpandableSection.js.map +1 -1
- package/dist/umd/react-core.min.js +1 -1
- package/helpers/package.json +1 -1
- package/layouts/package.json +1 -1
- package/next/package.json +1 -1
- package/package.json +2 -2
- package/src/components/Checkbox/__tests__/Checkbox.test.tsx +223 -69
- package/src/components/Checkbox/__tests__/__snapshots__/Checkbox.test.tsx.snap +3 -198
- package/src/components/ExpandableSection/ExpandableSection.tsx +1 -1
package/helpers/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-helpers","main":"../dist/js/helpers/index.js","module":"../dist/esm/helpers/index.js","typings":"../dist/esm/helpers/index.d.ts","version":"5.2.0-prerelease.
|
|
1
|
+
{"name":"@patternfly/react-core-helpers","main":"../dist/js/helpers/index.js","module":"../dist/esm/helpers/index.js","typings":"../dist/esm/helpers/index.d.ts","version":"5.2.0-prerelease.17","private":true}
|
package/layouts/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-layouts","main":"../dist/js/layouts/index.js","module":"../dist/esm/layouts/index.js","typings":"../dist/esm/layouts/index.d.ts","version":"5.2.0-prerelease.
|
|
1
|
+
{"name":"@patternfly/react-core-layouts","main":"../dist/js/layouts/index.js","module":"../dist/esm/layouts/index.js","typings":"../dist/esm/layouts/index.d.ts","version":"5.2.0-prerelease.17","private":true}
|
package/next/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-next","main":"../dist/js/next/index.js","module":"../dist/esm/next/index.js","typings":"../dist/esm/next/index.d.ts","version":"5.2.0-prerelease.
|
|
1
|
+
{"name":"@patternfly/react-core-next","main":"../dist/js/next/index.js","module":"../dist/esm/next/index.js","typings":"../dist/esm/next/index.d.ts","version":"5.2.0-prerelease.17","private":true}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "5.2.0-prerelease.
|
|
3
|
+
"version": "5.2.0-prerelease.18",
|
|
4
4
|
"description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"react": "^17 || ^18",
|
|
72
72
|
"react-dom": "^17 || ^18"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "044826a3f3ee454f616c35c0cfd5652d6baa9614"
|
|
75
75
|
}
|
|
@@ -6,91 +6,245 @@ import userEvent from '@testing-library/user-event';
|
|
|
6
6
|
import { Checkbox } from '../Checkbox';
|
|
7
7
|
import styles from '@patternfly/react-styles/css/components/Check/check';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const { asFragment } = render(<Checkbox isChecked id="check" aria-label="check" />);
|
|
12
|
-
expect(asFragment()).toMatchSnapshot();
|
|
13
|
-
});
|
|
9
|
+
test(`Renders with only the class ${styles.checkInput} on the check by default`, () => {
|
|
10
|
+
render(<Checkbox id="test-id" />);
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
expect(asFragment()).toMatchSnapshot();
|
|
18
|
-
});
|
|
12
|
+
expect(screen.getByRole('checkbox')).toHaveClass(styles.checkInput, { exact: true });
|
|
13
|
+
});
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
expect(asFragment()).toMatchSnapshot();
|
|
23
|
-
});
|
|
15
|
+
test(`Renders with only the classes ${styles.check} and ${styles.modifiers.standalone} on the check wrapper by default`, () => {
|
|
16
|
+
render(<Checkbox id="test-id" />);
|
|
24
17
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
expect(asFragment()).toMatchSnapshot();
|
|
18
|
+
expect(screen.getByRole('checkbox').parentElement).toHaveClass(`${styles.check} ${styles.modifiers.standalone}`, {
|
|
19
|
+
exact: true
|
|
28
20
|
});
|
|
21
|
+
});
|
|
29
22
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
expect(asFragment()).toMatchSnapshot();
|
|
33
|
-
});
|
|
23
|
+
test('Renders with additional classes passed via className', () => {
|
|
24
|
+
render(<Checkbox id="test-id" className="test-class" />);
|
|
34
25
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const { asFragment } = render(<Checkbox label={functionLabel()} id="check" isChecked aria-label="check" />);
|
|
38
|
-
expect(asFragment()).toMatchSnapshot();
|
|
39
|
-
});
|
|
26
|
+
expect(screen.getByRole('checkbox').parentElement).toHaveClass('test-class');
|
|
27
|
+
});
|
|
40
28
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
expect(asFragment()).toMatchSnapshot();
|
|
44
|
-
});
|
|
29
|
+
test('Renders with additional classes passed via inputClassName', () => {
|
|
30
|
+
render(<Checkbox id="test-id" inputClassName="test-class" />);
|
|
45
31
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
<Checkbox label="label" className="class-123" id="check" isChecked aria-label="check" />
|
|
49
|
-
);
|
|
50
|
-
expect(asFragment()).toMatchSnapshot();
|
|
51
|
-
});
|
|
32
|
+
expect(screen.getByRole('checkbox')).toHaveClass('test-class');
|
|
33
|
+
});
|
|
52
34
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
<Checkbox label="label" aria-labelledby="labelId" id="check" isChecked aria-label="check" />
|
|
56
|
-
);
|
|
57
|
-
expect(asFragment()).toMatchSnapshot();
|
|
58
|
-
});
|
|
35
|
+
test('Does not set the checkbox as invalid by default', () => {
|
|
36
|
+
render(<Checkbox id="test-id" />);
|
|
59
37
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
expect(screen.getByText('Text description...')).toBeInTheDocument();
|
|
63
|
-
});
|
|
38
|
+
expect(screen.getByRole('checkbox')).toBeValid();
|
|
39
|
+
});
|
|
64
40
|
|
|
65
|
-
|
|
66
|
-
|
|
41
|
+
test('Sets the checkbox as invalid when isValid is false', () => {
|
|
42
|
+
render(<Checkbox id="test-id" isValid={false} />);
|
|
67
43
|
|
|
68
|
-
|
|
69
|
-
|
|
44
|
+
expect(screen.getByRole('checkbox')).toBeInvalid();
|
|
45
|
+
});
|
|
70
46
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const user = userEvent.setup();
|
|
47
|
+
test('Does not set the checkbox as disabled by default', () => {
|
|
48
|
+
render(<Checkbox id="test-id" />);
|
|
74
49
|
|
|
75
|
-
|
|
50
|
+
expect(screen.getByRole('checkbox')).not.toBeDisabled();
|
|
51
|
+
});
|
|
76
52
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
});
|
|
53
|
+
test(`Sets the checkbox as disabled when isDisabled is passed`, () => {
|
|
54
|
+
render(<Checkbox id="test-id" isDisabled />);
|
|
80
55
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
global.console = { ...global.console, error: myMock };
|
|
56
|
+
expect(screen.getByRole('checkbox')).toBeDisabled();
|
|
57
|
+
});
|
|
84
58
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
});
|
|
59
|
+
test('Sets the label as disabled when isDisabled and label are passed', () => {
|
|
60
|
+
render(<Checkbox id="test-id" isDisabled label="test label" />);
|
|
88
61
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
62
|
+
expect(screen.getByLabelText('test label')).toBeDisabled();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('Does not set the checkbox as required by default', () => {
|
|
66
|
+
render(<Checkbox id="test-id" />);
|
|
67
|
+
|
|
68
|
+
expect(screen.getByRole('checkbox')).not.toBeRequired();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test(`Sets the checkbox as required when isRequired is passed`, () => {
|
|
72
|
+
render(<Checkbox id="test-id" isRequired />);
|
|
73
|
+
|
|
74
|
+
expect(screen.getByRole('checkbox')).toBeRequired();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test('Does not set the checkbox as checked by default', () => {
|
|
78
|
+
render(<Checkbox id="test-id" />);
|
|
79
|
+
|
|
80
|
+
expect(screen.getByRole('checkbox')).not.toBeChecked();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test(`Sets the checkbox as checked when isChecked is passed`, () => {
|
|
84
|
+
render(<Checkbox id="test-id" isChecked />);
|
|
85
|
+
|
|
86
|
+
expect(screen.getByRole('checkbox')).toBeChecked();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test(`Sets the checkbox as checked when checked is passed`, () => {
|
|
90
|
+
render(<Checkbox id="test-id" checked />);
|
|
91
|
+
|
|
92
|
+
expect(screen.getByRole('checkbox')).toBeChecked();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test(`Calls onChange when the checkbox is clicked`, async () => {
|
|
96
|
+
const user = userEvent.setup();
|
|
97
|
+
const onChange = jest.fn();
|
|
98
|
+
render(<Checkbox id="test-id" onChange={onChange} />);
|
|
99
|
+
|
|
100
|
+
await user.click(screen.getByRole('checkbox'));
|
|
101
|
+
|
|
102
|
+
expect(onChange).toHaveBeenCalledTimes(1);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test('Does not call onChange when the checkbox is not clicked', () => {
|
|
106
|
+
const onChange = jest.fn();
|
|
107
|
+
render(<Checkbox id="test-id" onChange={onChange} />);
|
|
108
|
+
|
|
109
|
+
expect(onChange).not.toHaveBeenCalled();
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test(`Calls onChange with the event and the checked value when the checkbox is clicked`, async () => {
|
|
113
|
+
const user = userEvent.setup();
|
|
114
|
+
const onChange = jest.fn();
|
|
115
|
+
render(<Checkbox id="test-id" onChange={onChange} />);
|
|
116
|
+
|
|
117
|
+
await user.click(screen.getByRole('checkbox'));
|
|
118
|
+
|
|
119
|
+
expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ type: 'change' }), true);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test(`Calls onChange with the event and the checked value when the checkbox is clicked and isChecked is passed`, async () => {
|
|
123
|
+
const user = userEvent.setup();
|
|
124
|
+
const onChange = jest.fn();
|
|
125
|
+
render(<Checkbox id="test-id" isChecked onChange={onChange} />);
|
|
126
|
+
|
|
127
|
+
await user.click(screen.getByRole('checkbox'));
|
|
128
|
+
|
|
129
|
+
expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ type: 'change' }), false);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test('Does not render a label by default', () => {
|
|
133
|
+
render(<Checkbox id="test-id" />);
|
|
134
|
+
|
|
135
|
+
expect(screen.queryByLabelText(/\w+/)).not.toBeInTheDocument();
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test('Renders a label when label is passed', () => {
|
|
139
|
+
render(<Checkbox id="test-id" label="test label" />);
|
|
140
|
+
|
|
141
|
+
expect(screen.getByLabelText('test label')).toBeVisible();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test('Associates the label with the checkbox', () => {
|
|
145
|
+
render(<Checkbox id="test-id" label="test label" />);
|
|
146
|
+
|
|
147
|
+
expect(screen.getByRole('checkbox')).toHaveAccessibleName('test label');
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test('Does not render an asterisk when a label is passed but isRequired is not', () => {
|
|
151
|
+
render(<Checkbox id="test-id" label="test label" />);
|
|
152
|
+
|
|
153
|
+
expect(screen.queryByText('*')).not.toBeInTheDocument();
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test('Renders an asterisk when isRequired and a label are passed', () => {
|
|
157
|
+
render(<Checkbox id="test-id" isRequired label="test label" />);
|
|
158
|
+
|
|
159
|
+
expect(screen.getByText('*')).toBeVisible();
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
test(`Wraps the required asterisk in the ${styles.checkLabelRequired} className`, () => {
|
|
163
|
+
render(<Checkbox id="test-id" isRequired label="test label" />);
|
|
164
|
+
|
|
165
|
+
expect(screen.getByText('*')).toHaveClass(styles.checkLabelRequired, { exact: true });
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
test('Renders with the provided id', () => {
|
|
169
|
+
render(<Checkbox id="test-id" />);
|
|
170
|
+
|
|
171
|
+
expect(screen.getByRole('checkbox')).toHaveAttribute('id', 'test-id');
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
test('Does not render an aria-label by default', () => {
|
|
175
|
+
render(<Checkbox id="test-id" />);
|
|
176
|
+
|
|
177
|
+
expect(screen.getByRole('checkbox')).not.toHaveAttribute('aria-label');
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test('Sets the name to the passed aria-label', () => {
|
|
181
|
+
render(<Checkbox id="test-id" aria-label="test aria-label" />);
|
|
182
|
+
|
|
183
|
+
expect(screen.getByRole('checkbox')).toHaveAccessibleName('test aria-label');
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test('Does not render a description by default', () => {
|
|
187
|
+
render(<Checkbox id="test-id" />);
|
|
188
|
+
|
|
189
|
+
expect(screen.queryByText(/\w+/)).not.toBeInTheDocument();
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
test('Renders a description when description is passed', () => {
|
|
193
|
+
render(<Checkbox id="test-id" description="test description" />);
|
|
194
|
+
|
|
195
|
+
expect(screen.getByText('test description')).toBeVisible();
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
test(`Renders the passed description with the ${styles.checkDescription} className`, () => {
|
|
199
|
+
render(<Checkbox id="test-id" description="test description" />);
|
|
200
|
+
|
|
201
|
+
expect(screen.getByText('test description')).toHaveClass(styles.checkDescription, { exact: true });
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
test('Does not render a body by default', () => {
|
|
205
|
+
render(<Checkbox id="test-id" />);
|
|
206
|
+
|
|
207
|
+
expect(screen.queryByText(/\w+/)).not.toBeInTheDocument();
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
test('Renders a body when body is passed', () => {
|
|
211
|
+
render(<Checkbox id="test-id" body="test body" />);
|
|
212
|
+
|
|
213
|
+
expect(screen.getByText('test body')).toBeVisible();
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
test(`Renders the passed body with the ${styles.checkBody} className`, () => {
|
|
217
|
+
render(<Checkbox id="test-id" body="test body" />);
|
|
218
|
+
|
|
219
|
+
expect(screen.getByText('test body')).toHaveClass(styles.checkBody, { exact: true });
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
test('Renders the check wrapper as a div by default', () => {
|
|
223
|
+
render(<Checkbox id="test-id" />);
|
|
224
|
+
|
|
225
|
+
expect(screen.getByRole('checkbox').parentElement?.tagName).toBe('DIV');
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
test('Renders with the provided component', () => {
|
|
229
|
+
render(<Checkbox id="test-id" component="span" />);
|
|
230
|
+
|
|
231
|
+
expect(screen.getByRole('checkbox').parentElement?.tagName).toBe('SPAN');
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
test(`Spreads additional props`, () => {
|
|
235
|
+
render(<Checkbox id="test-id" data-testid="test-id" />);
|
|
236
|
+
|
|
237
|
+
expect(screen.getByTestId('test-id')).toBeInTheDocument();
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
test(`Sets the checkbox as checked by default when defaultChecked is passed`, () => {
|
|
241
|
+
render(<Checkbox id="test-id" defaultChecked />);
|
|
242
|
+
|
|
243
|
+
expect(screen.getByRole('checkbox')).toBeChecked();
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
test('Matches snapshot', () => {
|
|
247
|
+
const { asFragment } = render(<Checkbox id="test-id" ouiaId="ouia-id" />);
|
|
248
|
+
|
|
249
|
+
expect(asFragment()).toMatchSnapshot();
|
|
96
250
|
});
|
|
@@ -1,212 +1,17 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`
|
|
3
|
+
exports[`Matches snapshot 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
5
5
|
<div
|
|
6
6
|
class="pf-v5-c-check pf-m-standalone"
|
|
7
7
|
>
|
|
8
8
|
<input
|
|
9
9
|
aria-invalid="false"
|
|
10
|
-
aria-label="check"
|
|
11
10
|
class="pf-v5-c-check__input"
|
|
12
|
-
data-ouia-component-id="
|
|
11
|
+
data-ouia-component-id="ouia-id"
|
|
13
12
|
data-ouia-component-type="PF5/Checkbox"
|
|
14
13
|
data-ouia-safe="true"
|
|
15
|
-
id="
|
|
16
|
-
type="checkbox"
|
|
17
|
-
/>
|
|
18
|
-
</div>
|
|
19
|
-
</DocumentFragment>
|
|
20
|
-
`;
|
|
21
|
-
|
|
22
|
-
exports[`Checkbox controlled 1`] = `
|
|
23
|
-
<DocumentFragment>
|
|
24
|
-
<div
|
|
25
|
-
class="pf-v5-c-check pf-m-standalone"
|
|
26
|
-
>
|
|
27
|
-
<input
|
|
28
|
-
aria-invalid="false"
|
|
29
|
-
aria-label="check"
|
|
30
|
-
checked=""
|
|
31
|
-
class="pf-v5-c-check__input"
|
|
32
|
-
data-ouia-component-id="OUIA-Generated-Checkbox-1"
|
|
33
|
-
data-ouia-component-type="PF5/Checkbox"
|
|
34
|
-
data-ouia-safe="true"
|
|
35
|
-
id="check"
|
|
36
|
-
type="checkbox"
|
|
37
|
-
/>
|
|
38
|
-
</div>
|
|
39
|
-
</DocumentFragment>
|
|
40
|
-
`;
|
|
41
|
-
|
|
42
|
-
exports[`Checkbox isDisabled 1`] = `
|
|
43
|
-
<DocumentFragment>
|
|
44
|
-
<div
|
|
45
|
-
class="pf-v5-c-check pf-m-standalone"
|
|
46
|
-
>
|
|
47
|
-
<input
|
|
48
|
-
aria-invalid="false"
|
|
49
|
-
aria-label="check"
|
|
50
|
-
class="pf-v5-c-check__input"
|
|
51
|
-
data-ouia-component-id="OUIA-Generated-Checkbox-4"
|
|
52
|
-
data-ouia-component-type="PF5/Checkbox"
|
|
53
|
-
data-ouia-safe="true"
|
|
54
|
-
disabled=""
|
|
55
|
-
id="check"
|
|
56
|
-
type="checkbox"
|
|
57
|
-
/>
|
|
58
|
-
</div>
|
|
59
|
-
</DocumentFragment>
|
|
60
|
-
`;
|
|
61
|
-
|
|
62
|
-
exports[`Checkbox label is function 1`] = `
|
|
63
|
-
<DocumentFragment>
|
|
64
|
-
<div
|
|
65
|
-
class="pf-v5-c-check"
|
|
66
|
-
>
|
|
67
|
-
<input
|
|
68
|
-
aria-invalid="false"
|
|
69
|
-
aria-label="check"
|
|
70
|
-
checked=""
|
|
71
|
-
class="pf-v5-c-check__input"
|
|
72
|
-
data-ouia-component-id="OUIA-Generated-Checkbox-6"
|
|
73
|
-
data-ouia-component-type="PF5/Checkbox"
|
|
74
|
-
data-ouia-safe="true"
|
|
75
|
-
id="check"
|
|
76
|
-
type="checkbox"
|
|
77
|
-
/>
|
|
78
|
-
<label
|
|
79
|
-
class="pf-v5-c-check__label"
|
|
80
|
-
for="check"
|
|
81
|
-
>
|
|
82
|
-
<h1>
|
|
83
|
-
Header
|
|
84
|
-
</h1>
|
|
85
|
-
</label>
|
|
86
|
-
</div>
|
|
87
|
-
</DocumentFragment>
|
|
88
|
-
`;
|
|
89
|
-
|
|
90
|
-
exports[`Checkbox label is node 1`] = `
|
|
91
|
-
<DocumentFragment>
|
|
92
|
-
<div
|
|
93
|
-
class="pf-v5-c-check"
|
|
94
|
-
>
|
|
95
|
-
<input
|
|
96
|
-
aria-invalid="false"
|
|
97
|
-
aria-label="check"
|
|
98
|
-
checked=""
|
|
99
|
-
class="pf-v5-c-check__input"
|
|
100
|
-
data-ouia-component-id="OUIA-Generated-Checkbox-7"
|
|
101
|
-
data-ouia-component-type="PF5/Checkbox"
|
|
102
|
-
data-ouia-safe="true"
|
|
103
|
-
id="check"
|
|
104
|
-
type="checkbox"
|
|
105
|
-
/>
|
|
106
|
-
<label
|
|
107
|
-
class="pf-v5-c-check__label"
|
|
108
|
-
for="check"
|
|
109
|
-
>
|
|
110
|
-
<h1>
|
|
111
|
-
Header
|
|
112
|
-
</h1>
|
|
113
|
-
</label>
|
|
114
|
-
</div>
|
|
115
|
-
</DocumentFragment>
|
|
116
|
-
`;
|
|
117
|
-
|
|
118
|
-
exports[`Checkbox label is string 1`] = `
|
|
119
|
-
<DocumentFragment>
|
|
120
|
-
<div
|
|
121
|
-
class="pf-v5-c-check"
|
|
122
|
-
>
|
|
123
|
-
<input
|
|
124
|
-
aria-invalid="false"
|
|
125
|
-
aria-label="check"
|
|
126
|
-
checked=""
|
|
127
|
-
class="pf-v5-c-check__input"
|
|
128
|
-
data-ouia-component-id="OUIA-Generated-Checkbox-5"
|
|
129
|
-
data-ouia-component-type="PF5/Checkbox"
|
|
130
|
-
data-ouia-safe="true"
|
|
131
|
-
id="check"
|
|
132
|
-
type="checkbox"
|
|
133
|
-
/>
|
|
134
|
-
<label
|
|
135
|
-
class="pf-v5-c-check__label"
|
|
136
|
-
for="check"
|
|
137
|
-
>
|
|
138
|
-
Label
|
|
139
|
-
</label>
|
|
140
|
-
</div>
|
|
141
|
-
</DocumentFragment>
|
|
142
|
-
`;
|
|
143
|
-
|
|
144
|
-
exports[`Checkbox passing HTML attribute 1`] = `
|
|
145
|
-
<DocumentFragment>
|
|
146
|
-
<div
|
|
147
|
-
class="pf-v5-c-check"
|
|
148
|
-
>
|
|
149
|
-
<input
|
|
150
|
-
aria-invalid="false"
|
|
151
|
-
aria-label="check"
|
|
152
|
-
aria-labelledby="labelId"
|
|
153
|
-
checked=""
|
|
154
|
-
class="pf-v5-c-check__input"
|
|
155
|
-
data-ouia-component-id="OUIA-Generated-Checkbox-9"
|
|
156
|
-
data-ouia-component-type="PF5/Checkbox"
|
|
157
|
-
data-ouia-safe="true"
|
|
158
|
-
id="check"
|
|
159
|
-
type="checkbox"
|
|
160
|
-
/>
|
|
161
|
-
<label
|
|
162
|
-
class="pf-v5-c-check__label"
|
|
163
|
-
for="check"
|
|
164
|
-
>
|
|
165
|
-
label
|
|
166
|
-
</label>
|
|
167
|
-
</div>
|
|
168
|
-
</DocumentFragment>
|
|
169
|
-
`;
|
|
170
|
-
|
|
171
|
-
exports[`Checkbox passing class 1`] = `
|
|
172
|
-
<DocumentFragment>
|
|
173
|
-
<div
|
|
174
|
-
class="pf-v5-c-check class-123"
|
|
175
|
-
>
|
|
176
|
-
<input
|
|
177
|
-
aria-invalid="false"
|
|
178
|
-
aria-label="check"
|
|
179
|
-
checked=""
|
|
180
|
-
class="pf-v5-c-check__input"
|
|
181
|
-
data-ouia-component-id="OUIA-Generated-Checkbox-8"
|
|
182
|
-
data-ouia-component-type="PF5/Checkbox"
|
|
183
|
-
data-ouia-safe="true"
|
|
184
|
-
id="check"
|
|
185
|
-
type="checkbox"
|
|
186
|
-
/>
|
|
187
|
-
<label
|
|
188
|
-
class="pf-v5-c-check__label"
|
|
189
|
-
for="check"
|
|
190
|
-
>
|
|
191
|
-
label
|
|
192
|
-
</label>
|
|
193
|
-
</div>
|
|
194
|
-
</DocumentFragment>
|
|
195
|
-
`;
|
|
196
|
-
|
|
197
|
-
exports[`Checkbox uncontrolled 1`] = `
|
|
198
|
-
<DocumentFragment>
|
|
199
|
-
<div
|
|
200
|
-
class="pf-v5-c-check pf-m-standalone"
|
|
201
|
-
>
|
|
202
|
-
<input
|
|
203
|
-
aria-invalid="false"
|
|
204
|
-
aria-label="check"
|
|
205
|
-
class="pf-v5-c-check__input"
|
|
206
|
-
data-ouia-component-id="OUIA-Generated-Checkbox-3"
|
|
207
|
-
data-ouia-component-type="PF5/Checkbox"
|
|
208
|
-
data-ouia-safe="true"
|
|
209
|
-
id="check"
|
|
14
|
+
id="test-id"
|
|
210
15
|
type="checkbox"
|
|
211
16
|
/>
|
|
212
17
|
</div>
|
|
@@ -143,7 +143,7 @@ class ExpandableSection extends React.Component<ExpandableSectionProps, Expandab
|
|
|
143
143
|
componentDidUpdate(prevProps: ExpandableSectionProps) {
|
|
144
144
|
if (
|
|
145
145
|
this.props.variant === ExpandableSectionVariant.truncate &&
|
|
146
|
-
prevProps.truncateMaxLines !== this.props.truncateMaxLines
|
|
146
|
+
(prevProps.truncateMaxLines !== this.props.truncateMaxLines || prevProps.children !== this.props.children)
|
|
147
147
|
) {
|
|
148
148
|
const expandableContent = this.expandableContentRef.current;
|
|
149
149
|
setLineClamp(this.props.truncateMaxLines, expandableContent);
|