Files
iNaturalistReactNative/tests/unit/components/Camera/StandardCamera.test.js
Johannes Klein 14d0239468 308 accessibility tests (#393)
* 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
2023-01-27 12:30:57 -08:00

76 lines
1.9 KiB
JavaScript

import { fireEvent, render, screen } from "@testing-library/react-native";
import StandardCamera from "components/Camera/StandardCamera";
import { ObsEditContext } from "providers/contexts";
import React from "react";
import { View } from "react-native";
const mockedNavigate = jest.fn();
jest.mock( "@react-navigation/native", () => {
const actualNav = jest.requireActual( "@react-navigation/native" );
return {
...actualNav,
useNavigation: () => ( {
navigate: mockedNavigate
} ),
useRoute: () => ( {} )
};
} );
const mockValue = {
addCameraPhotosToCurrentObservation: jest.fn(),
allObsPhotoUris: [],
cameraPreviewUris: []
};
const mockView = <View />;
jest.mock( "components/Camera/CameraView", () => ( {
__esModule: true,
default: ( ) => mockView
} ) );
jest.mock( "components/Camera/FadeInOutView", () => ( {
__esModule: true,
default: () => mockView
} ) );
jest.mock( "components/Camera/PhotoPreview", () => ( {
__esModule: true,
default: () => mockView
} ) );
const renderStandardCamera = () => render(
<ObsEditContext.Provider value={mockValue}>
<StandardCamera />
</ObsEditContext.Provider>
);
describe( "StandardCamera", ( ) => {
test( "should not have accessibility errors", () => {
const standardCamera = (
<ObsEditContext.Provider value={mockValue}>
<StandardCamera />
</ObsEditContext.Provider>
);
expect( standardCamera ).toBeAccessible();
} );
test( "should first render with flash disabled", async () => {
renderStandardCamera();
await screen.findByTestId( "flash-button-label-flash-off" );
} );
test( "should change to flash enabled on button press", async () => {
renderStandardCamera();
const flashButton = await screen.findByTestId(
"flash-button-label-flash-off"
);
fireEvent.press( flashButton );
await screen.findByTestId( "flash-button-label-flash" );
} );
} );