# jetpack/16.3-a.3/_inc/shared/components/ai-banner/test/component.jsx

Jetpack – WP Security, Backup, Speed, &amp; Growth, version 16.3-a.3. 45 lines.

- Page: https://pluginprobe.com/plugins/jetpack/16.3-a.3/code/_inc/shared/components/ai-banner/test/component.jsx
- Raw: https://pluginprobe.com/plugins/jetpack/16.3-a.3/raw/_inc/shared/components/ai-banner/test/component.jsx
- Modified: 2026-09-08T18:39:34+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/jetpack/16.3-a.3/code/_inc/shared/components/ai-banner/test/component.jsx#L10-L20`.

```jsx
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import AiBanner from '../index';

const noop = () => {};

describe( 'AiBanner', () => {
	test( 'renders title, description, and actions', () => {
		render(
			<AiBanner
				title="Banner title"
				description="Banner description"
				actions={ <button type="button">Do it</button> }
				onDismiss={ noop }
			/>
		);

		expect( screen.getByRole( 'heading', { name: 'Banner title' } ) ).toBeInTheDocument();
		expect( screen.getByText( 'Banner description' ) ).toBeInTheDocument();
		expect( screen.getByRole( 'button', { name: 'Do it' } ) ).toBeInTheDocument();
	} );

	test( 'renders only the close X when no actions are given', () => {
		render( <AiBanner title="Banner title" description="Banner description" onDismiss={ noop } /> );

		expect( screen.getAllByRole( 'button' ) ).toHaveLength( 1 );
		expect( screen.getByRole( 'button', { name: 'Dismiss banner' } ) ).toBeInTheDocument();
	} );

	test( 'close X calls onDismiss and takes a custom label', async () => {
		const onDismiss = jest.fn();
		render(
			<AiBanner
				title="Banner title"
				description="Banner description"
				onDismiss={ onDismiss }
				dismissLabel="Hide this"
			/>
		);

		await userEvent.click( screen.getByRole( 'button', { name: 'Hide this' } ) );
		expect( onDismiss ).toHaveBeenCalledTimes( 1 );
	} );
} );

```
