mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-06-21 05:58:37 -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
47 lines
1.8 KiB
JavaScript
47 lines
1.8 KiB
JavaScript
import { fireEvent, screen } from "@testing-library/react-native";
|
|
import ExploreContainer from "components/Explore/ExploreContainer";
|
|
import initI18next from "i18n/initI18next";
|
|
import inatjs from "inaturalistjs";
|
|
import React from "react";
|
|
import factory, { makeResponse } from "tests/factory";
|
|
import { renderAppWithComponent } from "tests/helpers/render";
|
|
|
|
const mockRemoteObservation = factory( "RemoteObservation", {
|
|
taxon: factory.states( "genus" )( "RemoteTaxon" )
|
|
} );
|
|
|
|
describe( "Explore", ( ) => {
|
|
beforeAll( async ( ) => {
|
|
await initI18next( );
|
|
} );
|
|
|
|
it( "should render", async ( ) => {
|
|
inatjs.observations.search.mockResolvedValue( makeResponse( [mockRemoteObservation] ) );
|
|
renderAppWithComponent( <ExploreContainer /> );
|
|
const obsTaxonNameElt = await screen.findByText( mockRemoteObservation.taxon.name );
|
|
expect( obsTaxonNameElt ).toBeTruthy( );
|
|
expect(
|
|
await screen.findByTestId( `ObsStatus.${mockRemoteObservation.uuid}` )
|
|
).toBeTruthy( );
|
|
expect(
|
|
screen.queryByTestId( `UploadIcon.progress.${mockRemoteObservation.uuid}` )
|
|
).toBeFalsy( );
|
|
} );
|
|
it( "should display grid item correctly", async ( ) => {
|
|
inatjs.observations.search.mockResolvedValue( makeResponse( [mockRemoteObservation] ) );
|
|
renderAppWithComponent( <ExploreContainer /> );
|
|
const obsTaxonNameElt = await screen.findByText( mockRemoteObservation.taxon.name );
|
|
expect( obsTaxonNameElt ).toBeTruthy( );
|
|
expect(
|
|
await screen.findByTestId( "SegmentedButton.grid" )
|
|
).toBeTruthy( );
|
|
fireEvent.press( await screen.findByTestId( "SegmentedButton.grid" ) );
|
|
expect(
|
|
await screen.findByTestId( `ObsStatus.${mockRemoteObservation.uuid}` )
|
|
).toBeTruthy( );
|
|
expect(
|
|
screen.queryByTestId( `UploadIcon.progress.${mockRemoteObservation.uuid}` )
|
|
).toBeFalsy( );
|
|
} );
|
|
} );
|