瀏覽代碼

test(utils): add test for current page greater than total pages

satnaing 2 月之前
父節點
當前提交
a3cdc0ef84
共有 1 個文件被更改,包括 5 次插入0 次删除
  1. 5 0
      src/lib/utils.test.ts

+ 5 - 0
src/lib/utils.test.ts

@@ -20,4 +20,9 @@ describe('getPageNumbers', () => {
   it('shows ellipsis on both side in the middle', () => {
     expect(getPageNumbers(5, 10)).toEqual([1, '...', 4, 5, 6, '...', 10])
   })
+
+  it('handles current page greater than total pages', () => {
+    expect(getPageNumbers(6, 5)).toEqual([1, 2, 3, 4, 5])
+    expect(getPageNumbers(11, 10)).toEqual([1, '...', 7, 8, 9, 10])
+  })
 })