mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-06-21 14:08:31 -04:00
* Bugfix: TaxonDetails was crashing if it received a null taxon * Send lat and lng instead of latitude and longitude to the score_image endpoint * Show offline suggestions when you are offline * Show notice when viewing offline suggestions * Moved code unique to useOnlineSuggestions into that file * Ensure we use a medium size image to get suggestions when dealing with remote URLs * More logging around React Query retries * Use default retry logic for useAuthenticatedQuery * Made a module-resolver shortcut for tests * Move offline notice above top suggestion; hide when offlines exist but onlines do too
74 lines
2.2 KiB
JavaScript
74 lines
2.2 KiB
JavaScript
import { render, screen } from "@testing-library/react-native";
|
|
import ObsGridItem from "components/SharedComponents/ObservationsFlashList/ObsGridItem";
|
|
import initI18next from "i18n/initI18next";
|
|
import React from "react";
|
|
import factory from "tests/factory";
|
|
|
|
describe( "ObsGridItem", () => {
|
|
beforeAll( async () => {
|
|
await initI18next();
|
|
} );
|
|
|
|
describe( "for an observation with a photo", ( ) => {
|
|
const observationWithPhoto = factory( "LocalObservation", {
|
|
observationPhotos: [factory( "LocalObservationPhoto" )]
|
|
} );
|
|
|
|
it( "should render", () => {
|
|
const observationWithStablePhotoUrl = factory( "LocalObservation", {
|
|
uuid: "00000000-0000-0000-0000-000000000000",
|
|
observationPhotos: [
|
|
factory( "LocalObservationPhoto", {
|
|
photo: factory( "LocalPhoto", {
|
|
url: "https://inaturalist-open-data.s3.amazonaws.com/photos/1/large.jpeg"
|
|
} )
|
|
} )
|
|
]
|
|
} );
|
|
render(
|
|
<ObsGridItem
|
|
observation={observationWithStablePhotoUrl}
|
|
uploadState={{ uploadProgress: false }}
|
|
/>
|
|
);
|
|
expect( screen ).toMatchSnapshot();
|
|
} );
|
|
|
|
it( "should have photo", async ( ) => {
|
|
render(
|
|
<ObsGridItem
|
|
observation={observationWithPhoto}
|
|
uploadState={{ uploadProgress: false }}
|
|
/>
|
|
);
|
|
expect( await screen.findByTestId( "ObsList.photo" ) ).toBeTruthy( );
|
|
} );
|
|
} );
|
|
|
|
describe( "for an observation without a photo", ( ) => {
|
|
const observationWithoutPhoto = factory( "LocalObservation", {
|
|
uuid: "00000000-0000-0000-0000-000000000000"
|
|
} );
|
|
|
|
it( "should render", ( ) => {
|
|
render(
|
|
<ObsGridItem
|
|
observation={observationWithoutPhoto}
|
|
uploadState={{ uploadProgress: false }}
|
|
/>
|
|
);
|
|
expect( screen ).toMatchSnapshot();
|
|
} );
|
|
|
|
it( "should have an iconic taxon icon", async ( ) => {
|
|
render(
|
|
<ObsGridItem
|
|
observation={observationWithoutPhoto}
|
|
uploadState={{ uploadProgress: false }}
|
|
/>
|
|
);
|
|
expect( await screen.findByTestId( "IconicTaxonName.iconicTaxonIcon" ) ).toBeTruthy( );
|
|
} );
|
|
} );
|
|
} );
|