mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-04-21 07:20:03 -04:00
* Random code cleanup * Simplify useCurrentUser hook; only fetch messages if current user; closes #272 * Fix padding around login prompt button * Code cleanup * Fix projects; display search and tabs separately * Remove log
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
import { fireEvent } from "@testing-library/react-native";
|
|
import Projects from "components/Projects/Projects";
|
|
import React from "react";
|
|
|
|
import factory from "../../../factory";
|
|
import { renderComponent } from "../../../helpers/render";
|
|
|
|
const mockedNavigate = jest.fn( );
|
|
const mockProject = factory( "RemoteProject" );
|
|
|
|
jest.mock( "sharedHooks/useAuthenticatedQuery", ( ) => ( {
|
|
__esModule: true,
|
|
default: ( ) => ( {
|
|
data: [mockProject]
|
|
} )
|
|
} ) );
|
|
|
|
jest.mock( "@react-navigation/native", ( ) => {
|
|
const actualNav = jest.requireActual( "@react-navigation/native" );
|
|
return {
|
|
...actualNav,
|
|
useNavigation: ( ) => ( {
|
|
navigate: mockedNavigate
|
|
} )
|
|
};
|
|
} );
|
|
|
|
test( "displays project search results", ( ) => {
|
|
const { getByTestId, getByText } = renderComponent( <Projects /> );
|
|
|
|
const input = getByTestId( "ProjectSearch.input" );
|
|
fireEvent.changeText( input, "butterflies" );
|
|
|
|
expect( getByText( mockProject.title ) ).toBeTruthy( );
|
|
expect( getByTestId( `Project.${mockProject.id}.photo` ).props.source )
|
|
.toStrictEqual( { uri: mockProject.icon } );
|
|
fireEvent.press( getByTestId( `Project.${mockProject.id}` ) );
|
|
expect( mockedNavigate ).toHaveBeenCalledWith( "ProjectDetails", {
|
|
id: mockProject.id
|
|
} );
|
|
} );
|