Merge pull request #3495 from overleaf/ae-prettier-2
Upgrade Prettier to v2 GitOrigin-RevId: 85aa3fa1acb6332c4f58c46165a43d1a51471f33
This commit is contained in:
+7
-7
@@ -9,19 +9,19 @@ import FileTreeCreateNameInput from '../../../../../../frontend/js/features/file
|
||||
import FileTreeContext from '../../../../../../frontend/js/features/file-tree/components/file-tree-context'
|
||||
import FileTreeCreateNameProvider from '../../../../../../frontend/js/features/file-tree/contexts/file-tree-create-name'
|
||||
|
||||
describe('<FileTreeCreateNameInput/>', function() {
|
||||
describe('<FileTreeCreateNameInput/>', function () {
|
||||
const sandbox = sinon.createSandbox()
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
sandbox.spy(window, 'requestAnimationFrame')
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
sandbox.restore()
|
||||
cleanup()
|
||||
})
|
||||
|
||||
it('renders an empty input', async function() {
|
||||
it('renders an empty input', async function () {
|
||||
render(
|
||||
<FileTreeContext {...contextProps}>
|
||||
<FileTreeCreateNameProvider>
|
||||
@@ -34,7 +34,7 @@ describe('<FileTreeCreateNameInput/>', function() {
|
||||
await screen.getByPlaceholderText('File Name')
|
||||
})
|
||||
|
||||
it('renders a custom label and placeholder', async function() {
|
||||
it('renders a custom label and placeholder', async function () {
|
||||
render(
|
||||
<FileTreeContext {...contextProps}>
|
||||
<FileTreeCreateNameProvider>
|
||||
@@ -50,7 +50,7 @@ describe('<FileTreeCreateNameInput/>', function() {
|
||||
await screen.getByPlaceholderText('Enter a file name…')
|
||||
})
|
||||
|
||||
it('uses an initial name', async function() {
|
||||
it('uses an initial name', async function () {
|
||||
render(
|
||||
<FileTreeContext {...contextProps}>
|
||||
<FileTreeCreateNameProvider initialName="test.tex">
|
||||
@@ -63,7 +63,7 @@ describe('<FileTreeCreateNameInput/>', function() {
|
||||
expect(input.value).to.equal('test.tex')
|
||||
})
|
||||
|
||||
it('focuses the name', async function() {
|
||||
it('focuses the name', async function () {
|
||||
render(
|
||||
<FileTreeContext {...contextProps}>
|
||||
<FileTreeCreateNameProvider initialName="test.tex">
|
||||
|
||||
+10
-10
@@ -16,13 +16,13 @@ import FileTreeContext from '../../../../../../frontend/js/features/file-tree/co
|
||||
import { useFileTreeActionable } from '../../../../../../frontend/js/features/file-tree/contexts/file-tree-actionable'
|
||||
import { useFileTreeMutable } from '../../../../../../frontend/js/features/file-tree/contexts/file-tree-mutable'
|
||||
|
||||
describe('<FileTreeModalCreateFile/>', function() {
|
||||
afterEach(function() {
|
||||
describe('<FileTreeModalCreateFile/>', function () {
|
||||
afterEach(function () {
|
||||
fetchMock.restore()
|
||||
cleanup()
|
||||
})
|
||||
|
||||
it('handles invalid file names', async function() {
|
||||
it('handles invalid file names', async function () {
|
||||
render(
|
||||
<FileTreeContext {...contextProps}>
|
||||
<OpenWithMode mode="doc" />
|
||||
@@ -56,7 +56,7 @@ describe('<FileTreeModalCreateFile/>', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('displays an error when the file limit is reached', async function() {
|
||||
it('displays an error when the file limit is reached', async function () {
|
||||
const rootFolder = [
|
||||
{
|
||||
docs: Array.from({ length: 10 }, (_, index) => ({
|
||||
@@ -84,7 +84,7 @@ describe('<FileTreeModalCreateFile/>', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('displays a warning when the file limit is nearly reached', async function() {
|
||||
it('displays a warning when the file limit is nearly reached', async function () {
|
||||
const rootFolder = [
|
||||
{
|
||||
docs: Array.from({ length: 9 }, (_, index) => ({
|
||||
@@ -108,7 +108,7 @@ describe('<FileTreeModalCreateFile/>', function() {
|
||||
screen.getByText(/This project is approaching the file limit \(\d+\/\d+\)/)
|
||||
})
|
||||
|
||||
it('counts files in nested folders', async function() {
|
||||
it('counts files in nested folders', async function () {
|
||||
const rootFolder = [
|
||||
{
|
||||
docs: [{ _id: 'entity-1' }],
|
||||
@@ -150,7 +150,7 @@ describe('<FileTreeModalCreateFile/>', function() {
|
||||
screen.getByText(/This project is approaching the file limit \(\d+\/\d+\)/)
|
||||
})
|
||||
|
||||
it('creates a new file when the form is submitted', async function() {
|
||||
it('creates a new file when the form is submitted', async function () {
|
||||
fetchMock.post('express:/project/:projectId/doc', () => 204)
|
||||
|
||||
render(
|
||||
@@ -173,7 +173,7 @@ describe('<FileTreeModalCreateFile/>', function() {
|
||||
).to.be.true
|
||||
})
|
||||
|
||||
it('imports a new file from a project', async function() {
|
||||
it('imports a new file from a project', async function () {
|
||||
fetchMock
|
||||
.get('path:/user/projects', {
|
||||
projects: [
|
||||
@@ -289,7 +289,7 @@ describe('<FileTreeModalCreateFile/>', function() {
|
||||
).to.be.true
|
||||
})
|
||||
|
||||
it('import from a URL when the form is submitted', async function() {
|
||||
it('import from a URL when the form is submitted', async function () {
|
||||
fetchMock.post('express:/project/:projectId/linked_file', () => 204)
|
||||
|
||||
render(
|
||||
@@ -331,7 +331,7 @@ describe('<FileTreeModalCreateFile/>', function() {
|
||||
})
|
||||
|
||||
// eslint-disable-next-line mocha/no-skipped-tests
|
||||
it.skip('uploads a new file', async function() {
|
||||
it.skip('uploads a new file', async function () {
|
||||
fetchMock.post('express:/project/:projectId/linked_file', () => 204)
|
||||
|
||||
render(
|
||||
|
||||
@@ -5,8 +5,8 @@ import renderWithContext from '../helpers/render-with-context'
|
||||
|
||||
import FileTreeDoc from '../../../../../frontend/js/features/file-tree/components/file-tree-doc'
|
||||
|
||||
describe('<FileTreeDoc/>', function() {
|
||||
it('renders unselected', function() {
|
||||
describe('<FileTreeDoc/>', function () {
|
||||
it('renders unselected', function () {
|
||||
const { container } = renderWithContext(
|
||||
<FileTreeDoc name="foo.tex" id="123abc" isLinkedFile={false} />
|
||||
)
|
||||
@@ -15,7 +15,7 @@ describe('<FileTreeDoc/>', function() {
|
||||
expect(container.querySelector('i.linked-file-highlight')).to.not.exist
|
||||
})
|
||||
|
||||
it('renders selected', function() {
|
||||
it('renders selected', function () {
|
||||
renderWithContext(
|
||||
<FileTreeDoc name="foo.tex" id="123abc" isLinkedFile={false} />,
|
||||
{
|
||||
@@ -42,7 +42,7 @@ describe('<FileTreeDoc/>', function() {
|
||||
screen.getByRole('menuitem', { name: 'Upload' })
|
||||
})
|
||||
|
||||
it('renders as linked file', function() {
|
||||
it('renders as linked file', function () {
|
||||
const { container } = renderWithContext(
|
||||
<FileTreeDoc name="foo.tex" id="123abc" isLinkedFile />
|
||||
)
|
||||
@@ -51,7 +51,7 @@ describe('<FileTreeDoc/>', function() {
|
||||
expect(container.querySelector('i.linked-file-highlight')).to.exist
|
||||
})
|
||||
|
||||
it('selects', function() {
|
||||
it('selects', function () {
|
||||
renderWithContext(<FileTreeDoc name="foo.tex" id="123abc" expanded />, {
|
||||
contextProps: {
|
||||
rootFolder: [
|
||||
@@ -70,7 +70,7 @@ describe('<FileTreeDoc/>', function() {
|
||||
screen.getByRole('treeitem', { selected: true })
|
||||
})
|
||||
|
||||
it('multi-selects', function() {
|
||||
it('multi-selects', function () {
|
||||
renderWithContext(<FileTreeDoc name="foo.tex" id="123abc" expanded />, {
|
||||
contextProps: {
|
||||
rootFolder: [
|
||||
|
||||
+6
-6
@@ -5,15 +5,15 @@ import renderWithContext from '../helpers/render-with-context'
|
||||
|
||||
import FileTreeFolderList from '../../../../../frontend/js/features/file-tree/components/file-tree-folder-list'
|
||||
|
||||
describe('<FileTreeFolderList/>', function() {
|
||||
it('renders empty', function() {
|
||||
describe('<FileTreeFolderList/>', function () {
|
||||
it('renders empty', function () {
|
||||
renderWithContext(<FileTreeFolderList folders={[]} docs={[]} files={[]} />)
|
||||
|
||||
screen.queryByRole('tree')
|
||||
expect(screen.queryByRole('treeitem')).to.not.exist
|
||||
})
|
||||
|
||||
it('renders docs, files and folders', function() {
|
||||
it('renders docs, files and folders', function () {
|
||||
const aFolder = {
|
||||
_id: '456def',
|
||||
name: 'A Folder',
|
||||
@@ -33,8 +33,8 @@ describe('<FileTreeFolderList/>', function() {
|
||||
screen.queryByRole('treeitem', { name: 'file.bib' })
|
||||
})
|
||||
|
||||
describe('selection and multi-selection', function() {
|
||||
it('without write permissions', function() {
|
||||
describe('selection and multi-selection', function () {
|
||||
it('without write permissions', function () {
|
||||
const docs = [
|
||||
{ _id: '1', name: '1.tex' },
|
||||
{ _id: '2', name: '2.tex' }
|
||||
@@ -69,7 +69,7 @@ describe('<FileTreeFolderList/>', function() {
|
||||
screen.getByRole('treeitem', { name: '2.tex', selected: false })
|
||||
})
|
||||
|
||||
it('with write permissions', function() {
|
||||
it('with write permissions', function () {
|
||||
const docs = [
|
||||
{ _id: '1', name: '1.tex' },
|
||||
{ _id: '2', name: '2.tex' },
|
||||
|
||||
@@ -5,12 +5,12 @@ import renderWithContext from '../helpers/render-with-context'
|
||||
|
||||
import FileTreeFolder from '../../../../../frontend/js/features/file-tree/components/file-tree-folder'
|
||||
|
||||
describe('<FileTreeFolder/>', function() {
|
||||
beforeEach(function() {
|
||||
describe('<FileTreeFolder/>', function () {
|
||||
beforeEach(function () {
|
||||
global.localStorage.clear()
|
||||
})
|
||||
|
||||
it('renders unselected', function() {
|
||||
it('renders unselected', function () {
|
||||
renderWithContext(
|
||||
<FileTreeFolder
|
||||
name="foo"
|
||||
@@ -25,7 +25,7 @@ describe('<FileTreeFolder/>', function() {
|
||||
expect(screen.queryByRole('tree')).to.not.exist
|
||||
})
|
||||
|
||||
it('renders selected', function() {
|
||||
it('renders selected', function () {
|
||||
renderWithContext(
|
||||
<FileTreeFolder
|
||||
name="foo"
|
||||
@@ -61,7 +61,7 @@ describe('<FileTreeFolder/>', function() {
|
||||
expect(screen.queryByRole('tree')).to.not.exist
|
||||
})
|
||||
|
||||
it('expands', function() {
|
||||
it('expands', function () {
|
||||
renderWithContext(
|
||||
<FileTreeFolder
|
||||
name="foo"
|
||||
@@ -90,7 +90,7 @@ describe('<FileTreeFolder/>', function() {
|
||||
screen.getByRole('tree')
|
||||
})
|
||||
|
||||
it('saves the expanded state for the next render', function() {
|
||||
it('saves the expanded state for the next render', function () {
|
||||
const { unmount } = renderWithContext(
|
||||
<FileTreeFolder
|
||||
name="foo"
|
||||
|
||||
+11
-11
@@ -6,20 +6,20 @@ import renderWithContext from '../../helpers/render-with-context'
|
||||
|
||||
import FileTreeitemInner from '../../../../../../frontend/js/features/file-tree/components/file-tree-item/file-tree-item-inner'
|
||||
|
||||
describe('<FileTreeitemInner />', function() {
|
||||
describe('<FileTreeitemInner />', function () {
|
||||
const setContextMenuCoords = sinon.stub()
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
global.requestAnimationFrame = sinon.stub()
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
setContextMenuCoords.reset()
|
||||
delete global.requestAnimationFrame
|
||||
})
|
||||
|
||||
describe('menu', function() {
|
||||
it('does not display if file is not selected', function() {
|
||||
describe('menu', function () {
|
||||
it('does not display if file is not selected', function () {
|
||||
renderWithContext(
|
||||
<FileTreeitemInner id="123abc" name="bar.tex" isSelected={false} />,
|
||||
{}
|
||||
@@ -29,8 +29,8 @@ describe('<FileTreeitemInner />', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('context menu', function() {
|
||||
it('does not display without write permissions', function() {
|
||||
describe('context menu', function () {
|
||||
it('does not display without write permissions', function () {
|
||||
renderWithContext(
|
||||
<FileTreeitemInner id="123abc" name="bar.tex" isSelected />,
|
||||
{ contextProps: { hasWritePermissions: false } }
|
||||
@@ -39,7 +39,7 @@ describe('<FileTreeitemInner />', function() {
|
||||
expect(screen.queryByRole('menu', { visible: false })).to.not.exist
|
||||
})
|
||||
|
||||
it('open / close', function() {
|
||||
it('open / close', function () {
|
||||
const { container } = renderWithContext(
|
||||
<FileTreeitemInner id="123abc" name="bar.tex" isSelected />
|
||||
)
|
||||
@@ -56,8 +56,8 @@ describe('<FileTreeitemInner />', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('name', function() {
|
||||
it('renders name', function() {
|
||||
describe('name', function () {
|
||||
it('renders name', function () {
|
||||
renderWithContext(
|
||||
<FileTreeitemInner id="123abc" name="bar.tex" isSelected />
|
||||
)
|
||||
@@ -66,7 +66,7 @@ describe('<FileTreeitemInner />', function() {
|
||||
expect(screen.queryByRole('textbox')).to.not.exist
|
||||
})
|
||||
|
||||
it('starts rename on menu item click', function() {
|
||||
it('starts rename on menu item click', function () {
|
||||
renderWithContext(
|
||||
<FileTreeitemInner id="123abc" name="bar.tex" isSelected />,
|
||||
{
|
||||
|
||||
+4
-4
@@ -5,14 +5,14 @@ import renderWithContext from '../../helpers/render-with-context'
|
||||
|
||||
import FileTreeitemMenu from '../../../../../../frontend/js/features/file-tree/components/file-tree-item/file-tree-item-menu'
|
||||
|
||||
describe('<FileTreeitemMenu />', function() {
|
||||
describe('<FileTreeitemMenu />', function () {
|
||||
const setContextMenuCoords = sinon.stub()
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
setContextMenuCoords.reset()
|
||||
})
|
||||
|
||||
it('renders dropdown', function() {
|
||||
it('renders dropdown', function () {
|
||||
renderWithContext(
|
||||
<FileTreeitemMenu
|
||||
id="123abc"
|
||||
@@ -24,7 +24,7 @@ describe('<FileTreeitemMenu />', function() {
|
||||
screen.getByRole('menu')
|
||||
})
|
||||
|
||||
it('open / close', function() {
|
||||
it('open / close', function () {
|
||||
renderWithContext(
|
||||
<FileTreeitemMenu
|
||||
id="123abc"
|
||||
|
||||
+10
-10
@@ -6,21 +6,21 @@ import renderWithContext from '../../helpers/render-with-context'
|
||||
|
||||
import FileTreeItemName from '../../../../../../frontend/js/features/file-tree/components/file-tree-item/file-tree-item-name'
|
||||
|
||||
describe('<FileTreeItemName />', function() {
|
||||
describe('<FileTreeItemName />', function () {
|
||||
const sandbox = sinon.createSandbox()
|
||||
const setIsDraggable = sinon.stub()
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
sandbox.spy(window, 'requestAnimationFrame')
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
sandbox.restore()
|
||||
setIsDraggable.reset()
|
||||
cleanup()
|
||||
})
|
||||
|
||||
it('renders name as button', function() {
|
||||
it('renders name as button', function () {
|
||||
renderWithContext(
|
||||
<FileTreeItemName
|
||||
name="foo.tex"
|
||||
@@ -33,7 +33,7 @@ describe('<FileTreeItemName />', function() {
|
||||
expect(screen.queryByRole('textbox')).to.not.exist
|
||||
})
|
||||
|
||||
it("doesn't start renaming on unselected component", function() {
|
||||
it("doesn't start renaming on unselected component", function () {
|
||||
renderWithContext(
|
||||
<FileTreeItemName
|
||||
name="foo.tex"
|
||||
@@ -49,7 +49,7 @@ describe('<FileTreeItemName />', function() {
|
||||
expect(screen.queryByRole('textbox')).to.not.exist
|
||||
})
|
||||
|
||||
it('start renaming on double-click', function() {
|
||||
it('start renaming on double-click', function () {
|
||||
renderWithContext(
|
||||
<FileTreeItemName
|
||||
name="foo.tex"
|
||||
@@ -68,7 +68,7 @@ describe('<FileTreeItemName />', function() {
|
||||
expect(setIsDraggable).to.be.calledWith(false)
|
||||
})
|
||||
|
||||
it('cannot start renaming in read-only', function() {
|
||||
it('cannot start renaming in read-only', function () {
|
||||
renderWithContext(
|
||||
<FileTreeItemName
|
||||
name="foo.tex"
|
||||
@@ -88,8 +88,8 @@ describe('<FileTreeItemName />', function() {
|
||||
expect(screen.queryByRole('textbox')).to.not.exist
|
||||
})
|
||||
|
||||
describe('stop renaming', function() {
|
||||
beforeEach(function() {
|
||||
describe('stop renaming', function () {
|
||||
beforeEach(function () {
|
||||
renderWithContext(
|
||||
<FileTreeItemName
|
||||
name="foo.tex"
|
||||
@@ -107,7 +107,7 @@ describe('<FileTreeItemName />', function() {
|
||||
fireEvent.change(input, { target: { value: 'bar.tex' } })
|
||||
})
|
||||
|
||||
it('on Escape', function() {
|
||||
it('on Escape', function () {
|
||||
const input = screen.getByRole('textbox')
|
||||
fireEvent.keyDown(input, { key: 'Escape' })
|
||||
|
||||
|
||||
@@ -6,15 +6,15 @@ import fetchMock from 'fetch-mock'
|
||||
|
||||
import FileTreeRoot from '../../../../../frontend/js/features/file-tree/components/file-tree-root'
|
||||
|
||||
describe('<FileTreeRoot/>', function() {
|
||||
describe('<FileTreeRoot/>', function () {
|
||||
const onSelect = sinon.stub()
|
||||
const onInit = sinon.stub()
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
global.requestAnimationFrame = sinon.stub()
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
delete global.requestAnimationFrame
|
||||
fetchMock.restore()
|
||||
onSelect.reset()
|
||||
@@ -22,7 +22,7 @@ describe('<FileTreeRoot/>', function() {
|
||||
global.localStorage.clear()
|
||||
})
|
||||
|
||||
it('renders', function() {
|
||||
it('renders', function () {
|
||||
const rootFolder = [
|
||||
{
|
||||
_id: 'root-folder-id',
|
||||
@@ -54,7 +54,7 @@ describe('<FileTreeRoot/>', function() {
|
||||
expect(container.querySelector('.disconnected-overlay')).to.not.exist
|
||||
})
|
||||
|
||||
it('renders with invalid selected doc in local storage', async function() {
|
||||
it('renders with invalid selected doc in local storage', async function () {
|
||||
global.localStorage.setItem(
|
||||
'doc.open_id.123abc',
|
||||
JSON.stringify('not-a-valid-id')
|
||||
@@ -94,7 +94,7 @@ describe('<FileTreeRoot/>', function() {
|
||||
await waitFor(() => screen.getByRole('button', { name: 'Cancel' }))
|
||||
})
|
||||
|
||||
it('renders disconnected overlay', function() {
|
||||
it('renders disconnected overlay', function () {
|
||||
const rootFolder = [
|
||||
{
|
||||
_id: 'root-folder-id',
|
||||
@@ -124,7 +124,7 @@ describe('<FileTreeRoot/>', function() {
|
||||
expect(container.querySelector('.disconnected-overlay')).to.exist
|
||||
})
|
||||
|
||||
it('fire onSelect', function() {
|
||||
it('fire onSelect', function () {
|
||||
const rootFolder = [
|
||||
{
|
||||
_id: 'root-folder-id',
|
||||
@@ -177,7 +177,7 @@ describe('<FileTreeRoot/>', function() {
|
||||
])
|
||||
})
|
||||
|
||||
it('listen to editor.openDoc', function() {
|
||||
it('listen to editor.openDoc', function () {
|
||||
const rootFolder = [
|
||||
{
|
||||
_id: 'root-folder-id',
|
||||
|
||||
@@ -5,12 +5,12 @@ import renderWithContext from '../helpers/render-with-context'
|
||||
|
||||
import FileTreeToolbar from '../../../../../frontend/js/features/file-tree/components/file-tree-toolbar'
|
||||
|
||||
describe('<FileTreeToolbar/>', function() {
|
||||
beforeEach(function() {
|
||||
describe('<FileTreeToolbar/>', function () {
|
||||
beforeEach(function () {
|
||||
global.localStorage.clear()
|
||||
})
|
||||
|
||||
it('without selected files', function() {
|
||||
it('without selected files', function () {
|
||||
renderWithContext(<FileTreeToolbar />)
|
||||
|
||||
screen.getByRole('button', { name: 'New File' })
|
||||
@@ -20,7 +20,7 @@ describe('<FileTreeToolbar/>', function() {
|
||||
expect(screen.queryByRole('button', { name: 'Delete' })).to.not.exist
|
||||
})
|
||||
|
||||
it('read-only', function() {
|
||||
it('read-only', function () {
|
||||
renderWithContext(<FileTreeToolbar />, {
|
||||
contextProps: { hasWritePermissions: false }
|
||||
})
|
||||
@@ -28,7 +28,7 @@ describe('<FileTreeToolbar/>', function() {
|
||||
expect(screen.queryByRole('button')).to.not.exist
|
||||
})
|
||||
|
||||
it('with one selected file', function() {
|
||||
it('with one selected file', function () {
|
||||
renderWithContext(<FileTreeToolbar />, {
|
||||
contextProps: {
|
||||
rootDocId: '456def',
|
||||
|
||||
Reference in New Issue
Block a user