overleaf/services/web/test/frontend/features/file-tree/helpers/render-with-context.js
Alf Eaton 7c97f8ab6e Switch to new JSX runtime (#4225)
* Use new JSX runtime and update Babel Node target
* Update .eslintrc
* Remove React imports

GitOrigin-RevId: 559de0267f8f2934c56a860ea8701bb522aa861a
2021-06-24 02:06:59 +00:00

34 lines
906 B
JavaScript

import { render } from '@testing-library/react'
import FileTreeContext from '../../../../../frontend/js/features/file-tree/components/file-tree-context'
export default (children, options = {}) => {
let { contextProps = {}, ...renderOptions } = options
contextProps = {
projectId: '123abc',
rootFolder: [
{
docs: [],
fileRefs: [],
folders: [],
},
],
hasWritePermissions: true,
userHasFeature: () => true,
refProviders: {},
reindexReferences: () => {
console.log('reindex references')
},
setRefProviderEnabled: provider => {
console.log(`ref provider ${provider} enabled`)
},
setStartedFreeTrial: () => {
console.log('started free trial')
},
onSelect: () => {},
...contextProps,
}
return render(
<FileTreeContext {...contextProps}>{children}</FileTreeContext>,
renderOptions
)
}