mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-31 04:41:32 +02:00
Merge pull request #3495 from overleaf/ae-prettier-2
Upgrade Prettier to v2 GitOrigin-RevId: 85aa3fa1acb6332c4f58c46165a43d1a51471f33
This commit is contained in:
@@ -38,8 +38,8 @@ const rootFolder = {
|
||||
project.rootFolder[0] = rootFolder
|
||||
project.rootDoc_id = rootDoc._id
|
||||
|
||||
describe('ProjectLocator', function() {
|
||||
beforeEach(function() {
|
||||
describe('ProjectLocator', function () {
|
||||
beforeEach(function () {
|
||||
Project.findById = (projectId, callback) => {
|
||||
callback(null, project)
|
||||
}
|
||||
@@ -61,8 +61,8 @@ describe('ProjectLocator', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('finding a doc', function() {
|
||||
it('finds one at the root level', function(done) {
|
||||
describe('finding a doc', function () {
|
||||
it('finds one at the root level', function (done) {
|
||||
this.locator.findElement(
|
||||
{ project_id: project._id, element_id: doc2._id, type: 'docs' },
|
||||
(err, foundElement, path, parentFolder) => {
|
||||
@@ -78,7 +78,7 @@ describe('ProjectLocator', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('when it is nested', function(done) {
|
||||
it('when it is nested', function (done) {
|
||||
this.locator.findElement(
|
||||
{ project_id: project._id, element_id: subSubDoc._id, type: 'doc' },
|
||||
(err, foundElement, path, parentFolder) => {
|
||||
@@ -96,7 +96,7 @@ describe('ProjectLocator', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should give error if element could not be found', function(done) {
|
||||
it('should give error if element could not be found', function (done) {
|
||||
this.locator.findElement(
|
||||
{ project_id: project._id, element_id: 'ddsd432nj42', type: 'docs' },
|
||||
(err, foundElement, path, parentFolder) => {
|
||||
@@ -108,8 +108,8 @@ describe('ProjectLocator', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('finding a folder', function() {
|
||||
it('should return root folder when looking for root folder', function(done) {
|
||||
describe('finding a folder', function () {
|
||||
it('should return root folder when looking for root folder', function (done) {
|
||||
this.locator.findElement(
|
||||
{ project_id: project._id, element_id: rootFolder._id, type: 'folder' },
|
||||
(err, foundElement, path, parentFolder) => {
|
||||
@@ -122,7 +122,7 @@ describe('ProjectLocator', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('when at root', function(done) {
|
||||
it('when at root', function (done) {
|
||||
this.locator.findElement(
|
||||
{ project_id: project._id, element_id: subFolder._id, type: 'folder' },
|
||||
(err, foundElement, path, parentFolder) => {
|
||||
@@ -138,7 +138,7 @@ describe('ProjectLocator', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('when deeply nested', function(done) {
|
||||
it('when deeply nested', function (done) {
|
||||
this.locator.findElement(
|
||||
{
|
||||
project_id: project._id,
|
||||
@@ -161,8 +161,8 @@ describe('ProjectLocator', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('finding a file', function() {
|
||||
it('when at root', function(done) {
|
||||
describe('finding a file', function () {
|
||||
it('when at root', function (done) {
|
||||
this.locator.findElement(
|
||||
{ project_id: project._id, element_id: file1._id, type: 'fileRefs' },
|
||||
(err, foundElement, path, parentFolder) => {
|
||||
@@ -178,7 +178,7 @@ describe('ProjectLocator', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('when deeply nested', function(done) {
|
||||
it('when deeply nested', function (done) {
|
||||
this.locator.findElement(
|
||||
{
|
||||
project_id: project._id,
|
||||
@@ -201,8 +201,8 @@ describe('ProjectLocator', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('finding an element with wrong element type', function() {
|
||||
it('should add an s onto the element type', function(done) {
|
||||
describe('finding an element with wrong element type', function () {
|
||||
it('should add an s onto the element type', function (done) {
|
||||
this.locator.findElement(
|
||||
{ project_id: project._id, element_id: subSubDoc._id, type: 'doc' },
|
||||
(err, foundElement, path, parentFolder) => {
|
||||
@@ -215,7 +215,7 @@ describe('ProjectLocator', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should convert file to fileRefs', function(done) {
|
||||
it('should convert file to fileRefs', function (done) {
|
||||
this.locator.findElement(
|
||||
{ project_id: project._id, element_id: file1._id, type: 'fileRefs' },
|
||||
(err, foundElement, path, parentFolder) => {
|
||||
@@ -229,7 +229,7 @@ describe('ProjectLocator', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('should be able to take actual project as well as id', function() {
|
||||
describe('should be able to take actual project as well as id', function () {
|
||||
const doc3 = {
|
||||
_id: '123dsdj3',
|
||||
name: 'doc3'
|
||||
@@ -242,7 +242,7 @@ describe('ProjectLocator', function() {
|
||||
_id: '1234566',
|
||||
rootFolder: [rootFolder2]
|
||||
}
|
||||
it('should find doc in project', function(done) {
|
||||
it('should find doc in project', function (done) {
|
||||
this.locator.findElement(
|
||||
{ project: project2, element_id: doc3._id, type: 'docs' },
|
||||
(err, foundElement, path, parentFolder) => {
|
||||
@@ -259,8 +259,8 @@ describe('ProjectLocator', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('finding root doc', function() {
|
||||
it('should return root doc when passed project', function(done) {
|
||||
describe('finding root doc', function () {
|
||||
it('should return root doc when passed project', function (done) {
|
||||
this.locator.findRootDoc(project, (err, doc) => {
|
||||
if (err != null) {
|
||||
return done(err)
|
||||
@@ -270,7 +270,7 @@ describe('ProjectLocator', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should return root doc when passed project_id', function(done) {
|
||||
it('should return root doc when passed project_id', function (done) {
|
||||
this.locator.findRootDoc(project._id, (err, doc) => {
|
||||
if (err != null) {
|
||||
return done(err)
|
||||
@@ -280,7 +280,7 @@ describe('ProjectLocator', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should return null when the project has no rootDoc', function(done) {
|
||||
it('should return null when the project has no rootDoc', function (done) {
|
||||
project.rootDoc_id = null
|
||||
this.locator.findRootDoc(project, (err, doc) => {
|
||||
if (err != null) {
|
||||
@@ -291,7 +291,7 @@ describe('ProjectLocator', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should return null when the rootDoc_id no longer exists', function(done) {
|
||||
it('should return null when the rootDoc_id no longer exists', function (done) {
|
||||
project.rootDoc_id = 'doesntexist'
|
||||
this.locator.findRootDoc(project, (err, doc) => {
|
||||
if (err != null) {
|
||||
@@ -303,8 +303,8 @@ describe('ProjectLocator', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('findElementByPath', function() {
|
||||
it('should take a doc path and return the element for a root level document', function(done) {
|
||||
describe('findElementByPath', function () {
|
||||
it('should take a doc path and return the element for a root level document', function (done) {
|
||||
const path = `${doc1.name}`
|
||||
this.locator.findElementByPath(
|
||||
{ project, path },
|
||||
@@ -319,7 +319,7 @@ describe('ProjectLocator', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should take a doc path and return the element for a root level document with a starting slash', function(done) {
|
||||
it('should take a doc path and return the element for a root level document with a starting slash', function (done) {
|
||||
const path = `/${doc1.name}`
|
||||
this.locator.findElementByPath(
|
||||
{ project, path },
|
||||
@@ -334,7 +334,7 @@ describe('ProjectLocator', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should take a doc path and return the element for a nested document', function(done) {
|
||||
it('should take a doc path and return the element for a nested document', function (done) {
|
||||
const path = `${subFolder.name}/${secondSubFolder.name}/${subSubDoc.name}`
|
||||
this.locator.findElementByPath(
|
||||
{ project, path },
|
||||
@@ -349,7 +349,7 @@ describe('ProjectLocator', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should take a file path and return the element for a root level document', function(done) {
|
||||
it('should take a file path and return the element for a root level document', function (done) {
|
||||
const path = `${file1.name}`
|
||||
this.locator.findElementByPath(
|
||||
{ project, path },
|
||||
@@ -364,7 +364,7 @@ describe('ProjectLocator', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should take a file path and return the element for a nested document', function(done) {
|
||||
it('should take a file path and return the element for a nested document', function (done) {
|
||||
const path = `${subFolder.name}/${secondSubFolder.name}/${subSubFile.name}`
|
||||
this.locator.findElementByPath(
|
||||
{ project, path },
|
||||
@@ -379,7 +379,7 @@ describe('ProjectLocator', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should take a file path and return the element for a nested document case insenstive', function(done) {
|
||||
it('should take a file path and return the element for a nested document case insenstive', function (done) {
|
||||
const path = `${subFolder.name.toUpperCase()}/${secondSubFolder.name.toUpperCase()}/${subSubFile.name.toUpperCase()}`
|
||||
this.locator.findElementByPath(
|
||||
{ project, path },
|
||||
@@ -394,7 +394,7 @@ describe('ProjectLocator', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should take a file path and return the element for a nested folder', function(done) {
|
||||
it('should take a file path and return the element for a nested folder', function (done) {
|
||||
const path = `${subFolder.name}/${secondSubFolder.name}`
|
||||
this.locator.findElementByPath(
|
||||
{ project, path },
|
||||
@@ -409,7 +409,7 @@ describe('ProjectLocator', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should take a file path and return the root folder', function(done) {
|
||||
it('should take a file path and return the root folder', function (done) {
|
||||
const path = '/'
|
||||
this.locator.findElementByPath(
|
||||
{ project, path },
|
||||
@@ -424,7 +424,7 @@ describe('ProjectLocator', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should return an error if the file can not be found inside know folder', function(done) {
|
||||
it('should return an error if the file can not be found inside know folder', function (done) {
|
||||
const path = `${subFolder.name}/${secondSubFolder.name}/exist.txt`
|
||||
this.locator.findElementByPath(
|
||||
{ project, path },
|
||||
@@ -437,7 +437,7 @@ describe('ProjectLocator', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should return an error if the file can not be found inside unknown folder', function(done) {
|
||||
it('should return an error if the file can not be found inside unknown folder', function (done) {
|
||||
const path = 'this/does/not/exist.txt'
|
||||
this.locator.findElementByPath(
|
||||
{ project, path },
|
||||
@@ -450,8 +450,8 @@ describe('ProjectLocator', function() {
|
||||
)
|
||||
})
|
||||
|
||||
describe('where duplicate folder exists', function() {
|
||||
beforeEach(function() {
|
||||
describe('where duplicate folder exists', function () {
|
||||
beforeEach(function () {
|
||||
this.duplicateFolder = {
|
||||
name: 'duplicate1',
|
||||
_id: '1234',
|
||||
@@ -477,14 +477,14 @@ describe('ProjectLocator', function() {
|
||||
}
|
||||
})
|
||||
|
||||
it('should not call the callback more than once', function(done) {
|
||||
it('should not call the callback more than once', function (done) {
|
||||
const path = `${this.duplicateFolder.name}/${this.doc.name}`
|
||||
this.locator.findElementByPath({ project: this.project, path }, () =>
|
||||
done()
|
||||
)
|
||||
}) // mocha will throw exception if done called multiple times
|
||||
|
||||
it('should not call the callback more than once when the path is longer than 1 level below the duplicate level', function(done) {
|
||||
it('should not call the callback more than once when the path is longer than 1 level below the duplicate level', function (done) {
|
||||
const path = `${this.duplicateFolder.name}/1/main.tex`
|
||||
this.locator.findElementByPath({ project: this.project, path }, () =>
|
||||
done()
|
||||
@@ -492,8 +492,8 @@ describe('ProjectLocator', function() {
|
||||
})
|
||||
}) // mocha will throw exception if done called multiple times
|
||||
|
||||
describe('with a null doc', function() {
|
||||
beforeEach(function() {
|
||||
describe('with a null doc', function () {
|
||||
beforeEach(function () {
|
||||
this.project = {
|
||||
rootFolder: [
|
||||
{
|
||||
@@ -505,7 +505,7 @@ describe('ProjectLocator', function() {
|
||||
}
|
||||
})
|
||||
|
||||
it('should not crash with a null', function(done) {
|
||||
it('should not crash with a null', function (done) {
|
||||
const path = '/other.tex'
|
||||
this.locator.findElementByPath(
|
||||
{ project: this.project, path },
|
||||
@@ -520,12 +520,12 @@ describe('ProjectLocator', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('with a null project', function() {
|
||||
beforeEach(function() {
|
||||
describe('with a null project', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectGetter = { getProject: sinon.stub().callsArg(2) }
|
||||
})
|
||||
|
||||
it('should not crash with a null', function(done) {
|
||||
it('should not crash with a null', function (done) {
|
||||
const path = '/other.tex'
|
||||
this.locator.findElementByPath(
|
||||
{ project_id: project._id, path },
|
||||
@@ -537,8 +537,8 @@ describe('ProjectLocator', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('with a project_id', function() {
|
||||
it('should take a doc path and return the element for a root level document', function(done) {
|
||||
describe('with a project_id', function () {
|
||||
it('should take a doc path and return the element for a root level document', function (done) {
|
||||
const path = `${doc1.name}`
|
||||
this.locator.findElementByPath(
|
||||
{ project_id: project._id, path },
|
||||
|
||||
Reference in New Issue
Block a user