2020-11-26 09:22:30 -05:00
|
|
|
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'
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('<FileTreeToolbar/>', function () {
|
|
|
|
beforeEach(function () {
|
2021-01-07 09:22:40 -05:00
|
|
|
global.localStorage.clear()
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('without selected files', function () {
|
2020-11-26 09:22:30 -05:00
|
|
|
renderWithContext(<FileTreeToolbar />)
|
|
|
|
|
2020-12-10 06:15:05 -05:00
|
|
|
screen.getByRole('button', { name: 'New File' })
|
|
|
|
screen.getByRole('button', { name: 'New Folder' })
|
|
|
|
screen.getByRole('button', { name: 'Upload' })
|
2020-11-26 09:22:30 -05:00
|
|
|
expect(screen.queryByRole('button', { name: 'Rename' })).to.not.exist
|
|
|
|
expect(screen.queryByRole('button', { name: 'Delete' })).to.not.exist
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('read-only', function () {
|
2020-11-26 09:22:30 -05:00
|
|
|
renderWithContext(<FileTreeToolbar />, {
|
2021-04-27 03:52:58 -04:00
|
|
|
contextProps: { hasWritePermissions: false },
|
2020-11-26 09:22:30 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
expect(screen.queryByRole('button')).to.not.exist
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
it('with one selected file', function () {
|
2020-11-26 09:22:30 -05:00
|
|
|
renderWithContext(<FileTreeToolbar />, {
|
2021-01-08 05:03:10 -05:00
|
|
|
contextProps: {
|
|
|
|
rootDocId: '456def',
|
|
|
|
rootFolder: [
|
|
|
|
{
|
|
|
|
_id: 'root-folder-id',
|
|
|
|
docs: [{ _id: '456def', name: 'main.tex' }],
|
|
|
|
folders: [],
|
2021-04-27 03:52:58 -04:00
|
|
|
fileRefs: [],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2020-11-26 09:22:30 -05:00
|
|
|
})
|
|
|
|
|
2020-12-10 06:15:05 -05:00
|
|
|
screen.getByRole('button', { name: 'New File' })
|
|
|
|
screen.getByRole('button', { name: 'New Folder' })
|
|
|
|
screen.getByRole('button', { name: 'Upload' })
|
2020-11-26 09:22:30 -05:00
|
|
|
screen.getByRole('button', { name: 'Rename' })
|
|
|
|
screen.getByRole('button', { name: 'Delete' })
|
|
|
|
})
|
|
|
|
})
|