overleaf/services/web/test/frontend/features/file-tree/components/file-tree-toolbar.test.js
Alf Eaton 7c97f8ab6e Switch to new JSX runtime (#4225)
* Use new JSX runtime and update Babel Node target
* Update .eslintrc
* Remove React imports

GitOrigin-RevId: 559de0267f8f2934c56a860ea8701bb522aa861a
2021-06-24 02:06:59 +00:00

51 lines
1.5 KiB
JavaScript

import { expect } from 'chai'
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 () {
beforeEach(function () {
global.localStorage.clear()
})
it('without selected files', function () {
renderWithContext(<FileTreeToolbar />)
screen.getByRole('button', { name: 'New File' })
screen.getByRole('button', { name: 'New Folder' })
screen.getByRole('button', { name: 'Upload' })
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: {
rootDocId: '456def',
rootFolder: [
{
_id: 'root-folder-id',
docs: [{ _id: '456def', name: 'main.tex' }],
folders: [],
fileRefs: [],
},
],
},
})
screen.getByRole('button', { name: 'New File' })
screen.getByRole('button', { name: 'New Folder' })
screen.getByRole('button', { name: 'Upload' })
screen.getByRole('button', { name: 'Rename' })
screen.getByRole('button', { name: 'Delete' })
})
})