mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-05-06 14:46:20 -04:00
* Use react navigation header for photo gallery / album picker * Use react navigation for group photos header * Use react nav header for Add ID * Use react navigation header for ObsEdit * Fix tests by mocking navigation setOptions * Show all buttons in camera options modal; remove header from StandardCamera * Only show obs edit header when observations have loaded Closes #226
66 lines
1.7 KiB
JavaScript
66 lines
1.7 KiB
JavaScript
import { NavigationContainer } from "@react-navigation/native";
|
|
import {
|
|
QueryClient,
|
|
QueryClientProvider
|
|
} from "@tanstack/react-query";
|
|
import { render } from "@testing-library/react-native";
|
|
import UserProfile from "components/UserProfile/UserProfile";
|
|
import React from "react";
|
|
|
|
import factory from "../../../factory";
|
|
|
|
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}`
|
|
} )
|
|
} )
|
|
};
|
|
} );
|
|
|
|
const queryClient = new QueryClient( );
|
|
|
|
const renderUserProfile = ( ) => render(
|
|
<QueryClientProvider client={queryClient}>
|
|
<NavigationContainer>
|
|
<UserProfile />
|
|
</NavigationContainer>
|
|
</QueryClientProvider>
|
|
);
|
|
|
|
test( "renders user profile from API call", async ( ) => {
|
|
const { getByTestId, getByText } = renderUserProfile( );
|
|
|
|
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( );
|
|
// } );
|