Add tests

This commit is contained in:
Kristina Durivage
2025-12-29 19:10:26 -06:00
parent f9b7e5743f
commit da6cc641a5
2 changed files with 13 additions and 1 deletions
@@ -16,4 +16,16 @@ describe('Pagination component', () => {
expect(screen.getAllByRole('button')).toHaveLength(9);
expect(screen.getAllByTestId('pagination-ellipsis-icon')).toHaveLength(2);
});
it('should only render the page number if number of pages is 0', () => {
render(<Pagination currentPage={8} numberOfPages={0} onNavigate={() => {}} />);
expect(screen.getAllByRole('button')).toHaveLength(2);
expect(screen.getAllByRole('button')[1]).toBeEnabled();
expect(screen.getByText('8')).toBeVisible();
});
it('should disable the next page button if hasNextPage is false', () => {
render(<Pagination currentPage={8} numberOfPages={0} onNavigate={() => {}} hasNextPage={false} />);
expect(screen.getAllByRole('button')).toHaveLength(2);
expect(screen.getAllByRole('button')[0]).toBeEnabled();
expect(screen.getAllByRole('button')[1]).toBeDisabled();
});
});
@@ -132,7 +132,7 @@ export const Pagination = ({
size="sm"
variant="secondary"
onClick={() => onNavigate(currentPage + 1)}
disabled={!hasNextPage || currentPage === numberOfPages}
disabled={hasNextPage === false || currentPage === numberOfPages}
>
<Icon name="angle-right" />
</Button>