mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-06-20 13:38:42 -04:00
* Simplify ObsEditProvider by moving functions into local state & calling reducer less frequently * Fix delete all observations * Fixes * Move index selection to MediaViewer via params * Access ObsEditContext on top level of ObsEdit and pass props * Move context to top level screen components * Fix tests * Use waitFor to fix ObsDetails integration test * Alphabetize props; remove realm check; refactor new Id method --------- Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
59 lines
1.7 KiB
JavaScript
59 lines
1.7 KiB
JavaScript
import { screen } from "@testing-library/react-native";
|
|
import IdentificationSection from "components/ObsEdit/IdentificationSection";
|
|
import initI18next from "i18n/initI18next";
|
|
import React from "react";
|
|
|
|
import factory from "../../../factory";
|
|
import { renderComponent } from "../../../helpers/render";
|
|
|
|
const renderIdentificationSection = obs => renderComponent(
|
|
<IdentificationSection
|
|
passesIdentificationTest
|
|
observations={obs}
|
|
currentObservation={obs[0]}
|
|
/>
|
|
);
|
|
|
|
describe( "IdentificationSection", () => {
|
|
beforeAll( async ( ) => {
|
|
await initI18next( );
|
|
} );
|
|
|
|
it( "should show IconicTaxonChooser when there is no identification", ( ) => {
|
|
const observations = [
|
|
factory( "RemoteObservation", {
|
|
taxon: null
|
|
} )
|
|
];
|
|
renderIdentificationSection( observations );
|
|
expect( screen.getByTestId( "ObsEdit.Suggestions" ) ).toBeVisible( );
|
|
} );
|
|
|
|
it( "should show IconicTaxonChooser when an iconic taxon is selected", ( ) => {
|
|
const observations = [
|
|
factory( "RemoteObservation", {
|
|
taxon: {
|
|
name: "Fungi",
|
|
isIconic: true,
|
|
iconic_taxon_name: "Fungi"
|
|
}
|
|
} )
|
|
];
|
|
renderIdentificationSection( observations );
|
|
expect( screen.getByTestId( "ObsEdit.Suggestions" ) ).toBeVisible( );
|
|
} );
|
|
|
|
it( "should hide IconicTaxonChooser when a non-iconic taxon is selected", ( ) => {
|
|
const observations = [
|
|
factory( "RemoteObservation", {
|
|
taxon: {
|
|
name: "Fox Squirrel",
|
|
iconic_taxon_name: null
|
|
}
|
|
} )
|
|
];
|
|
renderIdentificationSection( observations );
|
|
expect( screen.queryByTestId( "ObsEdit.Suggestions" ) ).toBeFalsy( );
|
|
} );
|
|
} );
|