mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-05-18 13:32:27 -04:00
* 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
96 lines
2.9 KiB
JavaScript
96 lines
2.9 KiB
JavaScript
import { screen } from "@testing-library/react-native";
|
|
import CustomTabBarContainer from "navigation/BottomTabNavigator/CustomTabBarContainer";
|
|
import React from "react";
|
|
import * as useCurrentUser from "sharedHooks/useCurrentUser";
|
|
import * as useIsConnected from "sharedHooks/useIsConnected.ts";
|
|
import useStore from "stores/useStore";
|
|
import factory from "tests/factory";
|
|
import faker from "tests/helpers/faker";
|
|
import { renderComponent } from "tests/helpers/render";
|
|
|
|
const initialPersistedStoreState = useStore.getState( );
|
|
|
|
const mockUser = factory( "LocalUser", {
|
|
login: faker.internet.userName( ),
|
|
icon_url: faker.image.url( )
|
|
} );
|
|
|
|
jest.mock( "sharedHooks/useCurrentUser", ( ) => ( {
|
|
__esModule: true,
|
|
default: () => undefined
|
|
} ) );
|
|
|
|
jest.mock( "sharedHooks/useAuthenticatedQuery", () => ( {
|
|
__esModule: true,
|
|
default: () => ( {
|
|
data: 0
|
|
} )
|
|
} ) );
|
|
|
|
describe( "CustomTabBar", () => {
|
|
beforeEach( ( ) => {
|
|
jest.useFakeTimers();
|
|
} );
|
|
|
|
// it( "should render correctly", async () => {
|
|
// renderComponent( <CustomTabBarContainer navigation={jest.fn( )} /> );
|
|
|
|
// await expect( screen ).toMatchSnapshot();
|
|
// } );
|
|
|
|
it( "should not have accessibility errors", async () => {
|
|
const tabBar = <CustomTabBarContainer navigation={jest.fn( )} />;
|
|
|
|
await expect( tabBar ).toBeAccessible();
|
|
} );
|
|
|
|
it( "should display person icon while user is logged out", async () => {
|
|
renderComponent( <CustomTabBarContainer navigation={jest.fn( )} isOnline /> );
|
|
|
|
const personIcon = screen.getByTestId( "NavButton.personIcon" );
|
|
await expect( personIcon ).toBeVisible( );
|
|
} );
|
|
|
|
it( "should display avatar while user is logged in", async () => {
|
|
jest.spyOn( useCurrentUser, "default" ).mockImplementation( () => mockUser );
|
|
renderComponent( <CustomTabBarContainer navigation={jest.fn( )} isOnline /> );
|
|
|
|
const avatar = screen.getByTestId( "UserIcon.photo" );
|
|
await expect( avatar ).toBeVisible( );
|
|
} );
|
|
|
|
it( "should display person icon when connectivity is low", async ( ) => {
|
|
jest.spyOn( useIsConnected, "default" ).mockImplementation( () => false );
|
|
renderComponent( <CustomTabBarContainer navigation={jest.fn( )} isOnline={false} /> );
|
|
|
|
const personIcon = screen.getByTestId( "NavButton.personIcon" );
|
|
await expect( personIcon ).toBeVisible( );
|
|
} );
|
|
} );
|
|
|
|
describe( "CustomTabBar with advanced user layout", () => {
|
|
beforeAll( ( ) => {
|
|
useStore.setState( { isAdvancedUser: true } );
|
|
} );
|
|
|
|
afterAll( ( ) => {
|
|
useStore.setState( initialPersistedStoreState );
|
|
} );
|
|
|
|
beforeEach( ( ) => {
|
|
jest.resetAllMocks();
|
|
} );
|
|
|
|
it( "should render correctly", async () => {
|
|
renderComponent( <CustomTabBarContainer navigation={jest.fn( )} /> );
|
|
|
|
await expect( screen ).toMatchSnapshot();
|
|
} );
|
|
|
|
it( "should not have accessibility errors", async () => {
|
|
const tabBar = <CustomTabBarContainer navigation={jest.fn( )} />;
|
|
|
|
await expect( tabBar ).toBeAccessible();
|
|
} );
|
|
} );
|