mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-04-21 15:28:39 -04:00
* Fetch user from server, set locale in realm and change language with i18next * Added some Spanish translations so I can see localization working * config QueryClient with `cacheTime: Infinity` to deal with "Jest did not exit" errors Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
51 lines
1.4 KiB
JavaScript
51 lines
1.4 KiB
JavaScript
import UserProfile from "components/UserProfile/UserProfile";
|
|
import React from "react";
|
|
|
|
import factory from "../../../factory";
|
|
import { renderComponent } from "../../../helpers/render";
|
|
|
|
const mockUser = factory( "RemoteUser" );
|
|
|
|
jest.mock( "sharedHooks/useAuthenticatedQuery", ( ) => ( {
|
|
__esModule: true,
|
|
default: ( ) => ( {
|
|
data: mockUser
|
|
} )
|
|
} ) );
|
|
|
|
jest.mock( "@react-navigation/native", ( ) => {
|
|
const actualNav = jest.requireActual( "@react-navigation/native" );
|
|
return {
|
|
...actualNav,
|
|
useRoute: ( ) => ( {
|
|
params: {
|
|
userId: mockUser.id
|
|
}
|
|
} ),
|
|
useNavigation: ( ) => ( {
|
|
setOptions: ( ) => ( {
|
|
headerTitle: `@${mockUser.login}`
|
|
} )
|
|
} )
|
|
};
|
|
} );
|
|
|
|
test( "renders user profile from API call", async ( ) => {
|
|
const { getByTestId, getByText } = renderComponent( <UserProfile /> );
|
|
|
|
expect( getByTestId( `UserProfile.${mockUser.id}` ) ).toBeTruthy( );
|
|
expect( getByText( `iNaturalist ${mockUser.roles[0]}` ) ).toBeTruthy( );
|
|
expect( getByTestId( "UserIcon.photo" ).props.source )
|
|
.toStrictEqual( { uri: mockUser.icon_url } );
|
|
} );
|
|
|
|
test.todo( "should not have accessibility errors" );
|
|
// test( "should not have accessibility errors", ( ) => {
|
|
// const userProfile = (
|
|
// <NavigationContainer>
|
|
// <UserProfile />
|
|
// </NavigationContainer>
|
|
// );
|
|
// expect( userProfile ).toBeAccessible( );
|
|
// } );
|