mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-04-21 07:20:03 -04:00
* Add missing dependency * Fix display taxon name * Lint * Add unit tests * Lint * Add test file * Fix bad commits * Add unit tests * Lint * Fix lint * Lint * Fix tests * Fix tests * Remove console log * Fix most comments and add test case for subspecies * Fix lint * Add common name capitalization * Fix broken tests * Fix test
46 lines
1.2 KiB
JavaScript
46 lines
1.2 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", {
|
|
taxon: { preferred_common_name: "Foo", name: "bar" }
|
|
} );;
|
|
|
|
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
|
|
} (${
|
|
mockObservation.taxon.rank
|
|
} ${
|
|
mockObservation.taxon.name
|
|
})`
|
|
) ).toBeTruthy( );
|
|
expect( getByTestId( "ObsList.photo" ).props.source )
|
|
.toStrictEqual( { uri: mockObservation.observation_photos[0].photo.url } );
|
|
} );
|