Files
iNaturalistReactNative/tests/unit/components/AddObsModal.test.js
Johannes Klein efd88802ed 1364 UI setting (#1384)
* Show settings menu item to all users

* Add strings

* Update strings.ftl

* Add a logged out section to Settings

* Refactor logged in section

* Prop to use small label

* Restyle radio buttons

* Add react-native-mmkv

* Show logged in section only when logged in

* Add a boolean if user is advanced

* Hook for storage

* Change bottom tab button based on isAdvancedUser

* Add string

* Change supported AR camera version

* Refactor navigation out of AddObsModal

* Create new observation only on ObsEdit navigation inside Modal

* Reset store needs to happen before making new observation

* Merge conflicts removed some strings, put them back

* Remove comment

* Refactor AddObsModal test to unit test only

* Refactor navigation parts into integration test

* Add test case for advanced user

* Code style

* Add test case for advanced user to Tab bar

* Do not use a user object for snapshot tests, only the advanced user layout

* Use advanced user layout in navigation tests

* StandardCamera test with advanced user layout

* Add default value for boolean setting

* Remove default value as it is breaking immediate update of UI

* Refactor persisted layout value to be a part of zustand store

* Refactor persisted state into one bound store

* Explicit state for snapshot needed?

* Revert "Explicit state for snapshot needed?"

This reverts commit d448edc3dc.

* Remove snapshot test
2024-04-12 16:47:10 +02:00

36 lines
1.0 KiB
JavaScript

import { render, screen } from "@testing-library/react-native";
import AddObsModal from "components/AddObsModal";
import i18next from "i18next";
import React from "react";
// eslint-disable-next-line import/no-unresolved
import mockPlatform from "react-native/Libraries/Utilities/Platform";
jest.mock( "react-native/Libraries/Utilities/Platform", ( ) => ( {
OS: "ios",
select: jest.fn( ),
Version: 11
} ) );
describe( "AddObsModal", ( ) => {
afterEach( () => {
jest.clearAllMocks( );
} );
it( "hides AR camera button on older devices", async ( ) => {
render( <AddObsModal closeModal={jest.fn( )} /> );
const arCameraButton = screen.getByLabelText(
i18next.t( "AR-Camera" )
);
expect( arCameraButton ).toBeOnTheScreen();
} );
it( "hides AR camera button on older devices", async ( ) => {
mockPlatform.Version = 9;
render( <AddObsModal closeModal={jest.fn( )} /> );
const arCameraButton = screen.queryByLabelText(
i18next.t( "AR-Camera" )
);
expect( arCameraButton ).toBeFalsy( );
} );
} );