2021-04-23 05:01:16 -04:00
|
|
|
// Disable prop type checks for test harnesses
|
|
|
|
/* eslint-disable react/prop-types */
|
|
|
|
|
2020-12-14 06:44:10 -05:00
|
|
|
import { render } from '@testing-library/react'
|
2021-04-23 05:01:16 -04:00
|
|
|
import { ChatProvider } from '../../../frontend/js/features/chat/context/chat-context'
|
2022-03-30 05:49:41 -04:00
|
|
|
import { EditorProviders } from './editor-providers'
|
2021-02-09 10:37:48 -05:00
|
|
|
|
2022-01-10 10:46:46 -05:00
|
|
|
export function renderWithEditorContext(
|
|
|
|
component,
|
|
|
|
contextProps,
|
|
|
|
renderOptions = {}
|
|
|
|
) {
|
2021-06-16 05:32:38 -04:00
|
|
|
const EditorProvidersWrapper = ({ children }) => (
|
|
|
|
<EditorProviders {...contextProps}>{children}</EditorProviders>
|
|
|
|
)
|
|
|
|
|
2022-01-10 10:46:46 -05:00
|
|
|
return render(component, {
|
|
|
|
wrapper: EditorProvidersWrapper,
|
|
|
|
...renderOptions,
|
|
|
|
})
|
2021-04-23 05:01:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export function ChatProviders({ children, ...props }) {
|
|
|
|
return (
|
|
|
|
<EditorProviders {...props}>
|
|
|
|
<ChatProvider>{children}</ChatProvider>
|
|
|
|
</EditorProviders>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-06-03 09:44:23 -04:00
|
|
|
export function renderWithChatContext(component, props) {
|
2021-06-16 05:32:38 -04:00
|
|
|
const ChatProvidersWrapper = ({ children }) => (
|
|
|
|
<ChatProviders {...props}>{children}</ChatProviders>
|
|
|
|
)
|
|
|
|
|
|
|
|
return render(component, { wrapper: ChatProvidersWrapper })
|
2021-02-09 10:37:48 -05:00
|
|
|
}
|
2021-02-17 05:05:33 -05:00
|
|
|
|
|
|
|
export function cleanUpContext() {
|
|
|
|
delete window.user
|
|
|
|
delete window.project_id
|
|
|
|
delete window._ide
|
|
|
|
}
|