mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-04-18 22:11:29 -04:00
57 lines
1.6 KiB
JavaScript
57 lines
1.6 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", () => {
|
|
expect( <DisplayTaxon taxon={mockTaxon} handlePress={( ) => { }} /> ).toBeAccessible( );
|
|
} );
|
|
|
|
it( "displays an iconic taxon icon when no photo is available", () => {
|
|
renderComponent( <DisplayTaxon taxon={mockTaxon} handlePress={( ) => { }} /> );
|
|
|
|
expect( screen.getByTestId( "IconicTaxonName.iconicTaxonIcon" ) );
|
|
} );
|
|
|
|
it( "displays an iconic taxon photo when no taxon photo is available", () => {
|
|
renderComponent( <DisplayTaxon taxon={taxonWithIconicTaxonPhoto} handlePress={( ) => { }} /> );
|
|
|
|
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={( ) => { }}
|
|
withdrawn
|
|
/>
|
|
);
|
|
|
|
expect(
|
|
screen.getByTestId( "DisplayTaxon.image" )
|
|
).toHaveStyle( { opacity: 0.5 } );
|
|
} );
|
|
} );
|