mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-05-06 14:46:20 -04:00
* Use authenticated query for search results * Use search API for fetching places from Settings * Use authenticated query for authorized applications * Use authenticated query to fetch user.me * Move fetch/search api calls into react query format, out of hooks * Update with react query instead of hooks * Fetch list of blocked and muted users with authenticated query * Added Podfile postinstall block to get app running in a Simulator * Use auth query in identify * Upgrade Realm to 11.0.0-rc.0, most recent version that will work with RN 0.68.2 * Upgrade @realm/react library to 0.4.0; fixes initialization error on android due to importing realm * Use authquery for explore provider * ObsDetail wasn't showing the edit button for obs created while signed out * simplified ObsEditHeader so it takes a full observation instead of relying on the ObsEditContext * ObsEdit now accepts an obs UUID as a param and loads that if the context doesn't have a current obs * null checks for API methods, mostly to prevent requests that won't work b/c of missing params Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
72 lines
1.9 KiB
JavaScript
72 lines
1.9 KiB
JavaScript
import { NavigationContainer } from "@react-navigation/native";
|
|
import {
|
|
QueryClient,
|
|
QueryClientProvider
|
|
} from "@tanstack/react-query";
|
|
import { fireEvent, render } from "@testing-library/react-native";
|
|
import Projects from "components/Projects/Projects";
|
|
import React from "react";
|
|
|
|
import factory from "../../../factory";
|
|
|
|
const mockedNavigate = jest.fn( );
|
|
const mockProject = factory( "RemoteProject" );
|
|
|
|
const mockLatLng = {
|
|
latitude: 37.77,
|
|
longitude: -122.42
|
|
};
|
|
|
|
jest.mock( "sharedHooks/useAuthenticatedQuery", ( ) => ( {
|
|
__esModule: true,
|
|
default: ( ) => ( {
|
|
data: [mockProject]
|
|
} )
|
|
} ) );
|
|
|
|
jest.mock( "../../../../src/sharedHooks/useLoggedIn", ( ) => ( {
|
|
__esModule: true,
|
|
default: ( ) => true
|
|
} ) );
|
|
|
|
// Mock the hooks we use on Map since we're not trying to test them here
|
|
jest.mock( "../../../../src/sharedHooks/useUserLocation", ( ) => ( {
|
|
default: ( ) => mockLatLng,
|
|
__esModule: true
|
|
} ) );
|
|
|
|
jest.mock( "@react-navigation/native", ( ) => {
|
|
const actualNav = jest.requireActual( "@react-navigation/native" );
|
|
return {
|
|
...actualNav,
|
|
useNavigation: ( ) => ( {
|
|
navigate: mockedNavigate
|
|
} )
|
|
};
|
|
} );
|
|
|
|
const queryClient = new QueryClient( );
|
|
|
|
const renderProjects = () => render(
|
|
<QueryClientProvider client={queryClient}>
|
|
<NavigationContainer>
|
|
<Projects />
|
|
</NavigationContainer>
|
|
</QueryClientProvider>
|
|
);
|
|
|
|
test( "displays project search results", ( ) => {
|
|
const { getByTestId, getByText } = renderProjects( );
|
|
|
|
const input = getByTestId( "ProjectSearch.input" );
|
|
fireEvent.changeText( input, "butterflies" );
|
|
|
|
expect( getByText( mockProject.title ) ).toBeTruthy( );
|
|
expect( getByTestId( `Project.${mockProject.id}.photo` ).props.source )
|
|
.toStrictEqual( { uri: mockProject.icon } );
|
|
fireEvent.press( getByTestId( `Project.${mockProject.id}` ) );
|
|
expect( mockedNavigate ).toHaveBeenCalledWith( "ProjectDetails", {
|
|
id: mockProject.id
|
|
} );
|
|
} );
|