Skip to content

Commit

Permalink
Right handling of zero pages in pagination
Browse files Browse the repository at this point in the history
RISDEV-2857
  • Loading branch information
rvp-c committed Dec 12, 2023
1 parent 74a3e05 commit 0b07e14
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion frontend/src/shared/components/Pagination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export type PageableService<TResult, TQuery = TResult> = (
<span class="underline">zurück</span>
</PaginationButton>
<span v-if="page">
{{ page.number + 1 }} von {{ page.totalPages }}
{{ page.totalPages ? page.number + 1 : 0 }} von {{ page.totalPages }}
</span>
<PaginationButton
aria-label="nächste Ergebnisse"
Expand Down
6 changes: 6 additions & 0 deletions frontend/test/shared/components/pagination.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ describe("Pagination", () => {
await screen.findByText("1 von 200")
})

test("displays 0 pages if there a no pages", async () => {
renderComponent({ totalPages: 0 })

await screen.findByText("0 von 0")
})

test("next button disabled if on last page", async () => {
renderComponent({ last: true })

Expand Down

0 comments on commit 0b07e14

Please sign in to comment.