Files
iNaturalistReactNative/tests/unit/components/Projects/ProjectObservations.test.js
Amanda Bullington 0d69fe1568 Fetch user locale from server and change language (#255)
* 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>
2022-12-09 15:51:17 -08:00

36 lines
1.0 KiB
JavaScript

import ProjectDetails from "components/Projects/ProjectDetails";
import React from "react";
import factory from "../../../factory";
import { renderComponent } from "../../../helpers/render";
const mockProject = factory( "RemoteProject" );
const mockObservation = factory( "RemoteObservation" );
jest.mock( "@react-navigation/native", ( ) => {
const actualNav = jest.requireActual( "@react-navigation/native" );
return {
...actualNav,
useRoute: ( ) => ( {
params: {
id: mockProject.id
}
} )
};
} );
jest.mock( "sharedHooks/useAuthenticatedQuery", ( ) => ( {
__esModule: true,
default: ( ) => ( {
data: [mockObservation]
} )
} ) );
test( "displays project observations", ( ) => {
const { getByTestId, getByText } = renderComponent( <ProjectDetails /> );
expect( getByText( mockObservation.taxon.preferred_common_name ) ).toBeTruthy( );
expect( getByTestId( "ObsList.photo" ).props.source )
.toStrictEqual( { uri: mockObservation.observation_photos[0].photo.url } );
} );