mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-04-18 22:11:29 -04:00
* (lint) MOB-1063 enforce trailing commas * autofix trailing commas * manually fix newly introduced maxlen violations * add trailing comma convention to i18n build
56 lines
1.4 KiB
JavaScript
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 },
|
|
} ) );
|
|
} );
|
|
} );
|