/**
 * (share/components — happy/negative/error branches per sheet gates).
 */
import React from 'react'
import { render, screen } from '@testing-library/react'
import Alert from '../index'

jest.mock('@/share/icons', () => ({
  AlertErrorIcon: ({ className }: { className?: string }) => <span data-testid="alert-error-icon" className={className} />,
  AlertInfo: ({ className }: { className?: string }) => <span data-testid="alert-info-icon" className={className} />,
}))

describe('[share/components/alert]', () => {
  describe('type branches (happy path / default icon)', () => {
    it('renders error variant with title, description, and error icon', () => {
      render(
        <Alert type="error" title="Error" description="Something happened" />,
      )
      expect(screen.getByText('Error')).toBeInTheDocument()
      expect(screen.getByText('Something happened')).toBeInTheDocument()
      expect(screen.getByTestId('alert-error-icon')).toBeInTheDocument()
    })

    it('renders info variant with info icon', () => {
      render(<Alert type="info" description="Info" />)
      expect(screen.getByTestId('alert-info-icon')).toBeInTheDocument()
      expect(screen.getByText('Info')).toBeInTheDocument()
    })

    it('uses default branch for success and warning (grey + info icon)', () => {
      const { rerender } = render(<Alert type="success" description="OK" />)
      expect(screen.getByText('OK')).toBeInTheDocument()
      expect(screen.getByTestId('alert-info-icon')).toBeInTheDocument()

      rerender(<Alert type="warning" description="Warn" />)
      expect(screen.getByText('Warn')).toBeInTheDocument()
      expect(screen.getByTestId('alert-info-icon')).toBeInTheDocument()
    })
  })
})
