Setup tests
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
export function getNextPageIndexLimited(currentPageIndex, pagesCount) {
|
||||
return Math.min(currentPageIndex + 1, pagesCount - 1)
|
||||
return Math.min(Math.max(currentPageIndex + 1, 0), pagesCount - 1)
|
||||
}
|
||||
|
||||
export function getNextPageIndexInfinte(currentPageIndex, pagesCount) {
|
||||
const newCurrentPageIndex = currentPageIndex + 1
|
||||
return newCurrentPageIndex > pagesCount - 1 ? 0 : newCurrentPageIndex
|
||||
const newCurrentPageIndex = Math.max(currentPageIndex, 0) + 1
|
||||
return newCurrentPageIndex > pagesCount - 1 ? 0 : Math.max(newCurrentPageIndex, 0)
|
||||
}
|
||||
|
||||
export function getNextPageIndexFn(infinite) {
|
||||
@@ -12,12 +12,12 @@ export function getNextPageIndexFn(infinite) {
|
||||
}
|
||||
|
||||
export function getPrevPageIndexLimited(currentPageIndex, pagesCount) {
|
||||
return Math.max(currentPageIndex - 1, 0)
|
||||
return Math.max(Math.min(currentPageIndex - 1, pagesCount - 1), 0)
|
||||
}
|
||||
|
||||
export function getPrevPageIndexInfinte(currentPageIndex, pagesCount) {
|
||||
const newCurrentPageIndex = currentPageIndex - 1
|
||||
return newCurrentPageIndex >= 0 ? newCurrentPageIndex : pagesCount - 1
|
||||
const newCurrentPageIndex = Math.min(currentPageIndex, pagesCount - 1) - 1
|
||||
return newCurrentPageIndex >= 0 ? Math.min(newCurrentPageIndex, pagesCount - 1) : pagesCount - 1
|
||||
}
|
||||
|
||||
export function getPrevPageIndexFn(infinite) {
|
||||
|
||||
Reference in New Issue
Block a user