{renderedContent}
diff --git a/packages/react/src/components/Slug/__tests__/Slug-test.js b/packages/react/src/components/Slug/__tests__/Slug-test.js
new file mode 100644
index 000000000000..6bc51c862b53
--- /dev/null
+++ b/packages/react/src/components/Slug/__tests__/Slug-test.js
@@ -0,0 +1,94 @@
+/**
+ * Copyright IBM Corp. 2016, 2023
+ *
+ * This source code is licensed under the Apache-2.0 license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+import React from 'react';
+import { Slug } from '../../Slug';
+import { render, screen } from '@testing-library/react';
+
+const prefix = 'cds';
+
+describe('Slug', () => {
+ describe('renders as expected - Component API', () => {
+ it('should spread extra props onto the popover element', () => {
+ const { container } = render(
);
+
+ expect(container.firstChild.firstChild).toHaveAttribute(
+ 'data-testid',
+ 'test'
+ );
+ });
+
+ it('should render children as expected', () => {
+ render(
Children test);
+
+ expect(screen.getByText('Children test')).toBeInTheDocument();
+ });
+
+ it('should support a custom `className` prop on the outermost element', () => {
+ const { container } = render(
);
+
+ expect(container.firstChild).toHaveClass('custom-class');
+ });
+
+ it('should respect aiText prop', () => {
+ render(
);
+
+ expect(screen.getByText('IA')).toBeInTheDocument();
+ });
+
+ it('should respect aiTextLabel prop', () => {
+ render(
);
+
+ expect(screen.getByText('Test text')).toBeInTheDocument();
+ });
+
+ it('should respect align prop', () => {
+ render(
);
+
+ expect(screen.getByTestId('test')).toHaveClass(
+ `${prefix}--popover--left-bottom`
+ );
+ });
+
+ it('should respect dotType prop', () => {
+ const { container } = render(
);
+
+ expect(container.firstChild).toHaveClass(`${prefix}--slug--hollow`);
+ });
+
+ it('should respect kind prop', () => {
+ render(
);
+
+ expect(screen.getByRole('button')).toHaveClass(
+ `${prefix}--slug__button--inline`
+ );
+ });
+
+ it('should respect revertActive prop', () => {
+ const { container } = render(
);
+
+ expect(container.firstChild).toHaveClass(`${prefix}--slug--revert`);
+ expect(container.firstChild.firstChild).toHaveClass(
+ `${prefix}--icon-tooltip`
+ );
+ });
+
+ it('should respect revertLabel prop', () => {
+ render(
);
+
+ expect(screen.getByText('Test revert label')).toBeInTheDocument();
+ });
+
+ it('should respect size prop', () => {
+ render(
);
+
+ expect(screen.getByRole('button')).toHaveClass(
+ `${prefix}--slug__button--xl`
+ );
+ });
+ });
+});
diff --git a/packages/react/src/components/Tag/Tag-test.js b/packages/react/src/components/Tag/Tag-test.js
index 8de524d9efac..1ba02e600ee1 100644
--- a/packages/react/src/components/Tag/Tag-test.js
+++ b/packages/react/src/components/Tag/Tag-test.js
@@ -9,6 +9,7 @@ import { Add } from '@carbon/icons-react';
import { render, screen } from '@testing-library/react';
import React from 'react';
import Tag from './';
+import { Slug } from '../Slug';
describe('Tag', () => {
describe('automated accessibility testing', () => {
@@ -56,4 +57,12 @@ describe('Tag', () => {
expect(screen.getByTestId('test')).toBeInTheDocument();
});
+
+ it('should respect slug prop', () => {
+ render(
} />);
+
+ expect(
+ screen.getByRole('button', { name: 'AI - Show information' })
+ ).toBeInTheDocument();
+ });
});
diff --git a/packages/react/src/components/TextArea/__tests__/TextArea-test.js b/packages/react/src/components/TextArea/__tests__/TextArea-test.js
index c1e3a3d599cb..2a9c3726efd9 100644
--- a/packages/react/src/components/TextArea/__tests__/TextArea-test.js
+++ b/packages/react/src/components/TextArea/__tests__/TextArea-test.js
@@ -10,6 +10,7 @@ import TextArea from '../TextArea';
import userEvent from '@testing-library/user-event';
import { fireEvent, waitFor } from '@testing-library/react';
import { render, screen, createEvent } from '@testing-library/react';
+import { Slug } from '../../Slug';
const prefix = 'cds';
@@ -194,6 +195,15 @@ describe('TextArea', () => {
expect(screen.getByText('0/500')).toBeInTheDocument();
});
+ it('should respect slug prop', () => {
+ render(
+
} />
+ );
+ expect(
+ screen.getByRole('button', { name: 'AI - Show information' })
+ ).toBeInTheDocument();
+ });
+
describe('behaves as expected - Component API', () => {
it('should respect onChange prop', async () => {
const onChange = jest.fn();
diff --git a/packages/react/src/components/TextInput/__tests__/TextInput-test.js b/packages/react/src/components/TextInput/__tests__/TextInput-test.js
index eadd34e4bf86..9c4c3a786679 100644
--- a/packages/react/src/components/TextInput/__tests__/TextInput-test.js
+++ b/packages/react/src/components/TextInput/__tests__/TextInput-test.js
@@ -9,6 +9,7 @@ import React from 'react';
import TextInput from '../TextInput';
import userEvent from '@testing-library/user-event';
import { render, screen } from '@testing-library/react';
+import { Slug } from '../../Slug';
const prefix = 'cds';
@@ -224,6 +225,15 @@ describe('TextInput', () => {
`${prefix}--form-requirement`
);
});
+
+ it('should respect slug prop', () => {
+ render(
+
} />
+ );
+ expect(
+ screen.getByRole('button', { name: 'AI - Show information' })
+ ).toBeInTheDocument();
+ });
});
describe('behaves as expected - Component API', () => {
diff --git a/packages/react/src/components/Tile/Tile-test.js b/packages/react/src/components/Tile/Tile-test.js
index bcd7f54dd086..9d836db954a7 100644
--- a/packages/react/src/components/Tile/Tile-test.js
+++ b/packages/react/src/components/Tile/Tile-test.js
@@ -18,6 +18,7 @@ import userEvent from '@testing-library/user-event';
import { render, screen } from '@testing-library/react';
import Link from '../Link';
import { Add } from '@carbon/icons-react';
+import { Slug } from '../Slug';
const prefix = 'cds';
@@ -46,6 +47,13 @@ describe('Tile', () => {
render(
Default tile);
expect(screen.getByText('Default tile')).toHaveClass('custom-tile-class');
});
+
+ it('should respect slug prop', () => {
+ render(
}>Default tile);
+ expect(
+ screen.getByRole('button', { name: 'AI - Show information' })
+ ).toBeInTheDocument();
+ });
});
describe('ClickableTile', () => {
@@ -81,6 +89,15 @@ describe('Tile', () => {
expect(screen.getByTestId('test')).toBeInTheDocument();
});
+
+ it('should respect slug prop', () => {
+ render(
}>Default tile);
+
+ // eslint-disable-next-line testing-library/no-node-access
+ expect(document.querySelector('svg')).toHaveClass(
+ `${prefix}--tile--slug-icon`
+ );
+ });
});
describe('Multi Select', () => {
@@ -154,6 +171,17 @@ describe('Tile', () => {
expect(id1).toHaveFocus();
});
+
+ it('should respect slug prop', () => {
+ render(
+
} id="tile-1" name="tiles" value="value">
+ Default tile
+
+ );
+ expect(
+ screen.getByRole('button', { name: 'AI - Show information' })
+ ).toBeInTheDocument();
+ });
});
describe('ExpandableTile', () => {
@@ -280,6 +308,22 @@ describe('Tile', () => {
`${prefix}--tile--is-expanded`
);
});
+
+ it('should respect slug prop', () => {
+ render(
+
}>
+
+ TestAbove
+
+
+ TestBelow
+
+
+ );
+ expect(
+ screen.getByRole('button', { name: 'AI - Show information' })
+ ).toBeInTheDocument();
+ });
});
describe('ExpandableTile with interactive elements', () => {
diff --git a/packages/react/src/components/Toggletip/index.tsx b/packages/react/src/components/Toggletip/index.tsx
index 83e154064617..306c0e0ab12a 100644
--- a/packages/react/src/components/Toggletip/index.tsx
+++ b/packages/react/src/components/Toggletip/index.tsx
@@ -100,6 +100,7 @@ export function Toggletip
({
className: customClassName,
children,
defaultOpen = false,
+ ...rest
}: ToggletipProps) {
const ref = useRef(null);
const [open, setOpen] = useState(defaultOpen);
@@ -176,7 +177,8 @@ export function Toggletip({
onKeyDown={onKeyDown}
onBlur={handleBlur}
ref={ref}
- autoAlign={autoAlign}>
+ autoAlign={autoAlign}
+ {...rest}>
{children}