- Fix setTimeout memory leak in ChatRoom.tsx by storing timeout in
useRef and cleaning up on unmount
- Add tests for Accordion, Collapsible, FloatingInput, AnimatedNumber,
and FAB components (5 new test files, all passing)
- Fix socialService methods (deleteComment, markRead, markAllRead) to
return values matching test expectations
- Fix MSW handlers for chat/token and notification endpoints to use
proper { success: true, data: ... } envelope format
- Fix invalid CSS selector in TrackList.test.tsx that caused JSDOM crash
- Document excluded test files with TODO tickets in vitest.config.ts
Co-authored-by: Cursor <cursoragent@cursor.com>
43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
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(<FloatingInput label="Email" />);
|
|
expect(screen.getByLabelText('Email')).toBeInTheDocument();
|
|
});
|
|
|
|
it('displays error message', () => {
|
|
render(<FloatingInput label="Email" error="Invalid email" />);
|
|
expect(screen.getByText('Invalid email')).toBeInTheDocument();
|
|
});
|
|
|
|
it('renders icon when provided', () => {
|
|
render(
|
|
<FloatingInput
|
|
label="Email"
|
|
icon={<span data-testid="icon">@</span>}
|
|
/>
|
|
);
|
|
expect(screen.getByTestId('icon')).toBeInTheDocument();
|
|
});
|
|
|
|
it('toggles password visibility', () => {
|
|
render(
|
|
<FloatingInput label="Password" type="password" showPasswordToggle />
|
|
);
|
|
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(<FloatingInput label="Test" className="custom-class" />);
|
|
const input = screen.getByLabelText('Test');
|
|
expect(input.className).toContain('custom-class');
|
|
});
|
|
});
|