import { describe, test, expect } from 'vitest'
import { render, screen } from '@testing-library/react'
import { ChatUserMessage } from './chat-user-message'

describe('ChatUserMessage', () => {
  test('renders children content', () => {
    render(<ChatUserMessage>Hello world</ChatUserMessage>)
    expect(screen.getByText('Hello world')).toBeTruthy()
  })

  test('renders secondary content when provided', () => {
    render(
      <ChatUserMessage topContext={<span>Secondary</span>}>
        Primary
      </ChatUserMessage>,
    )
    expect(screen.getByText('Primary')).toBeTruthy()
    expect(screen.getByText('Secondary')).toBeTruthy()
  })

  test('does not render secondary content when not provided', () => {
    const { container } = render(
      <ChatUserMessage>Only primary</ChatUserMessage>,
    )
    expect(container.textContent).toBe('Only primary')
  })
})
