render-with-context.js 929 B

1234567891011121314151617181920212223242526272829303132333435
  1. import React from 'react'
  2. import { render } from '@testing-library/react'
  3. import FileTreeContext from '../../../../../frontend/js/features/file-tree/components/file-tree-context'
  4. export default (children, options = {}) => {
  5. let { contextProps = {}, ...renderOptions } = options
  6. contextProps = {
  7. projectId: '123abc',
  8. rootFolder: [
  9. {
  10. docs: [],
  11. fileRefs: [],
  12. folders: []
  13. }
  14. ],
  15. hasWritePermissions: true,
  16. userHasFeature: () => true,
  17. refProviders: {},
  18. reindexReferences: () => {
  19. console.log('reindex references')
  20. },
  21. setRefProviderEnabled: provider => {
  22. console.log(`ref provider ${provider} enabled`)
  23. },
  24. setStartedFreeTrial: () => {
  25. console.log('started free trial')
  26. },
  27. onSelect: () => {},
  28. ...contextProps
  29. }
  30. return render(
  31. <FileTreeContext {...contextProps}>{children}</FileTreeContext>,
  32. renderOptions
  33. )
  34. }