Files
iNaturalistReactNative/tests/unit/components/SharedComponents/DisplayTaxon.test.js
Johannes Klein b4516b7b25 Update react native to v0.78.x (#3043)
* Update package.json

* Update package.json

* Updates for native files with upgrade-helpers

* Update .flowconfig

* Update package-lock.json

* Update Podfile.lock

* Add react-dom types

* Update package-lock.json

* Wrong install

* Use types-react-codemod

* Update TaxonSearch.tsx

* Remove react-native-accessibility-engine dependency

This is currently not maintained and not compatible with RN 0.78

* Comment out accessibility tests

* Disable broken snapshot test

* Move broken test

* Move broken test

* Move broken test

* Remove duplicate file

* Move broken tests

* Move broken tests

* Move broken tests

* Move broken tests

* Move broken tests

* Move broken test

* Remove duplicate file

* Move broken tests
2025-08-09 13:47:46 +02:00

64 lines
1.7 KiB
JavaScript

import { screen } from "@testing-library/react-native";
import { DisplayTaxon } from "components/SharedComponents";
import React from "react";
import factory from "tests/factory";
import { renderComponent } from "tests/helpers/render";
const mockTaxon = factory( "RemoteTaxon", {
name: "Aves",
preferred_common_name: "Birds",
default_photo: {
url: ""
}
} );
const taxonWithIconicTaxonPhoto = factory( "LocalTaxon", {
name: "Pavo cristatus",
preferred_common_name: "Peafowl",
iconic_taxon_name: "Aves",
default_photo: {
url: "some url"
}
} );
describe( "DisplayTaxon", () => {
it( "should be accessible", () => {
// Disabled during the update to RN 0.78
// expect( <DisplayTaxon taxon={mockTaxon} handlePress={( ) => undefined} /> )
// .toBeAccessible( );
} );
it( "displays an iconic taxon icon when no photo is available", () => {
renderComponent( <DisplayTaxon taxon={mockTaxon} handlePress={( ) => undefined} /> );
expect( screen.getByTestId( "IconicTaxonName.iconicTaxonIcon" ) );
} );
it( "displays an iconic taxon photo when no taxon photo is available", () => {
renderComponent(
<DisplayTaxon
taxon={taxonWithIconicTaxonPhoto}
handlePress={( ) => undefined}
/>
);
expect(
screen.getByTestId( "DisplayTaxon.image" ).props.source
).toStrictEqual( { uri: taxonWithIconicTaxonPhoto?.default_photo?.url } );
} );
it( "displays 50% opacity when taxon id is withdrawn", () => {
renderComponent(
<DisplayTaxon
taxon={taxonWithIconicTaxonPhoto}
handlePress={( ) => undefined}
withdrawn
/>
);
expect(
screen.getByTestId( "DisplayTaxon.image" )
).toHaveStyle( { opacity: 0.5 } );
} );
} );