[misc] run format_fix and lint:fix

This commit is contained in:
Jakob Ackermann
2021-07-13 12:04:48 +01:00
parent 679ea1616c
commit 540b52c128
23 changed files with 394 additions and 387 deletions
@@ -21,21 +21,21 @@ const { ObjectId } = require('mongodb')
describe('HttpController', function () {
beforeEach(function () {
const settings = {
max_doc_length: 2 * 1024 * 1024
max_doc_length: 2 * 1024 * 1024,
}
this.HttpController = SandboxedModule.require(modulePath, {
requires: {
'./DocManager': (this.DocManager = {}),
'./DocArchiveManager': (this.DocArchiveManager = {}),
'@overleaf/settings': settings,
'./HealthChecker': {}
}
'./HealthChecker': {},
},
})
this.res = {
send: sinon.stub(),
sendStatus: sinon.stub(),
json: sinon.stub(),
setHeader: sinon.stub()
setHeader: sinon.stub(),
}
this.res.status = sinon.stub().returns(this.res)
this.req = { query: {} }
@@ -46,14 +46,14 @@ describe('HttpController', function () {
_id: this.doc_id,
lines: ['mock', 'lines', ' here', '', '', ' spaces '],
version: 42,
rev: 5
rev: 5,
}
return (this.deletedDoc = {
deleted: true,
_id: this.doc_id,
lines: ['mock', 'lines', ' here', '', '', ' spaces '],
version: 42,
rev: 5
rev: 5,
})
})
@@ -62,7 +62,7 @@ describe('HttpController', function () {
beforeEach(function () {
this.req.params = {
project_id: this.project_id,
doc_id: this.doc_id
doc_id: this.doc_id,
}
this.DocManager.getFullDoc = sinon
.stub()
@@ -82,7 +82,7 @@ describe('HttpController', function () {
_id: this.doc_id,
lines: this.doc.lines,
rev: this.doc.rev,
version: this.doc.version
version: this.doc.version,
})
.should.equal(true)
})
@@ -92,7 +92,7 @@ describe('HttpController', function () {
beforeEach(function () {
this.req.params = {
project_id: this.project_id,
doc_id: this.doc_id
doc_id: this.doc_id,
}
return (this.DocManager.getFullDoc = sinon
.stub()
@@ -120,7 +120,7 @@ describe('HttpController', function () {
lines: this.doc.lines,
rev: this.doc.rev,
deleted: true,
version: this.doc.version
version: this.doc.version,
})
.should.equal(true)
})
@@ -131,7 +131,7 @@ describe('HttpController', function () {
beforeEach(function () {
this.req.params = {
project_id: this.project_id,
doc_id: this.doc_id
doc_id: this.doc_id,
}
this.DocManager.getDocLines = sinon.stub().callsArgWith(2, null, this.doc)
return this.HttpController.getRawDoc(this.req, this.res, this.next)
@@ -165,13 +165,13 @@ describe('HttpController', function () {
{
_id: ObjectId(),
lines: ['mock', 'lines', 'one'],
rev: 2
rev: 2,
},
{
_id: ObjectId(),
lines: ['mock', 'lines', 'two'],
rev: 4
}
rev: 4,
},
]
this.DocManager.getAllNonDeletedDocs = sinon
.stub()
@@ -191,13 +191,13 @@ describe('HttpController', function () {
{
_id: this.docs[0]._id.toString(),
lines: this.docs[0].lines,
rev: this.docs[0].rev
rev: this.docs[0].rev,
},
{
_id: this.docs[1]._id.toString(),
lines: this.docs[1].lines,
rev: this.docs[1].rev
}
rev: this.docs[1].rev,
},
])
.should.equal(true)
})
@@ -210,14 +210,14 @@ describe('HttpController', function () {
{
_id: ObjectId(),
lines: ['mock', 'lines', 'one'],
rev: 2
rev: 2,
},
null,
{
_id: ObjectId(),
lines: ['mock', 'lines', 'two'],
rev: 4
}
rev: 4,
},
]
this.DocManager.getAllNonDeletedDocs = sinon
.stub()
@@ -231,13 +231,13 @@ describe('HttpController', function () {
{
_id: this.docs[0]._id.toString(),
lines: this.docs[0].lines,
rev: this.docs[0].rev
rev: this.docs[0].rev,
},
{
_id: this.docs[2]._id.toString(),
lines: this.docs[2].lines,
rev: this.docs[2].rev
}
rev: this.docs[2].rev,
},
])
.should.equal(true)
})
@@ -247,7 +247,7 @@ describe('HttpController', function () {
.calledWith(
{
err: sinon.match.has('message', 'null doc'),
project_id: this.project_id
project_id: this.project_id,
},
'encountered null doc'
)
@@ -263,12 +263,12 @@ describe('HttpController', function () {
this.docs = [
{
_id: ObjectId(),
ranges: { mock_ranges: 'one' }
ranges: { mock_ranges: 'one' },
},
{
_id: ObjectId(),
ranges: { mock_ranges: 'two' }
}
ranges: { mock_ranges: 'two' },
},
]
this.DocManager.getAllNonDeletedDocs = sinon
.stub()
@@ -287,12 +287,12 @@ describe('HttpController', function () {
.calledWith([
{
_id: this.docs[0]._id.toString(),
ranges: this.docs[0].ranges
ranges: this.docs[0].ranges,
},
{
_id: this.docs[1]._id.toString(),
ranges: this.docs[1].ranges
}
ranges: this.docs[1].ranges,
},
])
.should.equal(true)
})
@@ -303,7 +303,7 @@ describe('HttpController', function () {
beforeEach(function () {
return (this.req.params = {
project_id: this.project_id,
doc_id: this.doc_id
doc_id: this.doc_id,
})
})
@@ -312,7 +312,7 @@ describe('HttpController', function () {
this.req.body = {
lines: (this.lines = ['hello', 'world']),
version: (this.version = 42),
ranges: (this.ranges = { changes: 'mock' })
ranges: (this.ranges = { changes: 'mock' }),
}
this.DocManager.updateDoc = sinon
.stub()
@@ -344,7 +344,7 @@ describe('HttpController', function () {
this.req.body = {
lines: (this.lines = ['hello', 'world']),
version: (this.version = 42),
ranges: {}
ranges: {},
}
this.DocManager.updateDoc = sinon
.stub()
@@ -412,7 +412,7 @@ describe('HttpController', function () {
this.req.body = {
lines: (this.lines = Array(2049).fill('a'.repeat(1024))),
version: (this.version = 42),
ranges: (this.ranges = { changes: 'mock' })
ranges: (this.ranges = { changes: 'mock' }),
}
return this.HttpController.updateDoc(this.req, this.res, this.next)
})
@@ -431,7 +431,7 @@ describe('HttpController', function () {
beforeEach(function () {
this.req.params = {
project_id: this.project_id,
doc_id: this.doc_id
doc_id: this.doc_id,
}
this.req.body = { name: 'foo.tex' }
this.DocManager.patchDoc = sinon.stub().yields(null)