// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import React, {type ComponentProps} from 'react'; import {Screens} from '@constants'; import {useIsTablet} from '@hooks/device'; import {bottomSheet} from '@screens/navigation'; import {act, fireEvent, renderWithIntlAndTheme} from '@test/intl-test-helper'; import UserAvatarsStack from './index'; jest.mock('@screens/navigation', () => ({ bottomSheet: jest.fn(), })); jest.mock('@gorhom/bottom-sheet', () => ({ useBottomSheetScrollableCreator: jest.fn().mockReturnValue( (props: object) => { const {View} = require('react-native'); return ; }, ), })); jest.mock('@hooks/device', () => ({ useIsTablet: jest.fn().mockReturnValue(false), })); describe('UserAvatarsStack', () => { function getBaseProps(): ComponentProps { return { location: Screens.CHANNEL, users: [], bottomSheetTitle: {id: 'test', defaultMessage: 'bottom sheet title test text'}, }; } it('should use the correct bottom sheet title', async () => { const props = getBaseProps(); jest.mocked(useIsTablet).mockReturnValueOnce(false); const {root} = renderWithIntlAndTheme(); await act(async () => { fireEvent.press(root); }); expect(bottomSheet).toHaveBeenCalledWith(expect.any(Function), expect.any(Array)); const Content = jest.mocked(bottomSheet).mock.calls[0][0]; const {getByText} = renderWithIntlAndTheme(); expect(getByText(props.bottomSheetTitle.defaultMessage as string)).toBeVisible(); }); });