Add tests
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user