mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-04-29 19:27:31 -04:00
* Incremental changes to navbar component * Fix tests * Fix ally tests * Space parens * Add box shadow for android * Add accessibility role * Add a11y * lint * Add basic tests * Fix tests * Fix tests * Update colors * Merge remote changes * Lint * Add more comprehensive test * Incremental changes to navbar component * Fix tests * Fix ally tests * Space parens * Add box shadow for android * Add accessibility role * Add a11y * lint * Add basic tests * Fix tests * Fix tests * Update colors * Merge remote changes * Lint * Add more comprehensive test * switch to react native paper * Make explore button nav to explore * Remove inline styles * Fix border on android * Use user icon component in nav bar * Rename props * Remove t from nav button * Change accessibility props * Use a11y role for tabs * Update NavBar.js * Mock route for messages * Mock route in tests * Remove not needed function * Remove NavBar unit test * Create integration test file * Add container mock to user profile test --------- Co-authored-by: Johannes Klein <johannes.t.klein@gmail.com>
51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
import { fireEvent, screen } 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
|
|
} ),
|
|
useRoute: () => ( {} )
|
|
};
|
|
} );
|
|
|
|
test( "displays project search results", ( ) => {
|
|
renderComponent( <Projects /> );
|
|
|
|
const input = screen.getByTestId( "ProjectSearch.input" );
|
|
fireEvent.changeText( input, "butterflies" );
|
|
|
|
expect( screen.getByText( mockProject.title ) ).toBeTruthy( );
|
|
expect( screen.getByTestId( `Project.${mockProject.id}.photo` ).props.source )
|
|
.toStrictEqual( { uri: mockProject.icon } );
|
|
fireEvent.press( screen.getByTestId( `Project.${mockProject.id}` ) );
|
|
expect( mockedNavigate ).toHaveBeenCalledWith( "ProjectDetails", {
|
|
id: mockProject.id
|
|
} );
|
|
} );
|
|
|
|
describe( "Projects", () => {
|
|
test( "should not have accessibility errors", async ( ) => {
|
|
renderComponent( <Projects /> );
|
|
const projectObservations = await screen.findByTestId( "Projects" );
|
|
expect( projectObservations ).toBeAccessible();
|
|
} );
|
|
} );
|