import { render, screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { Signal } from '../signal';

describe('Signal', () => {
  it('renders without a label', () => {
    const { container } = render(<Signal direction="up" />);
    expect(container.querySelector('span')).toBeInTheDocument();
  });

  it('renders label text when provided', () => {
    render(<Signal direction="up" label="Tăng" />);
    expect(screen.getByText('Tăng')).toBeInTheDocument();
  });

  it('renders icon with aria-hidden for up direction', () => {
    const { container } = render(<Signal direction="up" label="Up" />);
    expect(container.querySelector('[aria-hidden="true"]')).toBeInTheDocument();
  });

  it('renders icon with aria-hidden for down direction', () => {
    const { container } = render(<Signal direction="down" label="Down" />);
    expect(container.querySelector('[aria-hidden="true"]')).toBeInTheDocument();
  });

  it('renders icon with aria-hidden for neutral direction', () => {
    const { container } = render(<Signal direction="neutral" label="Neutral" />);
    expect(container.querySelector('[aria-hidden="true"]')).toBeInTheDocument();
  });

  it('renders as an inline span', () => {
    const { container } = render(<Signal direction="up" label="x" />);
    expect(container.firstChild?.nodeName).toBe('SPAN');
  });

  it('merges custom className onto root span', () => {
    const { container } = render(<Signal direction="up" className="extra" label="x" />);
    expect(container.firstChild).toHaveClass('extra');
  });

  it('contains an svg icon', () => {
    const { container } = render(<Signal direction="up" />);
    expect(container.querySelector('svg')).toBeInTheDocument();
  });
});
