import { describe, it, expect } from 'vitest';
import { render, screen, fireEvent } from '@testing-library/react';
import { FloatingInput } from './floating-input';
describe('FloatingInput', () => {
it('renders with label', () => {
render();
expect(screen.getByLabelText('Email')).toBeInTheDocument();
});
it('displays error message', () => {
render();
expect(screen.getByText('Invalid email')).toBeInTheDocument();
});
it('renders icon when provided', () => {
render(
@}
/>
);
expect(screen.getByTestId('icon')).toBeInTheDocument();
});
it('toggles password visibility', () => {
render(
);
const input = screen.getByLabelText('Password');
expect(input).toHaveAttribute('type', 'password');
const toggleButton = screen.getByLabelText('Show password');
fireEvent.click(toggleButton);
expect(input).toHaveAttribute('type', 'text');
});
it('applies custom className', () => {
render();
const input = screen.getByLabelText('Test');
expect(input.className).toContain('custom-class');
});
});