import { render, screen } from '@testing-library/react' import { describe, expect, it } from 'vitest' import { expectNoA11yViolations } from '../test/a11y' import { Kbd } from './Kbd' describe('Kbd', () => { it('renders a single key', () => { const { container } = render(Esc) expect(container.querySelector('kbd')).toHaveTextContent('Esc') }) it('renders a combination as nested kbd elements with separators', () => { const { container } = render() const outer = container.firstElementChild! expect(outer.tagName).toBe('KBD') expect(outer.querySelectorAll('kbd')).toHaveLength(2) expect(outer).toHaveTextContent('⌘Command+K') }) it('names symbols for screen readers', () => { render() expect(screen.getByText('⇧')).toHaveAttribute('aria-hidden', 'true') expect(screen.getByText('Shift')).toHaveClass('sr-only') expect(screen.queryByText('+')).not.toBeInTheDocument() }) it('has no axe violations', async () => { const { container } = render(

Press or /

, ) await expectNoA11yViolations(container) }) })