2026-01-07 09:31:02 +00:00
|
|
|
import { render, screen } from '@testing-library/react';
|
|
|
|
|
import { describe, it, expect } from 'vitest';
|
|
|
|
|
import { Textarea } from './textarea';
|
|
|
|
|
|
|
|
|
|
describe('Textarea Component', () => {
|
|
|
|
|
it('renders textarea', () => {
|
|
|
|
|
render(<Textarea placeholder="Enter text" />);
|
2026-01-13 18:47:57 +00:00
|
|
|
|
2026-01-07 09:31:02 +00:00
|
|
|
const textarea = screen.getByPlaceholderText('Enter text');
|
|
|
|
|
expect(textarea).toBeInTheDocument();
|
refactor: Phase 3a — Global color class migration to SUMI semantics
- Replace all kodo-* color classes across ~100 TSX files:
kodo-void → background, kodo-ink → card, kodo-graphite → muted,
kodo-steel → muted-foreground, kodo-cyan → primary, kodo-magenta → destructive,
kodo-lime → success, kodo-red → destructive, kodo-gold → warning
- Replace cyan-500, magenta-500, lime-500 default Tailwind colors with
semantic equivalents (primary, destructive, success)
- Fix WaveformVisualizer hardcoded hex colors to SUMI values
- Delete global-effects.css (conflicting, redundant with index.css)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 00:51:49 +00:00
|
|
|
expect(textarea).toHaveClass('bg-muted');
|
2026-01-07 09:31:02 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('renders with label', () => {
|
|
|
|
|
render(<Textarea label="Description" />);
|
2026-01-13 18:47:57 +00:00
|
|
|
|
2026-01-07 09:31:02 +00:00
|
|
|
const label = screen.getByText('Description');
|
|
|
|
|
expect(label).toBeInTheDocument();
|
2026-01-13 18:47:57 +00:00
|
|
|
|
2026-01-07 09:31:02 +00:00
|
|
|
const textarea = screen.getByLabelText('Description');
|
|
|
|
|
expect(textarea).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('displays error message', () => {
|
|
|
|
|
render(<Textarea error="This field is required" />);
|
2026-01-13 18:47:57 +00:00
|
|
|
|
2026-01-07 09:31:02 +00:00
|
|
|
const error = screen.getByText('This field is required');
|
|
|
|
|
expect(error).toBeInTheDocument();
|
refactor: Phase 3a — Global color class migration to SUMI semantics
- Replace all kodo-* color classes across ~100 TSX files:
kodo-void → background, kodo-ink → card, kodo-graphite → muted,
kodo-steel → muted-foreground, kodo-cyan → primary, kodo-magenta → destructive,
kodo-lime → success, kodo-red → destructive, kodo-gold → warning
- Replace cyan-500, magenta-500, lime-500 default Tailwind colors with
semantic equivalents (primary, destructive, success)
- Fix WaveformVisualizer hardcoded hex colors to SUMI values
- Delete global-effects.css (conflicting, redundant with index.css)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 00:51:49 +00:00
|
|
|
expect(error).toHaveClass('text-destructive');
|
2026-01-13 18:47:57 +00:00
|
|
|
|
2026-01-07 09:31:02 +00:00
|
|
|
const textarea = screen.getByRole('textbox');
|
refactor: Phase 3a — Global color class migration to SUMI semantics
- Replace all kodo-* color classes across ~100 TSX files:
kodo-void → background, kodo-ink → card, kodo-graphite → muted,
kodo-steel → muted-foreground, kodo-cyan → primary, kodo-magenta → destructive,
kodo-lime → success, kodo-red → destructive, kodo-gold → warning
- Replace cyan-500, magenta-500, lime-500 default Tailwind colors with
semantic equivalents (primary, destructive, success)
- Fix WaveformVisualizer hardcoded hex colors to SUMI values
- Delete global-effects.css (conflicting, redundant with index.css)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 00:51:49 +00:00
|
|
|
expect(textarea).toHaveClass('border-destructive');
|
2026-01-07 09:31:02 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('applies custom className', () => {
|
|
|
|
|
render(<Textarea className="custom-textarea" />);
|
2026-01-13 18:47:57 +00:00
|
|
|
|
2026-01-07 09:31:02 +00:00
|
|
|
const textarea = screen.getByRole('textbox');
|
|
|
|
|
expect(textarea).toHaveClass('custom-textarea');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('handles disabled state', () => {
|
|
|
|
|
render(<Textarea disabled />);
|
2026-01-13 18:47:57 +00:00
|
|
|
|
2026-01-07 09:31:02 +00:00
|
|
|
const textarea = screen.getByRole('textbox');
|
|
|
|
|
expect(textarea).toBeDisabled();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('handles value prop', () => {
|
|
|
|
|
render(<Textarea value="Test value" readOnly />);
|
2026-01-13 18:47:57 +00:00
|
|
|
|
2026-01-07 09:31:02 +00:00
|
|
|
const textarea = screen.getByRole('textbox');
|
|
|
|
|
expect(textarea).toHaveValue('Test value');
|
|
|
|
|
});
|
|
|
|
|
});
|