Files
iNaturalistReactNative/tests/unit/components/UserProfile/UserProfile.test.js
Amanda Bullington 4d213bd4c6 Create / update / delete requests with useMutation (#206)
* Use authenticated query for search results
* Use search API for fetching places from Settings
* Use authenticated query for authorized applications
* Use authenticated query to fetch user.me
* Move fetch/search api calls into react query format, out of hooks
* Update with react query instead of hooks
* Fetch list of blocked and muted users with authenticated query
* Added Podfile postinstall block to get app running in a Simulator
* Use auth query in identify
* Upgrade @realm/react library to 0.4.0; fixes initialization error on android due to importing realm
* Use authquery for explore provider
* Use mutations for blocking/muting users, invalidating queries, and refetching settings data
* Add react mutation to create/update/delete api calls
* Use mutation for creating identification on identity/obs detail screens
* Use mutations to update and delete relationships
* Use mutation to revoke authorized apps
* Use mutation for updating user settings
* Fix ids on activity tab; fix safe area view; fix mark viewed
* Limit fields for remote observation api call

Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
2022-10-31 20:39:38 -07:00

61 lines
1.6 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
}
} )
};
} );
const queryClient = new QueryClient( );
const renderUserProfile = ( ) => render(
<QueryClientProvider client={queryClient}>
<NavigationContainer>
<UserProfile />
</NavigationContainer>
</QueryClientProvider>
);
test( "renders user profile from API call", ( ) => {
const { getByTestId, getByText } = renderUserProfile( );
expect( getByTestId( `UserProfile.${mockUser.id}` ) ).toBeTruthy( );
expect( getByText( `@${mockUser.login}` ) ).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( );
// } );