diff --git a/src/components/App/DeviceCompatibilityNotification/__tests__/index.tsx b/src/components/App/DeviceCompatibilityNotification/__tests__/index.tsx new file mode 100644 index 000000000..c2aa23e2e --- /dev/null +++ b/src/components/App/DeviceCompatibilityNotification/__tests__/index.tsx @@ -0,0 +1,45 @@ +import '@testing-library/jest-dom' +import { fireEvent, render, screen } from '@testing-library/react' +import React from 'react' +import { DeviceCompatibilityNotice } from '..' +import * as MobileHook from '../../../../hooks/useIsMobile' + +jest.mock('~/hooks/useIsMobile') + +const useIsMobileHook = jest.spyOn(MobileHook, 'useIsMobile') + +describe('DeviceCompatibilityNotice Component', () => { + beforeEach(() => { + jest.clearAllMocks() + useIsMobileHook.mockReturnValue(true) + }) + + it('should display message and button correctly', () => { + render() + + expect(screen.getByText('Second Brain is currently')).toBeInTheDocument() + expect(screen.getByText('optimized for Desktop.')).toBeInTheDocument() + expect(screen.getByText('Mobile support coming soon.')).toBeInTheDocument() + expect(screen.getByRole('button', { name: 'Got It' })).toBeInTheDocument() + }) + + it('hides the notice when "Got It" button is clicked', () => { + jest.mock('../', () => jest.fn(() =>
)) + + render() + + fireEvent.click(screen.getByRole('button', { name: 'Got It' })) + + expect(screen.queryByTestId('device-compatibility-notice')).not.toBeInTheDocument() + }) + + it('should not render notice when useIsMobile hook returns false.', () => { + useIsMobileHook.mockReturnValue(false) + + jest.mock('../', () => jest.fn(() =>
)) + + render() + + expect(screen.queryByTestId('device-compatibility-notice')).not.toBeInTheDocument() + }) +})