import { describe, expect, it } from 'vitest' import { paginationRange } from '../../frontend/shared/utils/pagination' describe('paginationRange', () => { it('returns an empty array for zero or negative totals', () => { expect(paginationRange(1, 0)).toEqual([]) }) it('returns every page when the total fits within the visible window', () => { expect(paginationRange(1, 5)).toEqual([1, 2, 3, 4, 5]) expect(paginationRange(3, 7)).toEqual([1, 2, 3, 4, 5, 6, 7]) }) it('collapses the right side when near the start', () => { expect(paginationRange(1, 20)).toEqual([1, 2, 3, 4, 5, 'ellipsis', 20]) expect(paginationRange(2, 20)).toEqual([1, 2, 3, 4, 5, 'ellipsis', 20]) }) it('collapses the left side when near the end', () => { expect(paginationRange(20, 20)).toEqual([1, 'ellipsis', 16, 17, 18, 19, 20]) expect(paginationRange(19, 20)).toEqual([1, 'ellipsis', 16, 17, 18, 19, 20]) }) it('collapses both sides when in the middle', () => { expect(paginationRange(10, 20)).toEqual([1, 'ellipsis', 9, 10, 11, 'ellipsis', 20]) }) it('always includes the current page', () => { for (let current = 1; current <= 27; current++) { expect(paginationRange(current, 27)).toContain(current) } }) })