test(coverage): drive browser tests to 80% on all metrics (#496) #505
@@ -84,4 +84,28 @@ describe('Pagination', () => {
|
||||
const nav = document.querySelector('nav');
|
||||
expect(nav?.getAttribute('aria-label')).toBe('Custom pagination');
|
||||
});
|
||||
|
||||
it('renders the bridge page (no ellipsis) when window is exactly 2 pages from start', async () => {
|
||||
// page=3 (1-indexed=4), totalPages=10 → windowStart=3, first+2=3 → bridge to page 2
|
||||
render(Pagination, { props: { page: 3, totalPages: 10, makeHref } });
|
||||
|
||||
// Should have page 2 directly, not an ellipsis
|
||||
const ellipsisLeft = document.querySelector('[data-testid="pagination-ellipsis-left"]');
|
||||
expect(ellipsisLeft).toBeNull();
|
||||
});
|
||||
|
||||
it('renders the bridge page (no ellipsis) when window is exactly 2 pages from end', async () => {
|
||||
// page=6 (1-indexed=7), totalPages=10 → windowEnd=8, last-2=8 → bridge to page 9
|
||||
render(Pagination, { props: { page: 6, totalPages: 10, makeHref } });
|
||||
|
||||
// Should have page 9 directly, not an ellipsis on the right
|
||||
const ellipsisRight = document.querySelector('[data-testid="pagination-ellipsis-right"]');
|
||||
expect(ellipsisRight).toBeNull();
|
||||
});
|
||||
|
||||
it('returns no result when totalPages is 0', async () => {
|
||||
render(Pagination, { props: { page: 0, totalPages: 0, makeHref } });
|
||||
|
||||
expect(document.querySelector('nav')).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user