mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-01-06 04:49:05 -05:00
* Regroup accessibility label strings at end of strings file * Add accessibility test to AddID * Add a11y labels to AddID * Add a11y test to StandardCamera * Add a11y props to StandardCamera * Remove unit test with only todos * Add a11y test to Messages * Refactor PhotoScroll test into own file * Add a11y test to ObsDetails * Add a11y test to ObsList * Add a11y matcher to PhotoGallery test * Add a11y matcher to ProjectDetails test * Add a11y matcher to ProjectObservations test * Add a11y matcher to Projects test * Add a11y props to ProjectList * Add a11y props to ProjectTabs * Add a11y matcher to Search * Add a11y matcher to UserProfile test * Add a11y test matcher to UserText test * Update react-native-accessibility-engine * Add a11y matcher to Tabs test * Add a11y label to a selectable photo * Refactor DataTab tests into separate file * Refactor ActivityTab test out into own file * Added a test how to check if a component uses a mocked container * Add wrong a11y props to TextInput left icon * Enable a11y test with actual BottomSheet because mock does not pass a11y props down * Add a11y default props to Button
78 lines
2.3 KiB
JavaScript
78 lines
2.3 KiB
JavaScript
import { screen } from "@testing-library/react-native";
|
|
import ObsEdit from "components/ObsEdit/ObsEdit";
|
|
import { ObsEditContext } from "providers/contexts";
|
|
import ObsEditProvider from "providers/ObsEditProvider";
|
|
import React from "react";
|
|
|
|
import factory from "../../../factory";
|
|
import { renderComponent } from "../../../helpers/render";
|
|
|
|
const mockLocationName = "San Francisco, CA";
|
|
|
|
jest.mock( "sharedHooks/useLocationName", ( ) => ( {
|
|
__esModule: true,
|
|
default: ( ) => mockLocationName
|
|
} ) );
|
|
|
|
jest.mock( "@react-navigation/native", ( ) => {
|
|
const actualNav = jest.requireActual( "@react-navigation/native" );
|
|
return {
|
|
...actualNav,
|
|
useRoute: ( ) => ( {
|
|
} ),
|
|
useNavigation: ( ) => ( {
|
|
setOptions: jest.fn( )
|
|
} )
|
|
};
|
|
} );
|
|
|
|
const mockCurrentUser = factory( "LocalUser" );
|
|
|
|
jest.mock( "components/ObsEdit/ObsEditHeaderTitle" );
|
|
jest.mock( "components/ObsEdit/DeleteObservationDialog" );
|
|
jest.mock( "components/ObsEdit/SaveDialog" );
|
|
jest.mock( "components/MediaViewer/MediaViewerModal" );
|
|
jest.mock( "components/ObsEdit/EvidenceSection" );
|
|
jest.mock( "components/ObsEdit/IdentificationSection" );
|
|
jest.mock( "components/ObsEdit/OtherDataSection" );
|
|
jest.mock( "components/ObsEdit/AddEvidenceModal" );
|
|
|
|
// Mock ObservationProvider so it provides a specific array of observations
|
|
// without any current observation or ability to update or fetch
|
|
// observations
|
|
jest.mock( "providers/ObsEditProvider" );
|
|
const mockObsEditProviderWithObs = obs => ObsEditProvider.mockImplementation( ( { children } ) => (
|
|
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
<ObsEditContext.Provider value={{
|
|
observations: obs,
|
|
currentObservation: obs[0]
|
|
}}
|
|
>
|
|
{children}
|
|
</ObsEditContext.Provider>
|
|
) );
|
|
|
|
const renderObsEdit = ( ) => renderComponent(
|
|
<ObsEditProvider>
|
|
<ObsEdit />
|
|
</ObsEditProvider>
|
|
);
|
|
|
|
describe( "ObsEdit", () => {
|
|
test( "should not have accessibility errors", async () => {
|
|
const observations = [
|
|
factory( "RemoteObservation", {
|
|
latitude: 37.99,
|
|
longitude: -142.88,
|
|
user: mockCurrentUser,
|
|
place_guess: mockLocationName
|
|
} )
|
|
];
|
|
mockObsEditProviderWithObs( observations );
|
|
renderObsEdit();
|
|
|
|
const obsEdit = await screen.findByTestId( "obs-edit" );
|
|
expect( obsEdit ).toBeAccessible();
|
|
} );
|
|
} );
|