// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 import '@testing-library/jest-dom'; import React from 'react'; import Roster from '../../../../src/components/ui/Roster'; import RosterCell from '../../../../src/components/ui/Roster/RosterCell'; import RosterHeader from '../../../../src/components/ui/Roster/RosterHeader'; import lightTheme from '../../../../src/theme/light'; import { renderWithTheme } from '../../../test-helpers'; import { fireEvent } from '@testing-library/react'; describe('Roster', () => { it('should render a search button when search is pressed', () => { const component = ( {}} /> ); const { getByLabelText, queryAllByLabelText } = renderWithTheme( lightTheme, component ); expect.not.arrayContaining(queryAllByLabelText('Search')); fireEvent( getByLabelText('Open search'), new MouseEvent('click', { bubbles: true, cancelable: true, }) ); expect(getByLabelText('Search')).toBeInTheDocument(); fireEvent( getByLabelText('clear Search'), new MouseEvent('click', { bubbles: true, cancelable: true, }) ); }); }); describe('RosterCell', () => { it('should render a name', () => { const component = ; const { getByText } = renderWithTheme(lightTheme, component); expect(getByText('James')).toBeInTheDocument(); }); it('should render a subtitle', () => { const component = ; const { getByText } = renderWithTheme(lightTheme, component); expect(getByText('Moderator')).toBeInTheDocument(); }); it('should show microphone if not muted', () => { const component = ; const { getByTitle } = renderWithTheme(lightTheme, component); expect(getByTitle('Microphone')).toBeInTheDocument(); }); it('should show muted microphone if muted', () => { const component = ; const { getByTitle } = renderWithTheme(lightTheme, component); expect(getByTitle('Muted microphone')).toBeInTheDocument(); }); it('should show screen share icon if user is content sharing and video sharing', () => { const component = ; const { getByTitle } = renderWithTheme(lightTheme, component); expect(getByTitle('Screen share')).toBeInTheDocument(); }); it('should show tardy message in place of icons', () => { const component = ( ); const { getByText, queryByTitle } = renderWithTheme(lightTheme, component); expect(getByText('2 minutes')).toBeInTheDocument(); expect(queryByTitle('Microphone')).toBeNull(); }); });