overleaf/services/web/test/frontend/features/file-tree/components/file-tree-toolbar.test.js
Timothée Alby 2ca6d2dadb Merge pull request #3430 from overleaf/msm-filetree-open-selected-entity
[ReactFileTree] Use Local Storage for Open/Closed state of folders and selected doc

GitOrigin-RevId: 55073c92fef6c6e1d538a42b22d60d8657b92153
2021-01-08 03:05:18 +00:00

42 lines
1.4 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() {
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: '123abc' }
})
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' })
})
})