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'
|
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
|
|
|
}
|
|
|
|
|
2021-02-17 05:05:33 -05:00
|
|
|
export function cleanUpContext() {
|
|
|
|
delete window._ide
|
|
|
|
}
|