mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-06-21 22:18:32 -04:00
* Create Explore screen * Add input field component * Add input fields * UI for list view in Explore; dropdown taxa picker * UI for list view in Explore; dropdown taxa picker * ObservationViews component is shared between Explore and My Observations * Get tests passing with Explore + ObservationViews * Add map view, iOS location permission whenInUse, and geolocation fetch * Add RN permissions and geolocation to jest mocks * Explore filters, testing, explore provider/navigation stack * Crash fix for grid items with no observation photos * Code cleanup; remove duplicate files * Remove more duplication * Consolidate pickers into a single component * Move copyRealmSchema into Observation model * Move copyRealmSchema into Observation model * Move observation photo logic to Obs model * Obs details fetches an observation from API instead of from realm/exploreList * Rename hooks files with 'use' instead of 'fetch' * Add user to observation schema * Change realm keys from camelcase to snakecase with mapping * Simplify model code * Fix tests for ObsDetails * Attempt to clean up ObsList code; move useObservations hook into provider * Several minor changes to get tests passing * Stopped mocking useObservation hook in MyObservations integration test; this should not be mocked in an integration test since the point is to test the integration of all the different moving pieces within the app, and it was causing a failure because it was mocked but none of the methods were actually provided with mock responses, so it wasn't doing anything * Used the LocalObservation factory for ObsDetails.test.js, where the useObservation hook should return an observation in the Realm schema (or something like it), not in the remote schema * Updated the LocalObservation factory to meet expectations * Attempting to work around weird problem with fkirc/skip-duplicate-actions * Removed fkirc/skip-duplicate-actions from CI for now * CI fix Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
52 lines
1.4 KiB
JavaScript
52 lines
1.4 KiB
JavaScript
import React from "react";
|
|
import { render } from "@testing-library/react-native";
|
|
import { NavigationContainer } from "@react-navigation/native";
|
|
|
|
import factory from "../../../factory";
|
|
import UserProfile from "../../../../src/components/UserProfile/UserProfile";
|
|
|
|
const testUser = factory( "RemoteUser" );
|
|
const mockExpected = testUser;
|
|
|
|
jest.mock( "../../../../src/components/UserProfile/hooks/useUser", ( ) => ( {
|
|
useUser: ( ) => {
|
|
return mockExpected;
|
|
}
|
|
} ) );
|
|
|
|
jest.mock( "@react-navigation/native", ( ) => {
|
|
const actualNav = jest.requireActual( "@react-navigation/native" );
|
|
return {
|
|
...actualNav,
|
|
useRoute: ( ) => ( {
|
|
params: {
|
|
userId: mockExpected.id
|
|
}
|
|
} )
|
|
};
|
|
} );
|
|
|
|
const renderUserProfile = ( ) => render(
|
|
<NavigationContainer>
|
|
<UserProfile />
|
|
</NavigationContainer>
|
|
);
|
|
|
|
test( "renders user profile from API call", ( ) => {
|
|
const { getByTestId, getByText } = renderUserProfile( );
|
|
|
|
expect( getByTestId( `UserProfile.${testUser.id}` ) ).toBeTruthy( );
|
|
expect( getByText( `@${testUser.login}` ) ).toBeTruthy( );
|
|
expect( getByTestId( "UserIcon.photo" ).props.source ).toStrictEqual( { "uri": testUser.icon_url } );
|
|
} );
|
|
|
|
test.todo( "should not have accessibility errors" );
|
|
// test( "should not have accessibility errors", ( ) => {
|
|
// const userProfile = (
|
|
// <NavigationContainer>
|
|
// <UserProfile />
|
|
// </NavigationContainer>
|
|
// );
|
|
// expect( userProfile ).toBeAccessible( );
|
|
// } );
|