mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-01-04 11:58:08 -05:00
* 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
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.tsx";
|
|
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 }
|
|
} ) );
|
|
} );
|
|
} );
|