Skip to content

Commit 399c551

Browse files
author
Eric Olkowski
committed
Added tests to check truncation only on inlinecompact variant
1 parent 96a3823 commit 399c551

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,46 @@ describe('ClipboardCopy with truncation', () => {
404404
expect(screen.queryByTestId(testId)?.querySelector(`.${truncateStyles.truncate}`)).not.toBeInTheDocument();
405405
});
406406

407+
test('Does not render with truncate wrapper when truncation is true and variant is not inline-compact', () => {
408+
render(
409+
<ClipboardCopy truncation data-testid={testId}>
410+
{children}
411+
</ClipboardCopy>
412+
);
413+
414+
expect(screen.queryByTestId(testId)?.querySelector(`.${truncateStyles.truncate}`)).not.toBeInTheDocument();
415+
});
416+
417+
test('Does not render with truncate wrapper when truncation is true and variant is expansion', () => {
418+
render(
419+
<ClipboardCopy variant={ClipboardCopyVariant.expansion} truncation data-testid={testId}>
420+
{children}
421+
</ClipboardCopy>
422+
);
423+
424+
expect(screen.queryByTestId(testId)?.querySelector(`.${truncateStyles.truncate}`)).not.toBeInTheDocument();
425+
});
426+
427+
test('Does not render with truncate wrapper when truncation is an object and variant is not inline-compact', () => {
428+
render(
429+
<ClipboardCopy truncation={{}} data-testid={testId}>
430+
{children}
431+
</ClipboardCopy>
432+
);
433+
434+
expect(screen.queryByTestId(testId)?.querySelector(`.${truncateStyles.truncate}`)).not.toBeInTheDocument();
435+
});
436+
437+
test('Does not render with truncate wrapper when truncation is an object and variant is expansion', () => {
438+
render(
439+
<ClipboardCopy variant={ClipboardCopyVariant.expansion} truncation={{}} data-testid={testId}>
440+
{children}
441+
</ClipboardCopy>
442+
);
443+
444+
expect(screen.queryByTestId(testId)?.querySelector(`.${truncateStyles.truncate}`)).not.toBeInTheDocument();
445+
});
446+
407447
test('Does not render with truncate wrapper when variant="inline-compact" and truncation is false', () => {
408448
render(<ClipboardCopy variant={ClipboardCopyVariant.inlineCompact}>{children}</ClipboardCopy>);
409449

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

Lines changed: 1 addition & 1 deletion
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-30"
21+
data-ouia-component-id="OUIA-Generated-TextInputBase-34"
2222
data-ouia-component-type="PF6/TextInput"
2323
data-ouia-safe="true"
2424
id="text-input-generated-id"

0 commit comments

Comments
 (0)