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

describe('GuanghuThemeMenu', () => {
  it('presents the current theme as a channel-style navigation control', () => {
    render(<GuanghuThemeMenu value="lake-dark" onChange={vi.fn()} />)

    expect(screen.getByRole('button', {
      name: '选择光湖界面主题，当前为湖心深色（暗）',
    })).toBeInTheDocument()
    expect(screen.queryByRole('combobox')).not.toBeInTheDocument()
  })

  it('shows every theme in one consistent navigation menu and changes selection', async () => {
    const onChange = vi.fn()
    render(<GuanghuThemeMenu value="lake-dark" onChange={onChange} />)

    fireEvent.pointerDown(
      screen.getByRole('button', {
        name: '选择光湖界面主题，当前为湖心深色（暗）',
      }),
      { button: 0 },
    )
    fireEvent.click(await screen.findByRole('menuitemradio', { name: /极光深海/ }))

    expect(onChange).toHaveBeenCalledWith('aurora-dark')
  })
})
