Spaces:
Sleeping
Sleeping
Download frontend/src/components/ViewModeToggle.test.tsx from vn6295337/Instant-SWOT-Agent: direct link, hf CLI and curl.
- Browser
- Download file 1.68 kB
-
https://huggingface.co/spaces/vn6295337/Instant-SWOT-Agent/resolve/main/frontend/src/components/ViewModeToggle.test.tsx
- Command line
-
hf download hf://spaces/vn6295337/Instant-SWOT-Agent/frontend/src/components/ViewModeToggle.test.tsx
-
curl -L -o ViewModeToggle.test.tsx https://huggingface.co/spaces/vn6295337/Instant-SWOT-Agent/resolve/main/frontend/src/components/ViewModeToggle.test.tsx
1.68 kB
| import { describe, it, expect, vi } from 'vitest' | |
| import { render, screen, fireEvent } from '@testing-library/react' | |
| import { ViewModeToggle } from './ViewModeToggle' | |
| describe('ViewModeToggle', () => { | |
| it('renders Executive and Full buttons', () => { | |
| const onChange = vi.fn() | |
| render(<ViewModeToggle value="executive" onChange={onChange} />) | |
| expect(screen.getByRole('button', { name: 'Executive' })).toBeInTheDocument() | |
| expect(screen.getByRole('button', { name: 'Full' })).toBeInTheDocument() | |
| }) | |
| it('highlights the selected mode', () => { | |
| const onChange = vi.fn() | |
| const { rerender } = render(<ViewModeToggle value="executive" onChange={onChange} />) | |
| const executiveBtn = screen.getByRole('button', { name: 'Executive' }) | |
| const fullBtn = screen.getByRole('button', { name: 'Full' }) | |
| expect(executiveBtn).toHaveClass('bg-primary') | |
| expect(fullBtn).not.toHaveClass('bg-primary') | |
| rerender(<ViewModeToggle value="full" onChange={onChange} />) | |
| expect(executiveBtn).not.toHaveClass('bg-primary') | |
| expect(fullBtn).toHaveClass('bg-primary') | |
| }) | |
| it('calls onChange when clicking a different mode', () => { | |
| const onChange = vi.fn() | |
| render(<ViewModeToggle value="executive" onChange={onChange} />) | |
| fireEvent.click(screen.getByRole('button', { name: 'Full' })) | |
| expect(onChange).toHaveBeenCalledWith('full') | |
| }) | |
| it('calls onChange with executive when clicking Executive', () => { | |
| const onChange = vi.fn() | |
| render(<ViewModeToggle value="full" onChange={onChange} />) | |
| fireEvent.click(screen.getByRole('button', { name: 'Executive' })) | |
| expect(onChange).toHaveBeenCalledWith('executive') | |
| }) | |
| }) | |