Skip to content

Commit 25ce526

Browse files
committed
Add tests and deprecate prop
1 parent bdc821d commit 25ce526

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

packages/react-core/src/components/ClipboardCopy/ClipboardCopyButton.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export interface ClipboardCopyButtonProps
1111
children: React.ReactNode;
1212
/** ID of the copy button */
1313
id: string;
14+
/** @deprecated ID of the content that is being copied */
15+
textId?: string;
1416
/** Additional classes added to the copy button */
1517
className?: string;
1618
/** Exit delay on the copy button tooltip */

packages/react-core/src/components/ClipboardCopy/__tests__/ClipboardCopy.test.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jest.mock('../ClipboardCopyButton', () => ({
1313
<p>{`entryDelay: ${entryDelay}`}</p>
1414
<p>{`maxWidth: ${maxWidth}`}</p>
1515
<p>{`position: ${position}`}</p>
16-
<p>{`button-ariaLabel: ${ariaLabel}`}</p>
16+
<p>{`ariaLabel: ${ariaLabel}`}</p>
1717
<div>{`children: ${children}`}</div>
1818
<button onClick={onClick}>Test CCB clicker</button>
1919
</div>
@@ -177,7 +177,7 @@ test('Renders content passed to additionalActions when variant is inline-compact
177177
test('Passes hoverTip to ClipboardCopyButton by default', () => {
178178
render(<ClipboardCopy hoverTip="hover tip">{children}</ClipboardCopy>);
179179

180-
expect(screen.getByText('button-ariaLabel: hover tip')).toBeVisible();
180+
expect(screen.getByText('ariaLabel: hover tip')).toBeVisible();
181181
expect(screen.getByText('children: hover tip')).toBeVisible();
182182
});
183183

@@ -188,7 +188,7 @@ test('Passes hoverTip to ClipboardCopyButton when variant is inline-compact', ()
188188
</ClipboardCopy>
189189
);
190190

191-
expect(screen.getByText('button-ariaLabel: hover tip')).toBeVisible();
191+
expect(screen.getByText('ariaLabel: hover tip')).toBeVisible();
192192
expect(screen.getByText('children: hover tip')).toBeVisible();
193193
});
194194

@@ -265,6 +265,12 @@ test('Passes position to ClipboardCopyButton when variant is inline-compact', ()
265265
expect(screen.getByText('position: bottom')).toBeVisible();
266266
});
267267

268+
test('Passes copyAriaLabel to ClipboardCopyButton', () => {
269+
render(<ClipboardCopy copyAriaLabel="Copy text">{children}</ClipboardCopy>);
270+
271+
expect(screen.getByText('ariaLabel: Copy text')).toBeVisible();
272+
});
273+
268274
test('Passes toggleAriaLabel to ClipboardCopyToggle when variant is expansion', () => {
269275
render(
270276
<ClipboardCopy variant="expansion" toggleAriaLabel="toggle label">

packages/react-core/src/components/ClipboardCopy/__tests__/__snapshots__/ClipboardCopy.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ exports[`Matches snapshot 1`] = `
1818
<input
1919
aria-invalid="false"
2020
aria-label="Copyable input"
21-
data-ouia-component-id="OUIA-Generated-TextInputBase-34"
21+
data-ouia-component-id="OUIA-Generated-TextInputBase-35"
2222
data-ouia-component-type="PF6/TextInput"
2323
data-ouia-safe="true"
2424
id="text-input-generated-id"
@@ -42,7 +42,7 @@ exports[`Matches snapshot 1`] = `
4242
position: top
4343
</p>
4444
<p>
45-
button-ariaLabel: Copy to clipboard
45+
ariaLabel: Copy to clipboard
4646
</p>
4747
<div>
4848
children: Copy to clipboard

0 commit comments

Comments
 (0)