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

vi.mock('@/shared/model/auth', () => ({
  $user: {
    defaultState: { id: '1', avatar: null, avatarStyle: 'initials', displayName: 'Test' },
    subscribe: () => () => {},
    getState: () => ({ id: '1', avatar: null, avatarStyle: 'initials', displayName: 'Test' }),
    watch: () => () => {},
    on: () => {},
    reset: () => {},
  },
  updateProfileFx: { pending: false },
}))

vi.mock('effector-react', async () => {
  return {
    useUnit: () => ({ id: '1', avatar: null, avatarStyle: 'initials', displayName: 'Test' }),
  }
})

vi.mock('@dicebear/core', () => ({
  createAvatar: vi.fn(() => ({
    toDataUri: () => 'data:image/svg+xml,<svg></svg>',
  })),
}))

describe('AvatarSection', () => {
  it('renders avatar section', async () => {
    render(<AvatarSection />)
    await waitFor(() => {
      expect(screen.getByText('Аватар')).toBeTruthy()
    })
  })
})
