Files
iNaturalistReactNative/tests/unit/components/Camera/CameraContainer.test.js
Johannes Klein b4516b7b25 Update react native to v0.78.x (#3043)
* Update package.json

* Update package.json

* Updates for native files with upgrade-helpers

* Update .flowconfig

* Update package-lock.json

* Update Podfile.lock

* Add react-dom types

* Update package-lock.json

* Wrong install

* Use types-react-codemod

* Update TaxonSearch.tsx

* Remove react-native-accessibility-engine dependency

This is currently not maintained and not compatible with RN 0.78

* Comment out accessibility tests

* Disable broken snapshot test

* Move broken test

* Move broken test

* Move broken test

* Remove duplicate file

* Move broken tests

* Move broken tests

* Move broken tests

* Move broken tests

* Move broken tests

* Move broken test

* Remove duplicate file

* Move broken tests
2025-08-09 13:47:46 +02:00

86 lines
2.2 KiB
JavaScript

import {
fireEvent,
screen
} from "@testing-library/react-native";
import CameraContainer from "components/Camera/CameraContainer.tsx";
import React from "react";
import { View } from "react-native";
import factory from "tests/factory";
import { renderComponent } from "tests/helpers/render";
const mockedNavigate = jest.fn();
const mockTaxon = factory( "RemoteTaxon" );
jest.mock( "sharedHooks/useAuthenticatedQuery", () => ( {
__esModule: true,
default: () => ( {
data: mockTaxon
} )
} ) );
jest.mock( "@react-navigation/native", () => {
const actualNav = jest.requireActual( "@react-navigation/native" );
return {
...actualNav,
useNavigation: () => ( {
navigate: mockedNavigate,
addListener: () => jest.fn()
} ),
useRoute: () => ( {} ),
useFocusEffect: () => ( {} )
};
} );
const mockView = <View />;
jest.mock( "components/Camera/CameraView.tsx", () => ( {
__esModule: true,
default: ( ) => mockView
} ) );
jest.mock( "components/Camera/FadeInOutView.tsx", () => ( {
__esModule: true,
default: () => mockView
} ) );
jest.mock( "components/Camera/StandardCamera/PhotoPreview", () => ( {
__esModule: true,
default: () => mockView
} ) );
jest.mock( "components/Camera/AICamera/FrameProcessorCamera", () => ( {
__esModule: true,
default: () => mockView
} ) );
function renderCameraContainer( ) {
return renderComponent( <CameraContainer /> );
}
describe( "CameraContainer", ( ) => {
beforeAll( async ( ) => {
jest.useFakeTimers( );
} );
it( "should not have accessibility errors", async ( ) => {
renderCameraContainer( );
// const cameraWithDevice = await screen.findByTestId( "CameraWithDevice" );
// Disabled during the update to RN 0.78
// expect( cameraWithDevice ).toBeAccessible();
} );
it( "should first render with flash disabled", async () => {
renderCameraContainer( );
await screen.findByTestId( "flash-button-label-flash-off" );
} );
it( "should change to flash enabled on button press", async () => {
renderCameraContainer( );
const flashButton = await screen.findByTestId(
"flash-button-label-flash-off"
);
fireEvent.press( flashButton );
await screen.findByTestId( "flash-button-label-flash" );
} );
} );