diff --git a/src/hooks/useInstitutions.ts b/src/hooks/useInstitutions.ts index ba3212a..2191ac0 100644 --- a/src/hooks/useInstitutions.ts +++ b/src/hooks/useInstitutions.ts @@ -22,6 +22,6 @@ export const useInstitutions = () => { return useQuery( ["ui-training", "institutions"], - async () => ((await ky("location-units/institutions").json())).locinsts, + async () => ((await ky.get("location-units/institutions").json())).locinsts, ); }; \ No newline at end of file diff --git a/src/views/MainPage.test.tsx b/src/views/MainPage.test.tsx index e9ff5e4..45cde97 100644 --- a/src/views/MainPage.test.tsx +++ b/src/views/MainPage.test.tsx @@ -1,16 +1,25 @@ -import { getByText, render, screen } from '@folio/jest-config-stripes/testing-library/react'; +import { render, screen } from '@folio/jest-config-stripes/testing-library/react'; +import { QueryClient, QueryClientProvider } from 'react-query'; import React from 'react'; import MainPage from './MainPage'; import userEvent from '@testing-library/user-event' import withIntlConfiguration from '../test/util/withIntlConfiguration'; +const queryClient = new QueryClient(); + +// Mock the QueryClientProvider to provide the QueryClient +jest.mock('react-query', () => ({ + ...jest.requireActual('react-query'), + useQueryClient: () => queryClient, +})); + describe('Main page', () => { it('shows correct text', async () => { - render(withIntlConfiguration()); + render(withIntlConfiguration( )); expect(screen.getByRole('heading', { name: 'Headline Open side panel' })).toBeVisible(); - await userEvent.click(await screen.findByRole('button')); + await userEvent.click(await screen.findByText('Open side panel')); expect(screen.getByText('Side panel')).toBeVisible(); }); });