| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- // 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
- }
|