overleaf/services/web/test/frontend/features/file-tree/helpers/render-with-context.js
Alf Eaton ee79728bf9 Only check a user's features for importing from reference provider (#3797)
GitOrigin-RevId: cc5a36be20c673f8941a2694eaeba80eebb4db6a
2021-03-25 03:04:57 +00:00

35 lines
929 B
JavaScript

import React from 'react'
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
)
}