mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-06-19 13:11:23 -04:00
* Add exception handler library; fix computer vision results * Create loggedIn hook to check whether user is logged in before cv suggestions or upload * Create user profile card on MyObs * Update packages * Add text for camera permissions denied * Remove log * Upgrade react native on iOS * Add vendor file for ruby gems to gitignore * Remove vendor file from github * Update react native for android * Add plural example to fluent; create TranslatedText component to render translations * Add translations and update camera roll screens * Small changes to uploader flow; add date/time picker * Separate explore into landing screen and view screen * Show total number of observations, explore * Clean up styling and add details for grid view; banner for total observations in explore * Add checkboxes for status, quality grade, media filters * Add a lot of explore filters * Show months in Explore filters * Create About screen; sync package.json version using react native version * Get explore filters in mostly working condition * Observations download after login; clear login screen after nav; closes #62 and #60 * Allow separating photos if at least 1 combined photo obs is selected; closes #68 * Fix auth tests; add user id * Pop text input above keyboard to address #66 * Lint cleanup * Create bottom modal for user tapping back button on ObsEdit * Check permissions on android only, camera * Keep trying to get android camera working * Change version number to 0.1.0
60 lines
1.6 KiB
JavaScript
60 lines
1.6 KiB
JavaScript
import React from "react";
|
|
import { render, fireEvent } from "@testing-library/react-native";
|
|
import { NavigationContainer } from "@react-navigation/native";
|
|
|
|
import factory from "../../../factory";
|
|
import Projects from "../../../../src/components/Projects/Projects";
|
|
|
|
const mockedNavigate = jest.fn( );
|
|
const mockProject = factory( "RemoteProject" );
|
|
|
|
const mockLatLng = {
|
|
latitude: 37.77,
|
|
longitude: -122.42
|
|
};
|
|
|
|
// Mock the hooks we use on Map since we're not trying to test them here
|
|
jest.mock( "../../../../src/sharedHooks/useUserLocation" , ( ) => ( {
|
|
useUserLocation: ( ) => {
|
|
return mockLatLng;
|
|
}
|
|
} ) );
|
|
|
|
jest.mock( "../../../../src/components/Projects/hooks/useProjects" , ( ) => ( {
|
|
__esModule: true,
|
|
default: ( ) => {
|
|
return [mockProject];
|
|
}
|
|
} ) );
|
|
|
|
jest.mock( "@react-navigation/native", ( ) => {
|
|
const actualNav = jest.requireActual( "@react-navigation/native" );
|
|
return {
|
|
...actualNav,
|
|
useNavigation: ( ) => ( {
|
|
navigate: mockedNavigate
|
|
} )
|
|
};
|
|
} );
|
|
|
|
const renderProjects = () => render(
|
|
<NavigationContainer>
|
|
<Projects />
|
|
</NavigationContainer>
|
|
);
|
|
|
|
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
|
|
} );
|
|
} );
|
|
|