overleaf-cep/services/web/test/frontend/helpers/render-with-context.tsx
Antoine Clausse 07b1701b72 [web] Convert EditorProviders and some test files to Typescript (#26512)
* Rename files to tsx

* Update types

* Remove props that aren't typed

* Add `LayoutContextOwnStates`

* Use `LayoutContextOwnStates`

* Ignore ts errors about `SocketIOMock`

* Address comments: remove `satisfies`, update `BroadcastChannel` fixture

* Add types to `makeEditorOpenDocProvider`. Update `openDocId`->`currentDocumentId`

* misc.

* Type sockets as `SocketIOMock & Socket`

* Fix remaining typing errors

* Fix type of `ideReactContextValue`

GitOrigin-RevId: 2734ac707517d56c452b0bf06ea3438f947a64be
2025-07-07 08:05:40 +00:00

20 lines
587 B
TypeScript

import React from 'react'
import { render, type RenderOptions } from '@testing-library/react'
import { EditorProviders, type EditorProvidersProps } from './editor-providers'
export function renderWithEditorContext(
component: React.ReactElement,
contextProps: EditorProvidersProps = {},
renderOptions: RenderOptions = {}
) {
const EditorProvidersWrapper = ({
children,
}: {
children: React.ReactNode
}) => <EditorProviders {...contextProps}>{children}</EditorProviders>
return render(component, {
wrapper: EditorProvidersWrapper,
...renderOptions,
})
}