mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-06-21 22:18:32 -04:00
* Add to user profile * Create a hook to fetch member projects * Create custom header for user profile * Updates to user profile; resize image for CV suggestions; build config for Android * Bug fixes with obs list & CV suggestion fields * Add functions for creating id, faving obs and adding comment in obsdetail * Show comments as activity items; create comments and refetch obs data * Fix activity item keys * Add data to data tab, obs detail * Let user unfave observation * Fix camera modal * Get tests passing
55 lines
1.5 KiB
JavaScript
55 lines
1.5 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 {
|
|
user: mockExpected,
|
|
currentUser: null
|
|
};
|
|
}
|
|
} ) );
|
|
|
|
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( );
|
|
// } );
|