mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-04-21 07:20:03 -04:00
* Add eslint-plugin-testing-library dependency * Enable plugin inside tests folder * Fix errors given by eslint-plugin
49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
import { screen } from "@testing-library/react-native";
|
|
import ProjectDetails from "components/Projects/ProjectDetails";
|
|
import React from "react";
|
|
|
|
import factory from "../../../factory";
|
|
import { renderComponent } from "../../../helpers/render";
|
|
|
|
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,
|
|
useRoute: ( ) => ( {
|
|
params: {
|
|
id: mockProject.id
|
|
}
|
|
} )
|
|
};
|
|
} );
|
|
|
|
describe( "ProjectDetails", () => {
|
|
test( "should not have accessibility errors", async () => {
|
|
renderComponent( <ProjectDetails /> );
|
|
const projectDetails = await screen.findByTestId( "project-details" );
|
|
expect( projectDetails ).toBeAccessible();
|
|
} );
|
|
|
|
test( "displays project details", ( ) => {
|
|
renderComponent( <ProjectDetails /> );
|
|
|
|
expect( screen.getByText( mockProject.title ) ).toBeTruthy( );
|
|
expect( screen.getByText( mockProject.description ) ).toBeTruthy( );
|
|
expect(
|
|
screen.getByTestId( "ProjectDetails.headerImage" ).props.source
|
|
).toStrictEqual( { uri: mockProject.header_image_url } );
|
|
expect(
|
|
screen.getByTestId( "ProjectDetails.projectIcon" ).props.source
|
|
).toStrictEqual( { uri: mockProject.icon } );
|
|
} );
|
|
} );
|