import '@testing-library/jest-dom' import { render } from '@testing-library/react' import { useAtomValue } from 'jotai' import MainViewContainer from './index' import { MainViewState } from '@/constants/screens' // Mocking the Jotai atom jest.mock('jotai', () => { const originalModule = jest.requireActual('jotai') return { ...originalModule, useAtomValue: jest.fn(), } }) // Mocking the screen components jest.mock('@/screens/Hub', () => () =>
Hub Screen
) jest.mock('@/screens/LocalServer', () => () =>
Local Server Screen
) jest.mock('@/screens/Settings', () => () =>
Settings Screen
) jest.mock('@/screens/Thread', () => () =>
Thread Screen
) describe('MainViewContainer', () => { it('renders HubScreen when mainViewState is Hub', () => { ;(useAtomValue as jest.Mock).mockReturnValue(MainViewState.Hub) const { getByText } = render() expect(getByText('Hub Screen')).toBeInTheDocument() }) it('renders SettingsScreen when mainViewState is Settings', () => { ;(useAtomValue as jest.Mock).mockReturnValue(MainViewState.Settings) const { getByText } = render() expect(getByText('Settings Screen')).toBeInTheDocument() }) it('renders LocalServerScreen when mainViewState is LocalServer', () => { ;(useAtomValue as jest.Mock).mockReturnValue(MainViewState.LocalServer) const { getByText } = render() expect(getByText('Local Server Screen')).toBeInTheDocument() }) it('renders ThreadScreen when mainViewState is not defined', () => { ;(useAtomValue as jest.Mock).mockReturnValue(undefined) const { getByText } = render() expect(getByText('Thread Screen')).toBeInTheDocument() }) })