Files
iNaturalistReactNative/tests/unit/components/Projects/ProjectDetails.test.js
Amanda Bullington 0d69fe1568 Fetch user locale from server and change language (#255)
* Fetch user from server, set locale in realm and change language with i18next
* Added some Spanish translations so I can see localization working
* config QueryClient with `cacheTime: Infinity` to deal with "Jest did not
  exit" errors

Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
2022-12-09 15:51:17 -08:00

40 lines
1.1 KiB
JavaScript

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
}
} )
};
} );
test( "displays project details", ( ) => {
const { getByTestId, getByText } = renderComponent( <ProjectDetails /> );
expect( getByText( mockProject.title ) ).toBeTruthy( );
expect( getByText( mockProject.description ) ).toBeTruthy( );
expect(
getByTestId( "ProjectDetails.headerImage" ).props.source
).toStrictEqual( { uri: mockProject.header_image_url } );
expect(
getByTestId( "ProjectDetails.projectIcon" ).props.source
).toStrictEqual( { uri: mockProject.icon } );
} );