import { render } from '@testing-library/react';
import { describe, test, expect, vi } from 'vitest';
import Button from '../components/Button/index';

describe('test Button', () => {
  test('should render', () => {
    const { getByText } = render(<Button label="test" onClick={vi.fn()} />);
    expect(getByText('test')).toBeDefined();
  });

  test('should call onClick', () => {
    const onClick = vi.fn();
    const { getByText } = render(<Button label="test" onClick={onClick} />);
    getByText('test').click();
    expect(onClick).toHaveBeenCalled();
  });

  test('button should be disabled', () => {
    const onClick = vi.fn();
    const { getByText } = render(
      <Button label="test" disabled={true} onClick={onClick} />,
    );
    getByText('test').click();
    expect(onClick).not.toHaveBeenCalled();
  });

  test('button size', () => {
    const { getByText } = render(<Button label="test" size="large" />);
    expect(getByText('test').className).toContain('btn-large');
  })
});
