Files
iNaturalistReactNative/tests/unit/components/SharedComponents/IconicTaxonChooser.test.js
Ken-ichi ae2f9eeddc Fix missing map tiles when taxon chosen on Explore (#1722)
* IconicTaxonChooser no longer takes a taxon or manages its own state
* Setting iconic taxon filter to Unknown is now its own action
* Unsetting a taxon can be done with the CHOOSE_TAXON action by setting taxon
  to null or undefined
* Omitted some extraneous params from tile requests
2024-06-28 10:13:51 -07:00

42 lines
1.2 KiB
JavaScript

import { render, screen } from "@testing-library/react-native";
import { IconicTaxonChooser } from "components/SharedComponents";
import React from "react";
import factory from "tests/factory";
const mockData = [factory( "RemoteTaxon" )];
jest.mock( "sharedHooks/useAuthenticatedQuery", ( ) => ( {
__esModule: true,
default: ( ) => ( {
data: mockData
} )
} ) );
describe( "IconicTaxonChooser", () => {
it( "should be accessible", () => {
const mockTaxon = factory( "RemoteTaxon", {
name: "Aves"
} );
expect(
<IconicTaxonChooser chosen={[mockTaxon.name.toLowerCase()]} />
).toBeAccessible( );
} );
it( "should show an iconic taxa as selected", async ( ) => {
const mockTaxon = factory( "RemoteTaxon", {
name: "Plantae",
iconic_taxon_name: "Plantae"
} );
render( <IconicTaxonChooser chosen={[mockTaxon.name.toLowerCase()]} /> );
const plantButton = await screen.findByTestId(
`IconicTaxonButton.${mockTaxon.name.toLowerCase( )}`
);
const birdButton = await screen.findByTestId( "IconicTaxonButton.aves" );
expect( plantButton ).toHaveAccessibilityState( { selected: true } );
expect( birdButton ).toHaveAccessibilityState( { selected: false } );
} );
} );