overleaf/services/web/test/frontend/helpers/render-with-context.jsx
Jakob Ackermann 9daa8f5d98 Merge pull request #15040 from overleaf/jpa-js-to-jsx
[web] rename all the JSX files to .jsx/.tsx

GitOrigin-RevId: 82056ae47e017523722cf258dcc83c8a925a28f7
2023-09-29 08:04:29 +00:00

43 lines
1.1 KiB
JavaScript

// Disable prop type checks for test harnesses
/* eslint-disable react/prop-types */
import { render } from '@testing-library/react'
import { ChatProvider } from '../../../frontend/js/features/chat/context/chat-context'
import { EditorProviders } from './editor-providers'
export function renderWithEditorContext(
component,
contextProps,
renderOptions = {}
) {
const EditorProvidersWrapper = ({ children }) => (
<EditorProviders {...contextProps}>{children}</EditorProviders>
)
return render(component, {
wrapper: EditorProvidersWrapper,
...renderOptions,
})
}
export function ChatProviders({ children, ...props }) {
return (
<EditorProviders {...props}>
<ChatProvider>{children}</ChatProvider>
</EditorProviders>
)
}
export function renderWithChatContext(component, props) {
const ChatProvidersWrapper = ({ children }) => (
<ChatProviders {...props}>{children}</ChatProviders>
)
return render(component, { wrapper: ChatProvidersWrapper })
}
export function cleanUpContext() {
delete window.user
delete window.project_id
delete window._ide
}