import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { describe, expect, it } from 'vitest'
import { ThemeToggle } from '../../src/components/ThemeToggle'
import { ThemeProvider } from '../../src/design/ThemeProvider'

describe('ThemeToggle', () => {
  it('switches between the independent blue and light schemes', async () => {
    localStorage.clear()
    render(<ThemeProvider><ThemeToggle /></ThemeProvider>)
    await userEvent.click(screen.getByRole('button', { name: '切换前端 UI 方案' }))
    expect(document.documentElement.dataset.theme).toBe('light')
    expect(localStorage.getItem('safety-theme')).toBe('light')
  })
})
