diff --git a/components/recipe-gallery/__tests__/gallery-pagination.test.tsx b/components/recipe-gallery/__tests__/gallery-pagination.test.tsx index 6af3b0e..678e845 100644 --- a/components/recipe-gallery/__tests__/gallery-pagination.test.tsx +++ b/components/recipe-gallery/__tests__/gallery-pagination.test.tsx @@ -1,7 +1,7 @@ import { GalleryPagination } from '../gallery-pagination.client'; import { withMockNavigation } from '@/__mocks__/nextMocks'; import { describe, it, expect } from 'bun:test'; -import { screen, render, within } from '@testing-library/react'; +import { screen, render, within, waitFor } from '@testing-library/react'; describe('Given Gallery Pagination component', () => { it('should render three list items when there is one page', () => { @@ -20,11 +20,13 @@ describe('Given Gallery Pagination component', () => { expect(getAllByRole('listitem')).toHaveLength(7); }); - it('should set aria current based on search params', () => { + it('should set aria current based on search params', async () => { withMockNavigation({ searchParams: { page: '4' } }); render(); - const current = screen.getByRole('link', { current: 'page' }); - expect(current).toHaveTextContent('4'); + await waitFor(() => { + const current = screen.getByRole('link', { current: 'page' }); + expect(current).toHaveTextContent('4'); + }); }); it('should disable previous button when on first page', () => {