file-tree-toolbar.test.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  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. expect(screen.queryByRole('button', { name: 'New File' })).to.not.exist
  10. expect(screen.queryByRole('button', { name: 'New Folder' })).to.not.exist
  11. expect(screen.queryByRole('button', { name: 'Upload' })).to.not.exist
  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: 'Rename' })
  26. screen.getByRole('button', { name: 'Delete' })
  27. })
  28. })