File size: 868 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
/**
* @jest-environment jsdom
*/
import { render, screen } from '@testing-library/react';
import { Callout } from '../index';
describe( 'Callout', () => {
test( 'renders title and description', () => {
render( <Callout title="Test Title" titleAs="h6" description={ <p>Helpful content</p> } /> );
expect(
screen.getByRole( 'heading', {
name: 'Test Title',
} )
).toBeInTheDocument();
expect( screen.getByRole( 'paragraph' ) ).toHaveTextContent( 'Helpful content' );
} );
test( 'renders img element using image', () => {
render(
<Callout
title="Test Title"
description={ <p>Helpful content</p> }
image="https://example.com/illustration.png"
imageAlt="Illustration"
/>
);
expect( screen.getByRole( 'img', { name: 'Illustration' } ) ).toHaveAttribute(
'src',
'https://example.com/illustration.png'
);
} );
} );
|