Files
iNaturalistReactNative/tests/unit/components/SharedComponents/TaxonGridItem.test.js
Ryan Stelly b78be9243d lint rule & autofix for "trailing comma" (#3299)
* (lint) MOB-1063 enforce trailing commas

* autofix trailing commas

* manually fix newly introduced maxlen violations

* add trailing comma convention to i18n build
2025-12-22 20:17:13 -06:00

56 lines
1.4 KiB
JavaScript

import {
fireEvent,
screen,
} from "@testing-library/react-native";
import TaxonGridItem from "components/SharedComponents/TaxonGridItem";
import React from "react";
import factory from "tests/factory";
import { renderComponent } from "tests/helpers/render";
const mockTaxon = factory( "RemoteTaxon" );
const mockedNavigate = jest.fn( );
jest.mock( "@react-navigation/native", () => {
const actualNav = jest.requireActual( "@react-navigation/native" );
return {
...actualNav,
useNavigation: () => ( {
navigate: mockedNavigate,
} ),
useRoute: ( ) => ( {
} ),
useNavigationState: jest.fn( ),
};
} );
jest.mock( "sharedHooks/useAuthenticatedQuery", () => ( {
__esModule: true,
default: ( ) => ( {
data: {
total_results: 0,
},
} ),
} ) );
const renderTaxonGridItem = ( ) => renderComponent(
<TaxonGridItem taxon={mockTaxon} />,
);
describe( "TaxonGridItem", ( ) => {
it( "should be accessible", ( ) => {
// Disabled during the update to RN 0.78
// expect( <TaxonGridItem taxon={mockTaxon} /> ).toBeAccessible();
} );
it( "should navigate to user profile on tap", ( ) => {
renderTaxonGridItem( );
fireEvent.press( screen.getByTestId( `TaxonGridItem.Pressable.${mockTaxon.id}` ) );
expect( mockedNavigate ).toHaveBeenCalledWith( expect.objectContaining( {
name: "TaxonDetails",
params: { id: mockTaxon.id },
} ) );
} );
} );