Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

1.0 KB
Raw Blame
import '@testing-library/jest-dom'

import { render, screen } from '@testing-library/react'

import { WidgetCardHeaderDescription } from './WidgetCardHeader'

describe('WidgetCardHeaderDescription', () => {
    it('renders markdown when description is set and visible', () => {
        render(<WidgetCardHeaderDescription description="Weekly error summary" showDescription />)

        expect(screen.getByText('Weekly error summary')).toBeInTheDocument()
    })

    it('does not render when description is empty', () => {
        const { container } = render(<WidgetCardHeaderDescription description="" showDescription />)

        expect(container.querySelector('[data-slot="widget-card-header-description"]')).toBeNull()
    })

    it('does not render when description visibility is off', () => {
        const { container } = render(
            <WidgetCardHeaderDescription description="Hidden description" showDescription={false} />
        )

        expect(container.querySelector('[data-slot="widget-card-header-description"]')).toBeNull()
    })
})