diff --git a/packages/shared/src/components/modals/post/CommentModal.spec.tsx b/packages/shared/src/components/modals/post/CommentModal.spec.tsx new file mode 100644 index 00000000000..1c7b8991eea --- /dev/null +++ b/packages/shared/src/components/modals/post/CommentModal.spec.tsx @@ -0,0 +1,181 @@ +import React, { type ReactNode } from 'react'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import { render, screen } from '@testing-library/react'; +import CommentModal from './CommentModal'; +import Post from '../../../../__tests__/fixture/post'; +import loggedUser from '../../../../__tests__/fixture/loggedUser'; +import { useAuthContext } from '../../../contexts/AuthContext'; +import useCommentById from '../../../hooks/comments/useCommentById'; +import { useNotificationToggle } from '../../../hooks/notifications'; +import { useMutateComment } from '../../../hooks/post/useMutateComment'; + +jest.mock('../common/Modal', () => { + const mockReact = jest.requireActual('react') as typeof React; + + const MockModalBody = mockReact.forwardRef< + HTMLElement, + { children: ReactNode; className?: string } + >(({ children, className }, ref) => ( +
+ {children} +
+ )); + + MockModalBody.displayName = 'MockModalBody'; + + const Modal = ({ children }: { children: ReactNode }) => ( +
{children}
+ ); + + Modal.Body = MockModalBody; + + return { Modal }; +}); + +jest.mock('../../comments/CommentContainer', () => ({ + __esModule: true, + default: () =>
, +})); + +jest.mock('../../fields/Switch', () => { + const mockReact = jest.requireActual('react') as typeof React; + + const MockSwitch = mockReact.forwardRef< + HTMLLabelElement, + { + children: ReactNode; + className?: string; + labelClassName?: string; + } + >(({ children, className, labelClassName }, ref) => ( + + )); + + MockSwitch.displayName = 'MockSwitch'; + + return { + Switch: MockSwitch, + }; +}); + +jest.mock('../../fields/MarkdownInput/CommentMarkdownInput', () => { + const mockReact = jest.requireActual('react') as typeof React; + + const MockCommentMarkdownInput = mockReact.forwardRef< + HTMLFormElement, + { + className?: Record; + formProps?: Record; + } + >(({ className, formProps }, ref) => ( +
+
+