@patternfly/react-core 5.2.0-prerelease.14 → 5.2.0-prerelease.16

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 (134) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/components/package.json +1 -1
  3. package/deprecated/package.json +1 -1
  4. package/dist/dynamic/components/AboutModal/package.json +1 -1
  5. package/dist/dynamic/components/Accordion/package.json +1 -1
  6. package/dist/dynamic/components/ActionList/package.json +1 -1
  7. package/dist/dynamic/components/Alert/package.json +1 -1
  8. package/dist/dynamic/components/Avatar/package.json +1 -1
  9. package/dist/dynamic/components/BackToTop/package.json +1 -1
  10. package/dist/dynamic/components/Backdrop/package.json +1 -1
  11. package/dist/dynamic/components/BackgroundImage/package.json +1 -1
  12. package/dist/dynamic/components/Badge/package.json +1 -1
  13. package/dist/dynamic/components/Banner/package.json +1 -1
  14. package/dist/dynamic/components/Brand/package.json +1 -1
  15. package/dist/dynamic/components/Breadcrumb/package.json +1 -1
  16. package/dist/dynamic/components/Button/package.json +1 -1
  17. package/dist/dynamic/components/CalendarMonth/package.json +1 -1
  18. package/dist/dynamic/components/Card/package.json +1 -1
  19. package/dist/dynamic/components/Checkbox/package.json +1 -1
  20. package/dist/dynamic/components/Chip/package.json +1 -1
  21. package/dist/dynamic/components/ClipboardCopy/package.json +1 -1
  22. package/dist/dynamic/components/CodeBlock/package.json +1 -1
  23. package/dist/dynamic/components/DataList/package.json +1 -1
  24. package/dist/dynamic/components/DatePicker/package.json +1 -1
  25. package/dist/dynamic/components/DescriptionList/package.json +1 -1
  26. package/dist/dynamic/components/Divider/package.json +1 -1
  27. package/dist/dynamic/components/DragDrop/package.json +1 -1
  28. package/dist/dynamic/components/Drawer/package.json +1 -1
  29. package/dist/dynamic/components/Dropdown/package.json +1 -1
  30. package/dist/dynamic/components/DualListSelector/package.json +1 -1
  31. package/dist/dynamic/components/EmptyState/package.json +1 -1
  32. package/dist/dynamic/components/ExpandableSection/package.json +1 -1
  33. package/dist/dynamic/components/FileUpload/package.json +1 -1
  34. package/dist/dynamic/components/Form/package.json +1 -1
  35. package/dist/dynamic/components/FormSelect/package.json +1 -1
  36. package/dist/dynamic/components/HelperText/package.json +1 -1
  37. package/dist/dynamic/components/Hint/package.json +1 -1
  38. package/dist/dynamic/components/Icon/package.json +1 -1
  39. package/dist/dynamic/components/InputGroup/package.json +1 -1
  40. package/dist/dynamic/components/JumpLinks/package.json +1 -1
  41. package/dist/dynamic/components/Label/package.json +1 -1
  42. package/dist/dynamic/components/List/package.json +1 -1
  43. package/dist/dynamic/components/LoginPage/package.json +1 -1
  44. package/dist/dynamic/components/Masthead/package.json +1 -1
  45. package/dist/dynamic/components/Menu/package.json +1 -1
  46. package/dist/dynamic/components/MenuToggle/package.json +1 -1
  47. package/dist/dynamic/components/Modal/package.json +1 -1
  48. package/dist/dynamic/components/MultipleFileUpload/package.json +1 -1
  49. package/dist/dynamic/components/Nav/package.json +1 -1
  50. package/dist/dynamic/components/NotificationBadge/package.json +1 -1
  51. package/dist/dynamic/components/NotificationDrawer/package.json +1 -1
  52. package/dist/dynamic/components/NumberInput/package.json +1 -1
  53. package/dist/dynamic/components/OverflowMenu/package.json +1 -1
  54. package/dist/dynamic/components/Page/package.json +1 -1
  55. package/dist/dynamic/components/Pagination/package.json +1 -1
  56. package/dist/dynamic/components/Panel/package.json +1 -1
  57. package/dist/dynamic/components/Popover/package.json +1 -1
  58. package/dist/dynamic/components/Progress/package.json +1 -1
  59. package/dist/dynamic/components/ProgressStepper/package.json +1 -1
  60. package/dist/dynamic/components/Radio/package.json +1 -1
  61. package/dist/dynamic/components/SearchInput/package.json +1 -1
  62. package/dist/dynamic/components/Select/package.json +1 -1
  63. package/dist/dynamic/components/Sidebar/package.json +1 -1
  64. package/dist/dynamic/components/SimpleList/package.json +1 -1
  65. package/dist/dynamic/components/Skeleton/package.json +1 -1
  66. package/dist/dynamic/components/SkipToContent/package.json +1 -1
  67. package/dist/dynamic/components/Slider/package.json +1 -1
  68. package/dist/dynamic/components/Spinner/package.json +1 -1
  69. package/dist/dynamic/components/Switch/package.json +1 -1
  70. package/dist/dynamic/components/Tabs/package.json +1 -1
  71. package/dist/dynamic/components/Text/package.json +1 -1
  72. package/dist/dynamic/components/TextArea/package.json +1 -1
  73. package/dist/dynamic/components/TextInput/package.json +1 -1
  74. package/dist/dynamic/components/TextInputGroup/package.json +1 -1
  75. package/dist/dynamic/components/Tile/package.json +1 -1
  76. package/dist/dynamic/components/TimePicker/package.json +1 -1
  77. package/dist/dynamic/components/Timestamp/package.json +1 -1
  78. package/dist/dynamic/components/Title/package.json +1 -1
  79. package/dist/dynamic/components/ToggleGroup/package.json +1 -1
  80. package/dist/dynamic/components/Toolbar/package.json +1 -1
  81. package/dist/dynamic/components/Tooltip/package.json +1 -1
  82. package/dist/dynamic/components/TreeView/package.json +1 -1
  83. package/dist/dynamic/components/Truncate/package.json +1 -1
  84. package/dist/dynamic/components/Wizard/hooks/package.json +1 -1
  85. package/dist/dynamic/components/Wizard/package.json +1 -1
  86. package/dist/dynamic/deprecated/components/ApplicationLauncher/package.json +1 -1
  87. package/dist/dynamic/deprecated/components/ContextSelector/package.json +1 -1
  88. package/dist/dynamic/deprecated/components/Dropdown/package.json +1 -1
  89. package/dist/dynamic/deprecated/components/OptionsMenu/package.json +1 -1
  90. package/dist/dynamic/deprecated/components/PageHeader/package.json +1 -1
  91. package/dist/dynamic/deprecated/components/Select/package.json +1 -1
  92. package/dist/dynamic/deprecated/components/Wizard/package.json +1 -1
  93. package/dist/dynamic/deprecated/components/package.json +1 -1
  94. package/dist/dynamic/helpers/FocusTrap/FocusTrap/package.json +1 -1
  95. package/dist/dynamic/helpers/GenerateId/GenerateId/package.json +1 -1
  96. package/dist/dynamic/helpers/KeyboardHandler/package.json +1 -1
  97. package/dist/dynamic/helpers/OUIA/ouia/package.json +1 -1
  98. package/dist/dynamic/helpers/Popper/Popper/package.json +1 -1
  99. package/dist/dynamic/helpers/constants/package.json +1 -1
  100. package/dist/dynamic/helpers/datetimeUtils/package.json +1 -1
  101. package/dist/dynamic/helpers/favorites/package.json +1 -1
  102. package/dist/dynamic/helpers/fileUtils/package.json +1 -1
  103. package/dist/dynamic/helpers/htmlConstants/package.json +1 -1
  104. package/dist/dynamic/helpers/package.json +1 -1
  105. package/dist/dynamic/helpers/resizeObserver/package.json +1 -1
  106. package/dist/dynamic/helpers/typeUtils/package.json +1 -1
  107. package/dist/dynamic/helpers/useInterval/package.json +1 -1
  108. package/dist/dynamic/helpers/useIsomorphicLayout/package.json +1 -1
  109. package/dist/dynamic/helpers/useUnmountEffect/package.json +1 -1
  110. package/dist/dynamic/helpers/util/package.json +1 -1
  111. package/dist/dynamic/layouts/Bullseye/package.json +1 -1
  112. package/dist/dynamic/layouts/Flex/package.json +1 -1
  113. package/dist/dynamic/layouts/Gallery/package.json +1 -1
  114. package/dist/dynamic/layouts/Grid/package.json +1 -1
  115. package/dist/dynamic/layouts/Level/package.json +1 -1
  116. package/dist/dynamic/layouts/Split/package.json +1 -1
  117. package/dist/dynamic/layouts/Stack/package.json +1 -1
  118. package/dist/dynamic/next/components/package.json +1 -1
  119. package/dist/esm/components/Chip/Chip.d.ts.map +1 -1
  120. package/dist/esm/components/Chip/Chip.js +2 -2
  121. package/dist/esm/components/Chip/Chip.js.map +1 -1
  122. package/dist/js/components/Chip/Chip.d.ts.map +1 -1
  123. package/dist/js/components/Chip/Chip.js +2 -2
  124. package/dist/js/components/Chip/Chip.js.map +1 -1
  125. package/dist/umd/react-core.min.js +1 -1
  126. package/helpers/package.json +1 -1
  127. package/layouts/package.json +1 -1
  128. package/next/package.json +1 -1
  129. package/package.json +6 -6
  130. package/src/components/Chip/Chip.tsx +2 -1
  131. package/src/components/Chip/__tests__/Chip.test.tsx +249 -32
  132. package/src/components/Chip/__tests__/ChipGroup.test.tsx +288 -61
  133. package/src/components/Chip/__tests__/__snapshots__/Chip.test.tsx.snap +9 -209
  134. package/src/components/Chip/__tests__/__snapshots__/ChipGroup.test.tsx.snap +2 -313
@@ -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.13","private":true}
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.15","private":true}
@@ -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.13","private":true}
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.15","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.13","private":true}
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.15","private":true}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "5.2.0-prerelease.14",
3
+ "version": "5.2.0-prerelease.16",
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",
@@ -45,15 +45,15 @@
45
45
  "subpaths": "node ../../scripts/exportSubpaths.js --config subpaths.config.json"
46
46
  },
47
47
  "dependencies": {
48
- "@patternfly/react-icons": "^5.2.0-prerelease.3",
49
- "@patternfly/react-styles": "^5.2.0-prerelease.2",
50
- "@patternfly/react-tokens": "^5.2.0-prerelease.3",
48
+ "@patternfly/react-icons": "^5.2.0-prerelease.5",
49
+ "@patternfly/react-styles": "^5.2.0-prerelease.3",
50
+ "@patternfly/react-tokens": "^5.2.0-prerelease.4",
51
51
  "focus-trap": "7.5.2",
52
52
  "react-dropzone": "^14.2.3",
53
53
  "tslib": "^2.5.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@patternfly/patternfly": "5.2.0-prerelease.2",
56
+ "@patternfly/patternfly": "5.2.0-prerelease.3",
57
57
  "@rollup/plugin-commonjs": "^25.0.0",
58
58
  "@rollup/plugin-node-resolve": "^15.0.2",
59
59
  "@rollup/plugin-replace": "^5.0.2",
@@ -71,5 +71,5 @@
71
71
  "react": "^17 || ^18",
72
72
  "react-dom": "^17 || ^18"
73
73
  },
74
- "gitHead": "7d28e1d3fd8219525537a122a54ab939b6e55647"
74
+ "gitHead": "bbd82ab078a6512692d8f6253a80cf87242f775a"
75
75
  }
@@ -140,12 +140,13 @@ class Chip extends React.Component<ChipProps, ChipState> {
140
140
  tooltipPosition,
141
141
  component,
142
142
  ouiaId,
143
+ textMaxWidth,
143
144
  ...props
144
145
  } = this.props;
145
146
  const Component = component as any;
146
147
  return (
147
148
  <Component
148
- {...(this.props.textMaxWidth && {
149
+ {...(textMaxWidth && {
149
150
  style: this.setChipStyle()
150
151
  })}
151
152
  className={css(styles.chip, className)}
@@ -1,59 +1,276 @@
1
1
  import React from 'react';
2
- import { render } from '@testing-library/react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
3
4
  import { Chip } from '../Chip';
5
+ import styles from '@patternfly/react-styles/css/components/Chip/chip';
4
6
 
5
- describe('Chip', () => {
6
- test('overflow', () => {
7
- const { asFragment } = render(
8
- <Chip className="my-chp-cls" isOverflowChip>
9
- 4 more
7
+ jest.mock('../../Tooltip', () => ({
8
+ Tooltip: ({ content, position }) => (
9
+ <div data-testid="tooltip-mock">
10
+ <p>{`content: ${content}`}</p>
11
+ <p>{`position: ${position}`}</p>
12
+ </div>
13
+ )
14
+ }));
15
+
16
+ ['default chip', 'overflow chip'].forEach((chipType) => {
17
+ const isOverflowChip = chipType === 'overflow chip';
18
+
19
+ test(`Renders without children for ${chipType}`, () => {
20
+ render(
21
+ <div data-testid="container">
22
+ <Chip isOverflowChip={isOverflowChip} />
23
+ </div>
24
+ );
25
+
26
+ expect(screen.getByTestId('container').firstChild).toBeVisible();
27
+ });
28
+
29
+ test(`Renders with class ${styles.chip} on the ${chipType} container element`, () => {
30
+ render(
31
+ <Chip isOverflowChip={isOverflowChip} data-testid="container">
32
+ Chip text
33
+ </Chip>
34
+ );
35
+
36
+ // Only a non-overflow chip will have exactly the class "pf-v5-c-chip", we test for
37
+ // additional classes on overflow chips elsewhere in the suite
38
+ expect(screen.getByTestId('container')).toHaveClass(styles.chip, { exact: !isOverflowChip });
39
+ });
40
+
41
+ test(`Renders with class ${styles.chipContent} around the ${chipType} content`, () => {
42
+ render(
43
+ <Chip isOverflowChip={isOverflowChip} data-testid="container">
44
+ Chip text
10
45
  </Chip>
11
46
  );
12
- expect(asFragment()).toMatchSnapshot();
47
+
48
+ expect(screen.getByTestId('container').firstChild).toHaveClass(styles.chipContent, { exact: true });
49
+ });
50
+
51
+ test(`Renders ${chipType} children with class ${styles.chipText}`, () => {
52
+ render(<Chip isOverflowChip={isOverflowChip}>Chip text</Chip>);
53
+
54
+ expect(screen.getByText('Chip text')).toHaveClass(styles.chipText, { exact: true });
13
55
  });
14
56
 
15
- test('closable', () => {
16
- const { asFragment } = render(
17
- <Chip className="my-chp-cls" id="chip_one">
18
- Chip
57
+ test(`Renders with custom class on the ${chipType} container element`, () => {
58
+ render(
59
+ <Chip isOverflowChip={isOverflowChip} data-testid="container" className="custom-class">
60
+ Chip text
19
61
  </Chip>
20
62
  );
21
- expect(asFragment()).toMatchSnapshot();
63
+
64
+ expect(screen.getByTestId('container')).toHaveClass('custom-class');
22
65
  });
23
66
 
24
- test('closable with tooltip', () => {
25
- const { asFragment } = render(
26
- <Chip className="my-chp-cls" id="chip_one">
27
- 1234567890123456789
67
+ test(`Renders a badge when badge prop is passed to ${chipType}`, () => {
68
+ render(
69
+ <Chip isOverflowChip={isOverflowChip} badge={<div>Badge content</div>}>
70
+ Chip text
28
71
  </Chip>
29
72
  );
30
- expect(asFragment()).toMatchSnapshot();
73
+
74
+ expect(screen.getByText('Badge content')).toBeVisible();
75
+ });
76
+
77
+ test(`Renders with div container on ${chipType} by default`, () => {
78
+ render(
79
+ <Chip isOverflowChip={isOverflowChip} data-testid="container">
80
+ Chip text
81
+ </Chip>
82
+ );
83
+
84
+ expect(screen.getByTestId('container').tagName).toBe('DIV');
31
85
  });
32
86
 
33
- test('readonly', () => {
34
- const { asFragment } = render(
35
- <Chip className="my-chp-cls" isReadOnly>
36
- 4 more
87
+ test(`Renders with custom container on ${chipType} when component prop is passed`, () => {
88
+ render(
89
+ <Chip component="li" isOverflowChip={isOverflowChip}>
90
+ Chip text
37
91
  </Chip>
38
92
  );
39
- expect(asFragment()).toMatchSnapshot();
93
+
94
+ expect(screen.getByRole('listitem')).toBeVisible();
40
95
  });
41
96
 
42
- test('custom max-width text', () => {
43
- const { asFragment } = render(
44
- <Chip className="my-chp-cls" textMaxWidth="100px">
45
- 4 more
97
+ test(`Renders maxWidth css var in style attribute when textMaxWidth is passed for ${chipType}`, () => {
98
+ render(
99
+ <Chip isOverflowChip={isOverflowChip} data-testid="container" textMaxWidth="10px">
100
+ Chip text
46
101
  </Chip>
47
102
  );
48
- expect(asFragment()).toMatchSnapshot();
103
+
104
+ expect(screen.getByTestId('container')).toHaveAttribute('style', '--pf-v5-c-chip__text--MaxWidth: 10px;');
49
105
  });
50
106
 
51
- test("with role='gridcell'", () => {
52
- const { asFragment } = render(
53
- <Chip className="my-chp-cls" role="gridcell">
54
- I'm a roled chip
107
+ test(`Spreads additional props to container for ${chipType}`, () => {
108
+ render(
109
+ <Chip isOverflowChip={isOverflowChip} data-testid="container" role="button">
110
+ Chip text
55
111
  </Chip>
56
112
  );
57
- expect(asFragment()).toMatchSnapshot();
113
+
114
+ expect(screen.getByTestId('container')).toHaveAttribute('role', 'button');
58
115
  });
59
116
  });
117
+
118
+ test(`Renders id prop on ${styles.chipText} container for default chip`, () => {
119
+ render(<Chip id="custom-id">Chip text</Chip>);
120
+
121
+ expect(screen.getByText('Chip text')).toHaveAttribute('id', 'custom-id');
122
+ });
123
+
124
+ test(`Does not render id prop on ${styles.chipText} container for overflow chip`, () => {
125
+ render(
126
+ <Chip isOverflowChip id="custom-id">
127
+ Chip text
128
+ </Chip>
129
+ );
130
+
131
+ expect(screen.getByText('Chip text')).not.toHaveAttribute('id');
132
+ });
133
+
134
+ test(`Renders actions container with class ${styles.chipActions} when isReadOnly is false`, () => {
135
+ render(<Chip>Chip text</Chip>);
136
+
137
+ expect(screen.getByRole('button').parentElement).toHaveClass(styles.chipActions);
138
+ });
139
+
140
+ test(`Renders aria-labelledby on action close button by default`, () => {
141
+ render(<Chip>Chip text</Chip>);
142
+
143
+ expect(screen.getByRole('button')).toHaveAccessibleName('close Chip text');
144
+ });
145
+
146
+ test(`Renders aria-labelledby on action close button with custom id passed`, () => {
147
+ render(<Chip id="custom-id">Chip text</Chip>);
148
+
149
+ expect(screen.getByRole('button')).toHaveAccessibleName('close Chip text');
150
+ });
151
+
152
+ test(`Renders concatenated aria-label on action close button by default`, () => {
153
+ render(<Chip>Chip text</Chip>);
154
+
155
+ expect(screen.getByRole('button')).toHaveAccessibleName('close Chip text');
156
+ });
157
+
158
+ test(`Renders custom aria-label on action close button when closeBtnAriaLabel is passed`, () => {
159
+ render(<Chip closeBtnAriaLabel="custom label">Chip text</Chip>);
160
+
161
+ expect(screen.getByRole('button')).toHaveAccessibleName('custom label Chip text');
162
+ });
163
+
164
+ test(`Does not render close button action when isOverflowChip is true`, () => {
165
+ render(<Chip isOverflowChip>Chip text</Chip>);
166
+
167
+ // Because overflow chip renders as a button, we need to add the accessible name to the query
168
+ expect(screen.queryByRole('button', { name: 'close Chip text' })).not.toBeInTheDocument();
169
+ });
170
+
171
+ test(`Does not render close button action when isReadOnly is true`, () => {
172
+ render(<Chip isReadOnly>Chip text</Chip>);
173
+
174
+ expect(screen.queryByRole('button')).not.toBeInTheDocument();
175
+ });
176
+
177
+ test(`Does not render with class ${styles.modifiers.overflow} when isOverflowChip is not passed`, () => {
178
+ render(<Chip data-testid="container">Chip text</Chip>);
179
+
180
+ expect(screen.getByTestId('container')).not.toHaveClass(styles.modifiers.overflow);
181
+ });
182
+
183
+ test(`Renders with class ${styles.modifiers.overflow} when isOverflowChip is true`, () => {
184
+ render(
185
+ <Chip isOverflowChip data-testid="container">
186
+ Chip text
187
+ </Chip>
188
+ );
189
+
190
+ expect(screen.getByTestId('container')).toHaveClass(styles.modifiers.overflow);
191
+ });
192
+
193
+ test(`Calls onClick when close button action is clicked for default chip`, async () => {
194
+ const user = userEvent.setup();
195
+ const onClickMock = jest.fn();
196
+
197
+ render(<Chip onClick={onClickMock}>Chip text</Chip>);
198
+
199
+ await user.click(screen.getByRole('button', { name: 'close Chip text' }));
200
+
201
+ expect(onClickMock).toHaveBeenCalledTimes(1);
202
+ });
203
+
204
+ test(`Does not call onClick when close button action is not clicked for default chip`, async () => {
205
+ const user = userEvent.setup();
206
+ const onClickMock = jest.fn();
207
+
208
+ render(
209
+ <>
210
+ <Chip onClick={onClickMock}>Chip text</Chip>
211
+ <button>Test clicker</button>
212
+ </>
213
+ );
214
+
215
+ await user.click(screen.getByRole('button', { name: 'Test clicker' }));
216
+
217
+ expect(onClickMock).not.toHaveBeenCalled();
218
+ });
219
+
220
+ test(`Calls onClick when chip is clicked for overflow chip`, async () => {
221
+ const user = userEvent.setup();
222
+ const onClickMock = jest.fn();
223
+
224
+ render(
225
+ <Chip isOverflowChip component="button" onClick={onClickMock}>
226
+ Chip text
227
+ </Chip>
228
+ );
229
+
230
+ await user.click(screen.getByRole('button', { name: 'Chip text' }));
231
+
232
+ expect(onClickMock).toHaveBeenCalledTimes(1);
233
+ });
234
+
235
+ test(`Does not call onClick when chip is not clicked for overflow chip`, async () => {
236
+ const user = userEvent.setup();
237
+ const onClickMock = jest.fn();
238
+
239
+ render(
240
+ <>
241
+ <Chip isOverflowChip component="button" onClick={onClickMock}>
242
+ Chip text
243
+ </Chip>
244
+ <button>Test clicker</button>
245
+ </>
246
+ );
247
+
248
+ await user.click(screen.getByRole('button', { name: 'Test clicker' }));
249
+
250
+ expect(onClickMock).not.toHaveBeenCalled();
251
+ });
252
+
253
+ test('Passes position to Tooltip', () => {
254
+ Object.defineProperty(HTMLElement.prototype, 'scrollWidth', { configurable: true, value: 500 });
255
+ render(<Chip tooltipPosition="bottom">Test chip text</Chip>);
256
+
257
+ expect(screen.getByText('position: bottom')).toBeVisible();
258
+ Object.defineProperty(HTMLElement.prototype, 'scrollWidth', { configurable: true, value: 0 });
259
+ });
260
+
261
+ test('Passes content to Tooltip', () => {
262
+ Object.defineProperty(HTMLElement.prototype, 'scrollWidth', { configurable: true, value: 500 });
263
+ render(<Chip>Test chip text</Chip>);
264
+
265
+ expect(screen.getByText(`content: Test chip text`)).toBeVisible();
266
+ Object.defineProperty(HTMLElement.prototype, 'scrollWidth', { configurable: true, value: 0 });
267
+ });
268
+
269
+ test('Matches snapshot', () => {
270
+ const { asFragment } = render(
271
+ <Chip id="snapshot-test" ouiaId="snapshot-test">
272
+ Chip text
273
+ </Chip>
274
+ );
275
+ expect(asFragment()).toMatchSnapshot();
276
+ });