file-tree-toolbar.test.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { expect } from 'chai'
  2. import React from 'react'
  3. import { screen } from '@testing-library/react'
  4. import renderWithContext from '../helpers/render-with-context'
  5. import FileTreeToolbar from '../../../../../frontend/js/features/file-tree/components/file-tree-toolbar'
  6. describe('<FileTreeToolbar/>', function() {
  7. it('without selected files', function() {
  8. renderWithContext(<FileTreeToolbar />)
  9. screen.getByRole('button', { name: 'New File' })
  10. screen.getByRole('button', { name: 'New Folder' })
  11. screen.getByRole('button', { name: 'Upload' })
  12. expect(screen.queryByRole('button', { name: 'Rename' })).to.not.exist
  13. expect(screen.queryByRole('button', { name: 'Delete' })).to.not.exist
  14. })
  15. it('read-only', function() {
  16. renderWithContext(<FileTreeToolbar />, {
  17. contextProps: { hasWritePermissions: false }
  18. })
  19. expect(screen.queryByRole('button')).to.not.exist
  20. })
  21. it('with one selected file', function() {
  22. renderWithContext(<FileTreeToolbar />, {
  23. contextProps: { initialSelectedEntityId: '123abc' }
  24. })
  25. screen.getByRole('button', { name: 'New File' })
  26. screen.getByRole('button', { name: 'New Folder' })
  27. screen.getByRole('button', { name: 'Upload' })
  28. screen.getByRole('button', { name: 'Rename' })
  29. screen.getByRole('button', { name: 'Delete' })
  30. })
  31. })