-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added new pagination with page choice and limit - Ref gestion-d…
…e-projet#2698 (#1043) * feat: added new pagination with page choice - Ref gestion-de-projet#1306 * feat: added pagination limit - Ref gestion-de-projet#2698 * feat: add test for pagination * ci: exclude styles.ts from coverage --------- Co-authored-by: Salah-BOUYAHIA <salah.bouyahia-ext@aphp.fr>
- Loading branch information
1 parent
413e029
commit b81f46a
Showing
28 changed files
with
555 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { checkIfPageAvailable, handlePageError } from 'utils/paginationUtils' | ||
import { vi } from 'vitest' | ||
|
||
describe('checkIfPageAvailable', () => { | ||
it('should not return a dispatch with error ', () => { | ||
const count = 0 | ||
const currentPage = 1 | ||
const setPage = vi.fn() | ||
const dispatch = vi.fn() | ||
const rowsPerPage = 20 | ||
|
||
checkIfPageAvailable(count, currentPage, setPage, dispatch, rowsPerPage) | ||
expect(dispatch).not.toHaveBeenCalled() | ||
}) | ||
it('should return dispatch with error', () => { | ||
const count = 300 | ||
const currentPage = 155 | ||
const setPage = vi.fn() | ||
const dispatch = vi.fn() | ||
const rowsPerPage = 20 | ||
|
||
checkIfPageAvailable(count, currentPage, setPage, dispatch, rowsPerPage) | ||
expect(dispatch).toHaveBeenCalled() | ||
}) | ||
}) | ||
|
||
describe('handlePageError', () => { | ||
it('should not return a dispatch with error ', () => { | ||
const page = 1 | ||
const setPage = vi.fn() | ||
const dispatch = vi.fn() | ||
|
||
handlePageError(page, setPage, dispatch) | ||
expect(dispatch).not.toHaveBeenCalled() | ||
}) | ||
it('should return dispatch with error', () => { | ||
const page = 1001 | ||
const setPage = vi.fn() | ||
const dispatch = vi.fn() | ||
|
||
handlePageError(page, setPage, dispatch) | ||
expect(dispatch).toHaveBeenCalled() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.