import { describe, it, expect, vi } from 'vitest'
import { mount } from '@vue/test-utils'
import LanguageSwitcher from '../LanguageSwitcher.vue'

// Mock dependencies
vi.mock('vue-i18n', () => ({
  useI18n: () => ({
    t: (key: string) => key,
    locale: { value: 'en' }
  })
}))

vi.mock('@/i18n', () => ({
  setLanguage: vi.fn(),
  currentLanguage: () => 'en'
}))

// Mock lucide icons
vi.mock('lucide-vue-next', () => ({
  Globe: { template: '<div>Globe</div>' },
  ChevronDown: { template: '<div>ChevronDown</div>' }
}))

describe('LanguageSwitcher.vue', () => {
    it('renders correctly', () => {
        const wrapper = mount(LanguageSwitcher)
        expect(wrapper.exists()).toBe(true)
        expect(wrapper.find('button').exists()).toBe(true)
    })

    it('shows dropdown when clicked', async () => {
        const wrapper = mount(LanguageSwitcher)
        await wrapper.find('button').trigger('click')
        // The dropdown is inside a Transition, but we can check if it's in the DOM
        expect(wrapper.text()).toContain('English')
        expect(wrapper.text()).toContain('Русский')
    })
})
