import { axe, toHaveNoViolations } from 'jest-axe'; import { createRef } from 'react'; import * as React from 'react'; import { describe, it } from 'vitest'; import { render } from '@testing-library/react'; import { Card } from '.'; const cardContent = ( <> Header Body Footer ); describe('Card', () => { it('should render', () => { render({cardContent}); }); it('should forward ref', () => { const ref = createRef(); render({cardContent}); expect(ref.current).not.toBeNull(); }); it('should pass id prop', () => { const ref = createRef(); render( {cardContent} ); expect(ref.current).toHaveProperty('id', 'card-id'); }); it('should generate id prop', () => { const ref = createRef(); render({cardContent}); expect(ref.current).toHaveProperty('id'); }); it('should be accessible', async () => { expect.extend(toHaveNoViolations); const { container } = render({cardContent}); const results = await axe(container); expect(results).toHaveNoViolations(); }); });