Jest: include QueryClientProvider in tests

This commit is contained in:
Alex Gleason 2022-08-01 23:42:13 -05:00
parent 0eeca2be5c
commit f6e5df2278
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 12 additions and 9 deletions

View file

@ -137,9 +137,7 @@ describe('<FeedCarousel />', () => {
expect(screen.queryAllByTestId('prev-page')).toHaveLength(0); expect(screen.queryAllByTestId('prev-page')).toHaveLength(0);
}); });
await waitFor(() => { await user.click(screen.getByTestId('next-page'));
user.click(screen.getByTestId('next-page'));
});
await waitFor(() => { await waitFor(() => {
expect(screen.getByTestId('prev-page')).toBeInTheDocument(); expect(screen.getByTestId('prev-page')).toBeInTheDocument();

View file

@ -1,4 +1,5 @@
import { configureMockStore } from '@jedmao/redux-mock-store'; import { configureMockStore } from '@jedmao/redux-mock-store';
import { QueryClientProvider } from '@tanstack/react-query';
import { render, RenderOptions } from '@testing-library/react'; import { render, RenderOptions } from '@testing-library/react';
import { merge } from 'immutable'; import { merge } from 'immutable';
import React, { FC, ReactElement } from 'react'; import React, { FC, ReactElement } from 'react';
@ -9,6 +10,8 @@ import { Action, applyMiddleware, createStore } from 'redux';
import thunk from 'redux-thunk'; import thunk from 'redux-thunk';
import '@testing-library/jest-dom'; import '@testing-library/jest-dom';
import { queryClient } from 'soapbox/queries/client';
import NotificationsContainer from '../features/ui/containers/notifications_container'; import NotificationsContainer from '../features/ui/containers/notifications_container';
import { default as rootReducer } from '../reducers'; import { default as rootReducer } from '../reducers';
@ -45,13 +48,15 @@ const TestApp: FC<any> = ({ children, storeProps, routerProps = {} }) => {
return ( return (
<Provider store={props.store}> <Provider store={props.store}>
<IntlProvider locale={props.locale}> <QueryClientProvider client={queryClient}>
<MemoryRouter {...routerProps}> <IntlProvider locale={props.locale}>
{children} <MemoryRouter {...routerProps}>
{children}
<NotificationsContainer /> <NotificationsContainer />
</MemoryRouter> </MemoryRouter>
</IntlProvider> </IntlProvider>
</QueryClientProvider>
</Provider> </Provider>
); );
}; };