mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 02:45:26 -05:00
cda947d1ac
GitOrigin-RevId: c3d9601256af8720ab41264609cb5c5c810afbba
43 lines
1.1 KiB
JavaScript
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
|
|
}
|