import { render, screen } from '@testing-library/react'; import { describe, expect, it } from 'vitest'; import { Notice, Show } from './primitives'; describe('Show', () => { it('renders children when the condition is true', () => { render( Visible , ); expect(screen.getByText('Visible')).toBeInTheDocument(); }); it('renders fallback when the condition is false', () => { render( Hidden} when={false}> Visible , ); expect(screen.getByText('Hidden')).toBeInTheDocument(); expect(screen.queryByText('Visible')).not.toBeInTheDocument(); }); it('supports render-prop children', () => { render({(name) => {name}}); expect(screen.getByText('Ada')).toBeInTheDocument(); }); }); describe('Notice', () => { it('renders as a note by default', () => { render(Fallback message); expect(screen.getByText('Fallback message')).toHaveAttribute('role', 'note'); expect(screen.getByText('Fallback message')).toHaveAttribute('data-tone', 'info'); }); it('supports tone overrides', () => { render( Provider fallback , ); expect(screen.getByRole('note')).toHaveAttribute('data-tone', 'warning'); }); });