overleaf/services/web/test/frontend/features/file-tree/components/file-tree-toolbar.test.js
Timothée Alby 420aa4a657 Merge pull request #3232 from overleaf/ta-file-tree-react
React File Tree

GitOrigin-RevId: fb3141ba8cd9ca0d68e87edb74764a360144c8fe
2020-11-27 03:05:05 +00:00

35 lines
1.2 KiB
JavaScript

import { expect } from 'chai'
import React from 'react'
import { screen } from '@testing-library/react'
import renderWithContext from '../helpers/render-with-context'
import FileTreeToolbar from '../../../../../frontend/js/features/file-tree/components/file-tree-toolbar'
describe('<FileTreeToolbar/>', function() {
it('without selected files', function() {
renderWithContext(<FileTreeToolbar />)
expect(screen.queryByRole('button', { name: 'New File' })).to.not.exist
expect(screen.queryByRole('button', { name: 'New Folder' })).to.not.exist
expect(screen.queryByRole('button', { name: 'Upload' })).to.not.exist
expect(screen.queryByRole('button', { name: 'Rename' })).to.not.exist
expect(screen.queryByRole('button', { name: 'Delete' })).to.not.exist
})
it('read-only', function() {
renderWithContext(<FileTreeToolbar />, {
contextProps: { hasWritePermissions: false }
})
expect(screen.queryByRole('button')).to.not.exist
})
it('with one selected file', function() {
renderWithContext(<FileTreeToolbar />, {
contextProps: { initialSelectedEntityId: '123abc' }
})
screen.getByRole('button', { name: 'Rename' })
screen.getByRole('button', { name: 'Delete' })
})
})