Skip to content

Commit 655cfde

Browse files
author
devgioele
committed
fix tests
1 parent aa0669c commit 655cfde

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

src/__test__/pagination-with-one-based-index-type.test.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
import { calculatePagination } from '../index'
1+
import { calculatePagination, IndexType } from '../index'
22

33
it('should return no pagination if not enough items are given', () => {
44
const page = 1
55
const size = 5
66
const total = 2
7-
const pagination = calculatePagination(page, size, total)
7+
const pagination = calculatePagination(page, size, total, {
8+
indexType: IndexType.ONE_BASED,
9+
})
810

911
expect(pagination).toBeNull()
1012
})
1113
it('should return only a few pages', () => {
1214
const page = 2
1315
const size = 5
1416
const total = 15
15-
const pagination = calculatePagination(page, size, total)
17+
const pagination = calculatePagination(page, size, total, {
18+
indexType: IndexType.ONE_BASED,
19+
})
1620

1721
expect(pagination).not.toBeNull()
1822
expect(pagination?.pages).toHaveLength(3)
@@ -33,6 +37,7 @@ it('should return the maximum number of pages', () => {
3337
const total = 50
3438
const maxPages = 5
3539
const pagination = calculatePagination(page, size, total, {
40+
indexType: IndexType.ONE_BASED,
3641
maxPages: maxPages,
3742
})
3843

@@ -59,7 +64,9 @@ it('should disable the previous link', () => {
5964
const page = 1
6065
const size = 5
6166
const total = 10
62-
const pagination = calculatePagination(page, size, total)
67+
const pagination = calculatePagination(page, size, total, {
68+
indexType: IndexType.ONE_BASED,
69+
})
6370

6471
expect(pagination).not.toBeNull()
6572

@@ -76,7 +83,9 @@ it('should disable the next link', () => {
7683
const page = 2
7784
const size = 5
7885
const total = 10
79-
const pagination = calculatePagination(page, size, total)
86+
const pagination = calculatePagination(page, size, total, {
87+
indexType: IndexType.ONE_BASED,
88+
})
8089

8190
expect(pagination).not.toBeNull()
8291

0 commit comments

Comments
 (0)