import { describe, it, expect } from 'vitest'
import { render, screen } from '@testing-library/react'
import { CodeBlock } from './CodeBlock'

describe('CodeBlock', () => {
  it('renders content in a pre element', () => {
    render(<CodeBlock content='{"key": "value"}' />)
    expect(screen.getByText(/"key"/)).toBeInTheDocument()
  })

  it('pretty-prints JSON when language is json', () => {
    render(<CodeBlock content='{"a":1}' language="json" />)
    expect(screen.getByText(/"a":/)).toBeInTheDocument()
  })

  it('shows copy button when copyable', () => {
    render(<CodeBlock content="test" copyable />)
    expect(screen.getByRole('button', { name: /copy/i })).toBeInTheDocument()
  })
})
