mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-05 07:09:02 +02:00
Merge pull request #3495 from overleaf/ae-prettier-2
Upgrade Prettier to v2 GitOrigin-RevId: 85aa3fa1acb6332c4f58c46165a43d1a51471f33
This commit is contained in:
@@ -14,8 +14,8 @@ const sinon = require('sinon')
|
||||
const modulePath = '../../../../app/src/Features/Metadata/MetaController'
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
|
||||
describe('MetaController', function() {
|
||||
beforeEach(function() {
|
||||
describe('MetaController', function () {
|
||||
beforeEach(function () {
|
||||
this.projectId = 'somekindofid'
|
||||
this.EditorRealTimeController = {
|
||||
emitToRoom: sinon.stub()
|
||||
@@ -32,8 +32,8 @@ describe('MetaController', function() {
|
||||
}))
|
||||
})
|
||||
|
||||
describe('getMetadata', function() {
|
||||
beforeEach(function() {
|
||||
describe('getMetadata', function () {
|
||||
beforeEach(function () {
|
||||
this.fakeLabels = { somedoc: ['a_label'] }
|
||||
this.MetaHandler.getAllMetaForProject = sinon
|
||||
.stub()
|
||||
@@ -43,7 +43,7 @@ describe('MetaController', function() {
|
||||
return (this.next = sinon.stub())
|
||||
})
|
||||
|
||||
it('should call MetaHandler.getAllMetaForProject', function() {
|
||||
it('should call MetaHandler.getAllMetaForProject', function () {
|
||||
this.MetadataController.getMetadata(this.req, this.res, this.next)
|
||||
this.MetaHandler.getAllMetaForProject.callCount.should.equal(1)
|
||||
return this.MetaHandler.getAllMetaForProject
|
||||
@@ -51,12 +51,12 @@ describe('MetaController', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should call not call next with an error', function() {
|
||||
it('should call not call next with an error', function () {
|
||||
this.MetadataController.getMetadata(this.req, this.res, this.next)
|
||||
return this.next.callCount.should.equal(0)
|
||||
})
|
||||
|
||||
it('should send a json response', function() {
|
||||
it('should send a json response', function () {
|
||||
this.MetadataController.getMetadata(this.req, this.res, this.next)
|
||||
this.res.json.callCount.should.equal(1)
|
||||
return expect(this.res.json.lastCall.args[0]).to.have.all.keys([
|
||||
@@ -65,8 +65,8 @@ describe('MetaController', function() {
|
||||
])
|
||||
})
|
||||
|
||||
describe('when MetaHandler.getAllMetaForProject produces an error', function() {
|
||||
beforeEach(function() {
|
||||
describe('when MetaHandler.getAllMetaForProject produces an error', function () {
|
||||
beforeEach(function () {
|
||||
this.MetaHandler.getAllMetaForProject = sinon
|
||||
.stub()
|
||||
.callsArgWith(1, new Error('woops'))
|
||||
@@ -75,7 +75,7 @@ describe('MetaController', function() {
|
||||
return (this.next = sinon.stub())
|
||||
})
|
||||
|
||||
it('should call MetaHandler.getAllMetaForProject', function() {
|
||||
it('should call MetaHandler.getAllMetaForProject', function () {
|
||||
this.MetadataController.getMetadata(this.req, this.res, this.next)
|
||||
this.MetaHandler.getAllMetaForProject.callCount.should.equal(1)
|
||||
return this.MetaHandler.getAllMetaForProject
|
||||
@@ -83,21 +83,21 @@ describe('MetaController', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should call next with an error', function() {
|
||||
it('should call next with an error', function () {
|
||||
this.MetadataController.getMetadata(this.req, this.res, this.next)
|
||||
this.next.callCount.should.equal(1)
|
||||
return expect(this.next.lastCall.args[0]).to.be.instanceof(Error)
|
||||
})
|
||||
|
||||
it('should not send a json response', function() {
|
||||
it('should not send a json response', function () {
|
||||
this.MetadataController.getMetadata(this.req, this.res, this.next)
|
||||
return this.res.json.callCount.should.equal(0)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('broadcastMetadataForDoc', function() {
|
||||
beforeEach(function() {
|
||||
describe('broadcastMetadataForDoc', function () {
|
||||
beforeEach(function () {
|
||||
this.MetaHandler.getMetaForDoc = sinon
|
||||
.stub()
|
||||
.callsArgWith(2, null, this.fakeLabels)
|
||||
@@ -107,15 +107,15 @@ describe('MetaController', function() {
|
||||
return (this.next = sinon.stub())
|
||||
})
|
||||
|
||||
describe('with broadcast:true', function() {
|
||||
beforeEach(function() {
|
||||
describe('with broadcast:true', function () {
|
||||
beforeEach(function () {
|
||||
this.req = {
|
||||
params: { project_id: this.projectId, doc_id: this.docId },
|
||||
body: { broadcast: true }
|
||||
}
|
||||
})
|
||||
|
||||
it('should call MetaHandler.getMetaForDoc', function() {
|
||||
it('should call MetaHandler.getMetaForDoc', function () {
|
||||
this.MetadataController.broadcastMetadataForDoc(
|
||||
this.req,
|
||||
this.res,
|
||||
@@ -127,7 +127,7 @@ describe('MetaController', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should call not call next with an error', function() {
|
||||
it('should call not call next with an error', function () {
|
||||
this.MetadataController.broadcastMetadataForDoc(
|
||||
this.req,
|
||||
this.res,
|
||||
@@ -136,7 +136,7 @@ describe('MetaController', function() {
|
||||
return this.next.callCount.should.equal(0)
|
||||
})
|
||||
|
||||
it('should send a success response', function() {
|
||||
it('should send a success response', function () {
|
||||
this.MetadataController.broadcastMetadataForDoc(
|
||||
this.req,
|
||||
this.res,
|
||||
@@ -146,7 +146,7 @@ describe('MetaController', function() {
|
||||
return this.res.sendStatus.calledWith(200).should.equal(true)
|
||||
})
|
||||
|
||||
it('should emit a message to room', function() {
|
||||
it('should emit a message to room', function () {
|
||||
this.MetadataController.broadcastMetadataForDoc(
|
||||
this.req,
|
||||
this.res,
|
||||
@@ -160,15 +160,15 @@ describe('MetaController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('with broadcast:false', function() {
|
||||
beforeEach(function() {
|
||||
describe('with broadcast:false', function () {
|
||||
beforeEach(function () {
|
||||
this.req = {
|
||||
params: { project_id: this.projectId, doc_id: this.docId },
|
||||
body: { broadcast: false }
|
||||
}
|
||||
})
|
||||
|
||||
it('should call MetaHandler.getMetaForDoc', function() {
|
||||
it('should call MetaHandler.getMetaForDoc', function () {
|
||||
this.MetadataController.broadcastMetadataForDoc(
|
||||
this.req,
|
||||
this.res,
|
||||
@@ -180,7 +180,7 @@ describe('MetaController', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should call not call next with an error', function() {
|
||||
it('should call not call next with an error', function () {
|
||||
this.MetadataController.broadcastMetadataForDoc(
|
||||
this.req,
|
||||
this.res,
|
||||
@@ -189,7 +189,7 @@ describe('MetaController', function() {
|
||||
return this.next.callCount.should.equal(0)
|
||||
})
|
||||
|
||||
it('should send the metadata in the response', function() {
|
||||
it('should send the metadata in the response', function () {
|
||||
this.MetadataController.broadcastMetadataForDoc(
|
||||
this.req,
|
||||
this.res,
|
||||
@@ -201,7 +201,7 @@ describe('MetaController', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should not emit a message to room', function() {
|
||||
it('should not emit a message to room', function () {
|
||||
this.MetadataController.broadcastMetadataForDoc(
|
||||
this.req,
|
||||
this.res,
|
||||
@@ -213,8 +213,8 @@ describe('MetaController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when MetaHandler.getMetaForDoc produces an error', function() {
|
||||
beforeEach(function() {
|
||||
describe('when MetaHandler.getMetaForDoc produces an error', function () {
|
||||
beforeEach(function () {
|
||||
this.MetaHandler.getMetaForDoc = sinon
|
||||
.stub()
|
||||
.callsArgWith(2, new Error('woops'))
|
||||
@@ -228,7 +228,7 @@ describe('MetaController', function() {
|
||||
return (this.next = sinon.stub())
|
||||
})
|
||||
|
||||
it('should call MetaHandler.getMetaForDoc', function() {
|
||||
it('should call MetaHandler.getMetaForDoc', function () {
|
||||
this.MetadataController.broadcastMetadataForDoc(
|
||||
this.req,
|
||||
this.res,
|
||||
@@ -240,7 +240,7 @@ describe('MetaController', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should call next with an error', function() {
|
||||
it('should call next with an error', function () {
|
||||
this.MetadataController.broadcastMetadataForDoc(
|
||||
this.req,
|
||||
this.res,
|
||||
@@ -250,7 +250,7 @@ describe('MetaController', function() {
|
||||
return expect(this.next.lastCall.args[0]).to.be.instanceof(Error)
|
||||
})
|
||||
|
||||
it('should not send a json response', function() {
|
||||
it('should not send a json response', function () {
|
||||
this.MetadataController.broadcastMetadataForDoc(
|
||||
this.req,
|
||||
this.res,
|
||||
|
||||
@@ -15,8 +15,8 @@ const sinon = require('sinon')
|
||||
const modulePath = '../../../../app/src/Features/Metadata/MetaHandler'
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
|
||||
describe('MetaHandler', function() {
|
||||
beforeEach(function() {
|
||||
describe('MetaHandler', function () {
|
||||
beforeEach(function () {
|
||||
this.projectId = 'someprojectid'
|
||||
this.docId = 'somedocid'
|
||||
this.ProjectEntityHandler = {
|
||||
@@ -61,8 +61,8 @@ describe('MetaHandler', function() {
|
||||
}))
|
||||
})
|
||||
|
||||
describe('extractMetaFromDoc', function() {
|
||||
beforeEach(function() {
|
||||
describe('extractMetaFromDoc', function () {
|
||||
beforeEach(function () {
|
||||
return (this.lines = [
|
||||
'\\usepackage{foo}',
|
||||
'\\usepackage{amsmath, booktabs}',
|
||||
@@ -75,7 +75,7 @@ describe('MetaHandler', function() {
|
||||
])
|
||||
})
|
||||
|
||||
it('should extract all the labels and packages', function() {
|
||||
it('should extract all the labels and packages', function () {
|
||||
const docMeta = this.MetaHandler.extractMetaFromDoc(this.lines)
|
||||
return expect(docMeta).to.deep.equal({
|
||||
labels: ['aaa', 'bbb'],
|
||||
@@ -99,8 +99,8 @@ describe('MetaHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('extractMetaFromProjectDocs', function() {
|
||||
beforeEach(function() {
|
||||
describe('extractMetaFromProjectDocs', function () {
|
||||
beforeEach(function () {
|
||||
return (this.docs = {
|
||||
doc_one: {
|
||||
_id: 'id_one',
|
||||
@@ -135,7 +135,7 @@ describe('MetaHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should extract all metadata', function() {
|
||||
it('should extract all metadata', function () {
|
||||
const projectMeta = this.MetaHandler.extractMetaFromProjectDocs(this.docs)
|
||||
return expect(projectMeta).to.deep.equal({
|
||||
id_one: { labels: ['aaa'], packages: {} },
|
||||
@@ -185,8 +185,8 @@ describe('MetaHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('getMetaForDoc', function() {
|
||||
beforeEach(function() {
|
||||
describe('getMetaForDoc', function () {
|
||||
beforeEach(function () {
|
||||
this.fakeLines = ['\\usepackage{abc}', 'one', '\\label{aaa}', 'two']
|
||||
this.fakeMeta = { labels: ['aaa'], packages: ['abc'] }
|
||||
this.DocumentUpdaterHandler.flushDocToMongo = sinon
|
||||
@@ -205,21 +205,21 @@ describe('MetaHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should not produce an error', function(done) {
|
||||
it('should not produce an error', function (done) {
|
||||
return this.call((err, docMeta) => {
|
||||
expect(err).to.equal(null)
|
||||
return done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should produce docMeta', function(done) {
|
||||
it('should produce docMeta', function (done) {
|
||||
return this.call((err, docMeta) => {
|
||||
expect(docMeta).to.equal(this.fakeMeta)
|
||||
return done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should call flushDocToMongo', function(done) {
|
||||
it('should call flushDocToMongo', function (done) {
|
||||
return this.call((err, docMeta) => {
|
||||
this.DocumentUpdaterHandler.flushDocToMongo.callCount.should.equal(1)
|
||||
this.DocumentUpdaterHandler.flushDocToMongo
|
||||
@@ -229,7 +229,7 @@ describe('MetaHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should call getDoc', function(done) {
|
||||
it('should call getDoc', function (done) {
|
||||
return this.call((err, docMeta) => {
|
||||
this.ProjectEntityHandler.getDoc.callCount.should.equal(1)
|
||||
this.ProjectEntityHandler.getDoc
|
||||
@@ -239,7 +239,7 @@ describe('MetaHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should call extractMetaFromDoc', function(done) {
|
||||
it('should call extractMetaFromDoc', function (done) {
|
||||
return this.call((err, docMeta) => {
|
||||
this.MetaHandler.extractMetaFromDoc.callCount.should.equal(1)
|
||||
this.MetaHandler.extractMetaFromDoc
|
||||
@@ -250,8 +250,8 @@ describe('MetaHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('getAllMetaForProject', function() {
|
||||
beforeEach(function() {
|
||||
describe('getAllMetaForProject', function () {
|
||||
beforeEach(function () {
|
||||
this.fakeDocs = {
|
||||
doc_one: {
|
||||
lines: ['\\usepackage[some-options,more=foo]{foo}', '\\label{aaa}']
|
||||
@@ -291,21 +291,21 @@ describe('MetaHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should not produce an error', function(done) {
|
||||
it('should not produce an error', function (done) {
|
||||
return this.call((err, projectMeta) => {
|
||||
expect(err).to.equal(null)
|
||||
return done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should produce projectMeta', function(done) {
|
||||
it('should produce projectMeta', function (done) {
|
||||
return this.call((err, projectMeta) => {
|
||||
expect(projectMeta).to.equal(this.fakeMeta)
|
||||
return done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should call getAllDocs', function(done) {
|
||||
it('should call getAllDocs', function (done) {
|
||||
return this.call((err, projectMeta) => {
|
||||
this.ProjectEntityHandler.getAllDocs.callCount.should.equal(1)
|
||||
this.ProjectEntityHandler.getAllDocs
|
||||
@@ -315,7 +315,7 @@ describe('MetaHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should call extractMetaFromDoc', function(done) {
|
||||
it('should call extractMetaFromDoc', function (done) {
|
||||
return this.call((err, docMeta) => {
|
||||
this.MetaHandler.extractMetaFromProjectDocs.callCount.should.equal(1)
|
||||
this.MetaHandler.extractMetaFromProjectDocs
|
||||
|
||||
Reference in New Issue
Block a user