overleaf/services/web/test/frontend/features/file-tree/helpers/render-with-context.js
Timothée Alby 392410390e Merge pull request #6209 from overleaf/ta-file-tree-rework
File Tree Misc Code Changes

GitOrigin-RevId: dce64a5378ecee5c8a2e25e02502ae631d87f36b
2022-01-11 09:04:50 +00:00

51 lines
1.3 KiB
JavaScript

import FileTreeContext from '../../../../../frontend/js/features/file-tree/components/file-tree-context'
import { renderWithEditorContext } from '../../../helpers/render-with-context'
export default (children, options = {}) => {
let { contextProps = {}, ...renderOptions } = options
contextProps = {
projectId: '123abc',
projectRootFolder: [
{
_id: 'root-folder-id',
name: 'rootFolder',
docs: [],
fileRefs: [],
folders: [],
},
],
refProviders: {},
reindexReferences: () => {
console.log('reindex references')
},
setRefProviderEnabled: provider => {
console.log(`ref provider ${provider} enabled`)
},
setStartedFreeTrial: () => {
console.log('started free trial')
},
onSelect: () => {},
...contextProps,
}
const {
refProviders,
reindexReferences,
setRefProviderEnabled,
setStartedFreeTrial,
onSelect,
...editorContextProps
} = contextProps
return renderWithEditorContext(
<FileTreeContext
refProviders={refProviders}
reindexReferences={reindexReferences}
setRefProviderEnabled={setRefProviderEnabled}
setStartedFreeTrial={setStartedFreeTrial}
onSelect={onSelect}
>
{children}
</FileTreeContext>,
editorContextProps,
renderOptions
)
}