Files
iNaturalistReactNative/tests/helpers/render.js
Amanda Bullington 8d738d9d8c Delete observations from ObsEdit (#277)
* Remove delete option for observations not in realm
* Add mutation for delete observation
* Hide delete option for observations not persisted to realm
* Close kebab menu when item pressed; this allows dialog to respond to first user
   press

Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
2022-12-09 17:36:47 -08:00

41 lines
1.1 KiB
JavaScript

import { NavigationContainer } from "@react-navigation/native";
import {
QueryClient,
QueryClientProvider
} from "@tanstack/react-query";
import { render } from "@testing-library/react-native";
import App from "components/App";
import React from "react";
const queryClient = new QueryClient( {
defaultOptions: {
queries: {
// No need to do default retries in tests
retry: false,
// Prevent `Jest did not exit one second after the test run has completed.` error
// https://react-query-v3.tanstack.com/guides/testing#set-cachetime-to-infinity-with-jest
cacheTime: Infinity
}
}
} );
function renderComponent( component, update = null ) {
const renderMethod = update || render;
return renderMethod(
<QueryClientProvider client={queryClient}>
<NavigationContainer>
{ component }
</NavigationContainer>
</QueryClientProvider>
);
}
function renderAppWithComponent( component, update = null ) {
return renderComponent( <App>{ component }</App>, update );
}
export {
renderAppWithComponent,
renderComponent
};