Files
ReadMeABook/tests/components/admin/indexers/AvailableIndexerRow.test.tsx
T
kikootwo 31bca0052f Add series fields to audiobooks and update related logic
Introduces 'series' and 'seriesPart' fields to the Audiobook model and database schema. Updates API routes, file organization, and path template utilities to support series metadata. Enhances chapter merging logic, improves notification backend testing, and expands test coverage for admin and API routes.
2026-01-28 11:42:00 -05:00

39 lines
1.2 KiB
TypeScript

/**
* Component: Available Indexer Row Tests
* Documentation: documentation/frontend/components.md
*/
// @vitest-environment jsdom
import { describe, expect, it, vi } from 'vitest';
import { fireEvent, render, screen } from '@testing-library/react';
import { AvailableIndexerRow } from '@/components/admin/indexers/AvailableIndexerRow';
describe('AvailableIndexerRow', () => {
const indexer = {
id: 1,
name: 'Test Indexer',
protocol: 'torrent',
supportsRss: true,
};
it('renders an add button when the indexer is not added', () => {
const onAdd = vi.fn();
render(<AvailableIndexerRow indexer={indexer} isAdded={false} onAdd={onAdd} />);
fireEvent.click(screen.getByRole('button', { name: 'Add' }));
expect(onAdd).toHaveBeenCalledTimes(1);
expect(screen.getByText('Test Indexer')).toBeInTheDocument();
expect(screen.getByText('torrent')).toBeInTheDocument();
});
it('renders the added state when already configured', () => {
render(<AvailableIndexerRow indexer={indexer} isAdded onAdd={vi.fn()} />);
expect(screen.getByText('Added')).toBeInTheDocument();
expect(screen.queryByRole('button', { name: 'Add' })).toBeNull();
});
});