mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-02 20:30:10 +00:00
31bca0052f
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.
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
/**
|
|
* Component: Pagination Tests
|
|
* Documentation: documentation/frontend/components.md
|
|
*/
|
|
|
|
// @vitest-environment jsdom
|
|
|
|
import React from 'react';
|
|
import { fireEvent, render, screen } from '@testing-library/react';
|
|
import { describe, expect, it, vi } from 'vitest';
|
|
import { Pagination } from '@/components/ui/Pagination';
|
|
|
|
describe('Pagination', () => {
|
|
it('renders nothing when there is only one page', () => {
|
|
const { container } = render(<Pagination currentPage={1} totalPages={1} onPageChange={vi.fn()} />);
|
|
expect(container.firstChild).toBeNull();
|
|
});
|
|
|
|
it('renders ellipses for large page ranges', () => {
|
|
render(<Pagination currentPage={5} totalPages={10} onPageChange={vi.fn()} />);
|
|
const ellipses = screen.getAllByText('...');
|
|
expect(ellipses.length).toBeGreaterThan(0);
|
|
});
|
|
|
|
it('calls onPageChange for navigation controls', () => {
|
|
const onPageChange = vi.fn();
|
|
render(<Pagination currentPage={2} totalPages={5} onPageChange={onPageChange} />);
|
|
|
|
fireEvent.click(screen.getByLabelText('Previous page'));
|
|
expect(onPageChange).toHaveBeenCalledWith(1);
|
|
|
|
fireEvent.click(screen.getByLabelText('Next page'));
|
|
expect(onPageChange).toHaveBeenCalledWith(3);
|
|
|
|
fireEvent.click(screen.getByLabelText('Page 4'));
|
|
expect(onPageChange).toHaveBeenCalledWith(4);
|
|
});
|
|
});
|