Merge pull request #3495 from overleaf/ae-prettier-2
Upgrade Prettier to v2 GitOrigin-RevId: 85aa3fa1acb6332c4f58c46165a43d1a51471f33
This commit is contained in:
@@ -6,8 +6,8 @@ const modulePath = require('path').join(
|
||||
'../../../../app/src/Features/ThirdPartyDataStore/TpdsController.js'
|
||||
)
|
||||
|
||||
describe('TpdsController', function() {
|
||||
beforeEach(function() {
|
||||
describe('TpdsController', function () {
|
||||
beforeEach(function () {
|
||||
this.TpdsUpdateHandler = {}
|
||||
this.AuthenticationController = {
|
||||
getLoggedInUserId: sinon.stub().returns('user-id')
|
||||
@@ -36,8 +36,8 @@ describe('TpdsController', function() {
|
||||
this.user_id = 'dsad29jlkjas'
|
||||
})
|
||||
|
||||
describe('getting an update', function() {
|
||||
it('should process the update with the update receiver', function(done) {
|
||||
describe('getting an update', function () {
|
||||
it('should process the update with the update receiver', function (done) {
|
||||
const path = '/projectName/here.txt'
|
||||
const req = {
|
||||
pause() {},
|
||||
@@ -67,7 +67,7 @@ describe('TpdsController', function() {
|
||||
this.TpdsController.mergeUpdate(req, res)
|
||||
})
|
||||
|
||||
it('should return a 500 error when the update receiver fails', function() {
|
||||
it('should return a 500 error when the update receiver fails', function () {
|
||||
const path = '/projectName/here.txt'
|
||||
const req = {
|
||||
pause() {},
|
||||
@@ -89,7 +89,7 @@ describe('TpdsController', function() {
|
||||
res.sendStatus.calledWith(500).should.equal(true)
|
||||
})
|
||||
|
||||
it('should return a 400 error when the project is too big', function() {
|
||||
it('should return a 400 error when the project is too big', function () {
|
||||
const path = '/projectName/here.txt'
|
||||
const req = {
|
||||
pause() {},
|
||||
@@ -114,7 +114,7 @@ describe('TpdsController', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should return a 429 error when the update receiver fails due to too many requests error', function() {
|
||||
it('should return a 429 error when the update receiver fails due to too many requests error', function () {
|
||||
const path = '/projectName/here.txt'
|
||||
const req = {
|
||||
pause() {},
|
||||
@@ -137,8 +137,8 @@ describe('TpdsController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('getting a delete update', function() {
|
||||
it('should process the delete with the update receiver', function(done) {
|
||||
describe('getting a delete update', function () {
|
||||
it('should process the delete with the update receiver', function (done) {
|
||||
const path = '/projectName/here.txt'
|
||||
const req = {
|
||||
params: { 0: path, user_id: this.user_id },
|
||||
@@ -162,8 +162,8 @@ describe('TpdsController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('parseParams', function() {
|
||||
it('should take the project name off the start and replace with slash', function() {
|
||||
describe('parseParams', function () {
|
||||
it('should take the project name off the start and replace with slash', function () {
|
||||
const path = 'noSlashHere'
|
||||
const req = { params: { 0: path, user_id: this.user_id } }
|
||||
const result = this.TpdsController.parseParams(req)
|
||||
@@ -172,7 +172,7 @@ describe('TpdsController', function() {
|
||||
result.projectName.should.equal(path)
|
||||
})
|
||||
|
||||
it('should take the project name off the start and it with no slashes in', function() {
|
||||
it('should take the project name off the start and it with no slashes in', function () {
|
||||
const path = '/project/file.tex'
|
||||
const req = { params: { 0: path, user_id: this.user_id } }
|
||||
const result = this.TpdsController.parseParams(req)
|
||||
@@ -181,7 +181,7 @@ describe('TpdsController', function() {
|
||||
result.projectName.should.equal('project')
|
||||
})
|
||||
|
||||
it('should take the project name of and return a slash for the file path', function() {
|
||||
it('should take the project name of and return a slash for the file path', function () {
|
||||
const path = '/project_name'
|
||||
const req = { params: { 0: path, user_id: this.user_id } }
|
||||
const result = this.TpdsController.parseParams(req)
|
||||
@@ -190,8 +190,8 @@ describe('TpdsController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('updateProjectContents', function() {
|
||||
beforeEach(function() {
|
||||
describe('updateProjectContents', function () {
|
||||
beforeEach(function () {
|
||||
this.UpdateMerger.mergeUpdate = sinon.stub().callsArg(5)
|
||||
this.req = {
|
||||
params: {
|
||||
@@ -210,7 +210,7 @@ describe('TpdsController', function() {
|
||||
this.TpdsController.updateProjectContents(this.req, this.res, this.next)
|
||||
})
|
||||
|
||||
it('should merge the update', function() {
|
||||
it('should merge the update', function () {
|
||||
this.UpdateMerger.mergeUpdate
|
||||
.calledWith(
|
||||
null,
|
||||
@@ -222,13 +222,13 @@ describe('TpdsController', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should return a success', function() {
|
||||
it('should return a success', function () {
|
||||
this.res.sendStatus.calledWith(200).should.equal(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('deleteProjectContents', function() {
|
||||
beforeEach(function() {
|
||||
describe('deleteProjectContents', function () {
|
||||
beforeEach(function () {
|
||||
this.UpdateMerger.deleteUpdate = sinon.stub().callsArg(4)
|
||||
this.req = {
|
||||
params: {
|
||||
@@ -247,30 +247,30 @@ describe('TpdsController', function() {
|
||||
this.TpdsController.deleteProjectContents(this.req, this.res, this.next)
|
||||
})
|
||||
|
||||
it('should delete the file', function() {
|
||||
it('should delete the file', function () {
|
||||
this.UpdateMerger.deleteUpdate
|
||||
.calledWith(null, this.project_id, `/${this.path}`, this.source)
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should return a success', function() {
|
||||
it('should return a success', function () {
|
||||
this.res.sendStatus.calledWith(200).should.equal(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('getQueues', function() {
|
||||
beforeEach(function() {
|
||||
describe('getQueues', function () {
|
||||
beforeEach(function () {
|
||||
this.req = {}
|
||||
this.res = { json: sinon.stub() }
|
||||
this.next = sinon.stub()
|
||||
})
|
||||
|
||||
describe('success', function() {
|
||||
beforeEach(async function() {
|
||||
describe('success', function () {
|
||||
beforeEach(async function () {
|
||||
await this.TpdsController.getQueues(this.req, this.res, this.next)
|
||||
})
|
||||
|
||||
it('should use userId from session', function() {
|
||||
it('should use userId from session', function () {
|
||||
this.AuthenticationController.getLoggedInUserId.should.have.been
|
||||
.calledOnce
|
||||
this.TpdsQueueManager.promises.getQueues.should.have.been.calledWith(
|
||||
@@ -278,14 +278,14 @@ describe('TpdsController', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should call json with response', function() {
|
||||
it('should call json with response', function () {
|
||||
this.res.json.should.have.been.calledWith('queues')
|
||||
this.next.should.not.have.been.called
|
||||
})
|
||||
})
|
||||
|
||||
describe('error', function() {
|
||||
beforeEach(async function() {
|
||||
describe('error', function () {
|
||||
beforeEach(async function () {
|
||||
this.err = new Error()
|
||||
this.TpdsQueueManager.promises.getQueues = sinon
|
||||
.stub()
|
||||
@@ -293,7 +293,7 @@ describe('TpdsController', function() {
|
||||
await this.TpdsController.getQueues(this.req, this.res, this.next)
|
||||
})
|
||||
|
||||
it('should call next with error', function() {
|
||||
it('should call next with error', function () {
|
||||
this.res.json.should.not.have.been.called
|
||||
this.next.should.have.been.calledWith(this.err)
|
||||
})
|
||||
|
||||
@@ -7,8 +7,8 @@ const { Project } = require('../helpers/models/Project')
|
||||
const MODULE_PATH =
|
||||
'../../../../app/src/Features/ThirdPartyDataStore/TpdsProjectFlusher'
|
||||
|
||||
describe('TpdsProjectFlusher', function() {
|
||||
beforeEach(function() {
|
||||
describe('TpdsProjectFlusher', function () {
|
||||
beforeEach(function () {
|
||||
this.project = { _id: ObjectId() }
|
||||
this.docs = {
|
||||
'/doc/one': { _id: 'mock-doc-1', lines: ['one'], rev: 5 },
|
||||
@@ -30,10 +30,7 @@ describe('TpdsProjectFlusher', function() {
|
||||
}
|
||||
this.ProjectEntityHandler = {
|
||||
promises: {
|
||||
getAllDocs: sinon
|
||||
.stub()
|
||||
.withArgs(this.project._id)
|
||||
.resolves(this.docs),
|
||||
getAllDocs: sinon.stub().withArgs(this.project._id).resolves(this.docs),
|
||||
getAllFiles: sinon
|
||||
.stub()
|
||||
.withArgs(this.project._id)
|
||||
@@ -60,25 +57,25 @@ describe('TpdsProjectFlusher', function() {
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
this.ProjectMock.restore()
|
||||
})
|
||||
|
||||
describe('flushProjectToTpds', function() {
|
||||
describe('usually', function() {
|
||||
beforeEach(async function() {
|
||||
describe('flushProjectToTpds', function () {
|
||||
describe('usually', function () {
|
||||
beforeEach(async function () {
|
||||
await this.TpdsProjectFlusher.promises.flushProjectToTpds(
|
||||
this.project._id
|
||||
)
|
||||
})
|
||||
|
||||
it('should flush the project from the doc updater', function() {
|
||||
it('should flush the project from the doc updater', function () {
|
||||
expect(
|
||||
this.DocumentUpdaterHandler.promises.flushProjectToMongo
|
||||
).to.have.been.calledWith(this.project._id)
|
||||
})
|
||||
|
||||
it('should flush each doc to the TPDS', function() {
|
||||
it('should flush each doc to the TPDS', function () {
|
||||
for (const [path, doc] of Object.entries(this.docs)) {
|
||||
expect(this.TpdsUpdateSender.promises.addDoc).to.have.been.calledWith(
|
||||
{
|
||||
@@ -92,7 +89,7 @@ describe('TpdsProjectFlusher', function() {
|
||||
}
|
||||
})
|
||||
|
||||
it('should flush each file to the TPDS', function() {
|
||||
it('should flush each file to the TPDS', function () {
|
||||
for (const [path, file] of Object.entries(this.files)) {
|
||||
expect(
|
||||
this.TpdsUpdateSender.promises.addFile
|
||||
@@ -107,8 +104,8 @@ describe('TpdsProjectFlusher', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when a TPDS flush is pending', function() {
|
||||
beforeEach(async function() {
|
||||
describe('when a TPDS flush is pending', function () {
|
||||
beforeEach(async function () {
|
||||
this.project.deferredTpdsFlushCounter = 2
|
||||
this.ProjectMock.expects('updateOne')
|
||||
.withArgs(
|
||||
@@ -125,14 +122,14 @@ describe('TpdsProjectFlusher', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('resets the deferred flush counter', function() {
|
||||
it('resets the deferred flush counter', function () {
|
||||
this.ProjectMock.verify()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('deferProjectFlushToTpds', function() {
|
||||
beforeEach(async function() {
|
||||
describe('deferProjectFlushToTpds', function () {
|
||||
beforeEach(async function () {
|
||||
this.ProjectMock.expects('updateOne')
|
||||
.withArgs(
|
||||
{
|
||||
@@ -147,32 +144,32 @@ describe('TpdsProjectFlusher', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('increments the deferred flush counter', function() {
|
||||
it('increments the deferred flush counter', function () {
|
||||
this.ProjectMock.verify()
|
||||
})
|
||||
})
|
||||
|
||||
describe('flushProjectToTpdsIfNeeded', function() {
|
||||
describe('flushProjectToTpdsIfNeeded', function () {
|
||||
let cases = [0, undefined]
|
||||
cases.forEach(counterValue => {
|
||||
describe(`when the deferred flush counter is ${counterValue}`, function() {
|
||||
beforeEach(async function() {
|
||||
describe(`when the deferred flush counter is ${counterValue}`, function () {
|
||||
beforeEach(async function () {
|
||||
this.project.deferredTpdsFlushCounter = counterValue
|
||||
await this.TpdsProjectFlusher.promises.flushProjectToTpdsIfNeeded(
|
||||
this.project._id
|
||||
)
|
||||
})
|
||||
|
||||
it("doesn't flush the project from the doc updater", function() {
|
||||
it("doesn't flush the project from the doc updater", function () {
|
||||
expect(this.DocumentUpdaterHandler.promises.flushProjectToMongo).not
|
||||
.to.have.been.called
|
||||
})
|
||||
|
||||
it("doesn't flush any doc", function() {
|
||||
it("doesn't flush any doc", function () {
|
||||
expect(this.TpdsUpdateSender.promises.addDoc).not.to.have.been.called
|
||||
})
|
||||
|
||||
it("doesn't flush any file", function() {
|
||||
it("doesn't flush any file", function () {
|
||||
expect(this.TpdsUpdateSender.promises.addFile).not.to.have.been.called
|
||||
})
|
||||
})
|
||||
@@ -180,8 +177,8 @@ describe('TpdsProjectFlusher', function() {
|
||||
|
||||
cases = [1, 2]
|
||||
cases.forEach(counterValue => {
|
||||
describe(`when the deferred flush counter is ${counterValue}`, function() {
|
||||
beforeEach(async function() {
|
||||
describe(`when the deferred flush counter is ${counterValue}`, function () {
|
||||
beforeEach(async function () {
|
||||
this.project.deferredTpdsFlushCounter = counterValue
|
||||
this.ProjectMock.expects('updateOne')
|
||||
.withArgs(
|
||||
@@ -198,13 +195,13 @@ describe('TpdsProjectFlusher', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('flushes the project from the doc updater', function() {
|
||||
it('flushes the project from the doc updater', function () {
|
||||
expect(
|
||||
this.DocumentUpdaterHandler.promises.flushProjectToMongo
|
||||
).to.have.been.calledWith(this.project._id)
|
||||
})
|
||||
|
||||
it('flushes each doc to the TPDS', function() {
|
||||
it('flushes each doc to the TPDS', function () {
|
||||
for (const [path, doc] of Object.entries(this.docs)) {
|
||||
expect(
|
||||
this.TpdsUpdateSender.promises.addDoc
|
||||
@@ -218,7 +215,7 @@ describe('TpdsProjectFlusher', function() {
|
||||
}
|
||||
})
|
||||
|
||||
it('flushes each file to the TPDS', function() {
|
||||
it('flushes each file to the TPDS', function () {
|
||||
for (const [path, file] of Object.entries(this.files)) {
|
||||
expect(
|
||||
this.TpdsUpdateSender.promises.addFile
|
||||
@@ -232,7 +229,7 @@ describe('TpdsProjectFlusher', function() {
|
||||
}
|
||||
})
|
||||
|
||||
it('resets the deferred flush counter', function() {
|
||||
it('resets the deferred flush counter', function () {
|
||||
this.ProjectMock.verify()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -7,16 +7,16 @@ const Errors = require('../../../../app/src/Features/Errors/Errors')
|
||||
const MODULE_PATH =
|
||||
'../../../../app/src/Features/ThirdPartyDataStore/TpdsUpdateHandler.js'
|
||||
|
||||
describe('TpdsUpdateHandler', function() {
|
||||
beforeEach(function() {
|
||||
describe('TpdsUpdateHandler', function () {
|
||||
beforeEach(function () {
|
||||
this.clock = sinon.useFakeTimers()
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
this.clock.restore()
|
||||
})
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
this.projectName = 'My recipes'
|
||||
this.projects = {
|
||||
active1: { _id: new ObjectId(), name: this.projectName },
|
||||
@@ -92,22 +92,22 @@ describe('TpdsUpdateHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('getting an update', function() {
|
||||
describe('with no matching project', function() {
|
||||
describe('getting an update', function () {
|
||||
describe('with no matching project', function () {
|
||||
setupMatchingProjects([])
|
||||
receiveUpdate()
|
||||
expectProjectCreated()
|
||||
expectUpdateProcessed()
|
||||
})
|
||||
|
||||
describe('with one matching active project', function() {
|
||||
describe('with one matching active project', function () {
|
||||
setupMatchingProjects(['active1'])
|
||||
receiveUpdate()
|
||||
expectProjectNotCreated()
|
||||
expectUpdateProcessed()
|
||||
})
|
||||
|
||||
describe('with one matching archived project', function() {
|
||||
describe('with one matching archived project', function () {
|
||||
setupMatchingProjects(['archived1'])
|
||||
receiveUpdate()
|
||||
expectProjectNotCreated()
|
||||
@@ -115,7 +115,7 @@ describe('TpdsUpdateHandler', function() {
|
||||
expectDropboxNotUnlinked()
|
||||
})
|
||||
|
||||
describe('with two matching active projects', function() {
|
||||
describe('with two matching active projects', function () {
|
||||
setupMatchingProjects(['active1', 'active2'])
|
||||
receiveUpdate()
|
||||
expectProjectNotCreated()
|
||||
@@ -123,7 +123,7 @@ describe('TpdsUpdateHandler', function() {
|
||||
expectDropboxUnlinked()
|
||||
})
|
||||
|
||||
describe('with two matching archived projects', function() {
|
||||
describe('with two matching archived projects', function () {
|
||||
setupMatchingProjects(['archived1', 'archived2'])
|
||||
receiveUpdate()
|
||||
expectProjectNotCreated()
|
||||
@@ -131,7 +131,7 @@ describe('TpdsUpdateHandler', function() {
|
||||
expectDropboxNotUnlinked()
|
||||
})
|
||||
|
||||
describe('with one matching active and one matching archived project', function() {
|
||||
describe('with one matching active and one matching archived project', function () {
|
||||
setupMatchingProjects(['active1', 'archived1'])
|
||||
receiveUpdate()
|
||||
expectProjectNotCreated()
|
||||
@@ -139,9 +139,9 @@ describe('TpdsUpdateHandler', function() {
|
||||
expectDropboxUnlinked()
|
||||
})
|
||||
|
||||
describe('update to a file that should be ignored', function(done) {
|
||||
describe('update to a file that should be ignored', function (done) {
|
||||
setupMatchingProjects(['active1'])
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
this.FileTypeManager.shouldIgnore.yields(null, true)
|
||||
})
|
||||
receiveUpdate()
|
||||
@@ -150,10 +150,10 @@ describe('TpdsUpdateHandler', function() {
|
||||
expectDropboxNotUnlinked()
|
||||
})
|
||||
|
||||
describe('update to a project on cooldown', function(done) {
|
||||
describe('update to a project on cooldown', function (done) {
|
||||
setupMatchingProjects(['active1'])
|
||||
setupProjectOnCooldown()
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function (done) {
|
||||
this.TpdsUpdateHandler.newUpdate(
|
||||
this.userId,
|
||||
this.projectName,
|
||||
@@ -170,29 +170,29 @@ describe('TpdsUpdateHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('getting a file delete', function() {
|
||||
describe('with no matching project', function() {
|
||||
describe('getting a file delete', function () {
|
||||
describe('with no matching project', function () {
|
||||
setupMatchingProjects([])
|
||||
receiveFileDelete()
|
||||
expectDeleteNotProcessed()
|
||||
expectProjectNotDeleted()
|
||||
})
|
||||
|
||||
describe('with one matching active project', function() {
|
||||
describe('with one matching active project', function () {
|
||||
setupMatchingProjects(['active1'])
|
||||
receiveFileDelete()
|
||||
expectDeleteProcessed()
|
||||
expectProjectNotDeleted()
|
||||
})
|
||||
|
||||
describe('with one matching archived project', function() {
|
||||
describe('with one matching archived project', function () {
|
||||
setupMatchingProjects(['archived1'])
|
||||
receiveFileDelete()
|
||||
expectDeleteNotProcessed()
|
||||
expectProjectNotDeleted()
|
||||
})
|
||||
|
||||
describe('with two matching active projects', function() {
|
||||
describe('with two matching active projects', function () {
|
||||
setupMatchingProjects(['active1', 'active2'])
|
||||
receiveFileDelete()
|
||||
expectDeleteNotProcessed()
|
||||
@@ -200,7 +200,7 @@ describe('TpdsUpdateHandler', function() {
|
||||
expectDropboxUnlinked()
|
||||
})
|
||||
|
||||
describe('with two matching archived projects', function() {
|
||||
describe('with two matching archived projects', function () {
|
||||
setupMatchingProjects(['archived1', 'archived2'])
|
||||
receiveFileDelete()
|
||||
expectDeleteNotProcessed()
|
||||
@@ -208,7 +208,7 @@ describe('TpdsUpdateHandler', function() {
|
||||
expectDropboxNotUnlinked()
|
||||
})
|
||||
|
||||
describe('with one matching active and one matching archived project', function() {
|
||||
describe('with one matching active and one matching archived project', function () {
|
||||
setupMatchingProjects(['active1', 'archived1'])
|
||||
receiveFileDelete()
|
||||
expectDeleteNotProcessed()
|
||||
@@ -217,29 +217,29 @@ describe('TpdsUpdateHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('getting a project delete', function() {
|
||||
describe('with no matching project', function() {
|
||||
describe('getting a project delete', function () {
|
||||
describe('with no matching project', function () {
|
||||
setupMatchingProjects([])
|
||||
receiveProjectDelete()
|
||||
expectDeleteNotProcessed()
|
||||
expectProjectNotDeleted()
|
||||
})
|
||||
|
||||
describe('with one matching active project', function() {
|
||||
describe('with one matching active project', function () {
|
||||
setupMatchingProjects(['active1'])
|
||||
receiveProjectDelete()
|
||||
expectDeleteNotProcessed()
|
||||
expectProjectDeleted()
|
||||
})
|
||||
|
||||
describe('with one matching archived project', function() {
|
||||
describe('with one matching archived project', function () {
|
||||
setupMatchingProjects(['archived1'])
|
||||
receiveProjectDelete()
|
||||
expectDeleteNotProcessed()
|
||||
expectProjectNotDeleted()
|
||||
})
|
||||
|
||||
describe('with two matching active projects', function() {
|
||||
describe('with two matching active projects', function () {
|
||||
setupMatchingProjects(['active1', 'active2'])
|
||||
receiveProjectDelete()
|
||||
expectDeleteNotProcessed()
|
||||
@@ -247,7 +247,7 @@ describe('TpdsUpdateHandler', function() {
|
||||
expectDropboxUnlinked()
|
||||
})
|
||||
|
||||
describe('with two matching archived projects', function() {
|
||||
describe('with two matching archived projects', function () {
|
||||
setupMatchingProjects(['archived1', 'archived2'])
|
||||
receiveProjectDelete()
|
||||
expectDeleteNotProcessed()
|
||||
@@ -255,7 +255,7 @@ describe('TpdsUpdateHandler', function() {
|
||||
expectDropboxNotUnlinked()
|
||||
})
|
||||
|
||||
describe('with one matching active and one matching archived project', function() {
|
||||
describe('with one matching active and one matching archived project', function () {
|
||||
setupMatchingProjects(['active1', 'archived1'])
|
||||
receiveProjectDelete()
|
||||
expectDeleteNotProcessed()
|
||||
@@ -268,7 +268,7 @@ describe('TpdsUpdateHandler', function() {
|
||||
/* Setup helpers */
|
||||
|
||||
function setupMatchingProjects(projectKeys) {
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
const projects = projectKeys.map(key => this.projects[key])
|
||||
this.ProjectGetter.findUsersProjectsByName
|
||||
.withArgs(this.userId, this.projectName)
|
||||
@@ -277,7 +277,7 @@ function setupMatchingProjects(projectKeys) {
|
||||
}
|
||||
|
||||
function setupProjectOnCooldown() {
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
this.CooldownManager.isProjectOnCooldown
|
||||
.withArgs(this.projects.active1._id)
|
||||
.yields(null, true)
|
||||
@@ -287,7 +287,7 @@ function setupProjectOnCooldown() {
|
||||
/* Test helpers */
|
||||
|
||||
function receiveUpdate() {
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function (done) {
|
||||
this.TpdsUpdateHandler.newUpdate(
|
||||
this.userId,
|
||||
this.projectName,
|
||||
@@ -300,7 +300,7 @@ function receiveUpdate() {
|
||||
}
|
||||
|
||||
function receiveFileDelete() {
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function (done) {
|
||||
this.TpdsUpdateHandler.deleteUpdate(
|
||||
this.userId,
|
||||
this.projectName,
|
||||
@@ -312,7 +312,7 @@ function receiveFileDelete() {
|
||||
}
|
||||
|
||||
function receiveProjectDelete() {
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function (done) {
|
||||
this.TpdsUpdateHandler.deleteUpdate(
|
||||
this.userId,
|
||||
this.projectName,
|
||||
@@ -326,13 +326,13 @@ function receiveProjectDelete() {
|
||||
/* Expectations */
|
||||
|
||||
function expectProjectCreated() {
|
||||
it('creates a project', function() {
|
||||
it('creates a project', function () {
|
||||
expect(
|
||||
this.ProjectCreationHandler.createBlankProject
|
||||
).to.have.been.calledWith(this.userId, this.projectName)
|
||||
})
|
||||
|
||||
it('sets the root doc', function() {
|
||||
it('sets the root doc', function () {
|
||||
// Fire pending timers
|
||||
this.clock.runAll()
|
||||
expect(this.RootDocManager.setRootDocAutomatically).to.have.been.calledWith(
|
||||
@@ -342,12 +342,12 @@ function expectProjectCreated() {
|
||||
}
|
||||
|
||||
function expectProjectNotCreated() {
|
||||
it('does not create a project', function() {
|
||||
it('does not create a project', function () {
|
||||
expect(this.ProjectCreationHandler.createBlankProject).not.to.have.been
|
||||
.called
|
||||
})
|
||||
|
||||
it('does not set the root doc', function() {
|
||||
it('does not set the root doc', function () {
|
||||
// Fire pending timers
|
||||
this.clock.runAll()
|
||||
expect(this.RootDocManager.setRootDocAutomatically).not.to.have.been.called
|
||||
@@ -355,7 +355,7 @@ function expectProjectNotCreated() {
|
||||
}
|
||||
|
||||
function expectUpdateProcessed() {
|
||||
it('processes the update', function() {
|
||||
it('processes the update', function () {
|
||||
expect(this.UpdateMerger.mergeUpdate).to.have.been.calledWith(
|
||||
this.userId,
|
||||
this.projects.active1._id,
|
||||
@@ -367,20 +367,20 @@ function expectUpdateProcessed() {
|
||||
}
|
||||
|
||||
function expectUpdateNotProcessed() {
|
||||
it('does not process the update', function() {
|
||||
it('does not process the update', function () {
|
||||
expect(this.UpdateMerger.mergeUpdate).not.to.have.been.called
|
||||
})
|
||||
}
|
||||
|
||||
function expectDropboxUnlinked() {
|
||||
it('unlinks Dropbox', function() {
|
||||
it('unlinks Dropbox', function () {
|
||||
expect(this.Modules.hooks.fire).to.have.been.calledWith(
|
||||
'removeDropbox',
|
||||
this.userId
|
||||
)
|
||||
})
|
||||
|
||||
it('creates a notification that dropbox was unlinked', function() {
|
||||
it('creates a notification that dropbox was unlinked', function () {
|
||||
expect(
|
||||
this.NotificationsBuilder.dropboxDuplicateProjectNames
|
||||
).to.have.been.calledWith(this.userId)
|
||||
@@ -389,18 +389,18 @@ function expectDropboxUnlinked() {
|
||||
}
|
||||
|
||||
function expectDropboxNotUnlinked() {
|
||||
it('does not unlink Dropbox', function() {
|
||||
it('does not unlink Dropbox', function () {
|
||||
expect(this.Modules.hooks.fire).not.to.have.been.called
|
||||
})
|
||||
|
||||
it('does not create a notification that dropbox was unlinked', function() {
|
||||
it('does not create a notification that dropbox was unlinked', function () {
|
||||
expect(this.NotificationsBuilder.dropboxDuplicateProjectNames).not.to.have
|
||||
.been.called
|
||||
})
|
||||
}
|
||||
|
||||
function expectDeleteProcessed() {
|
||||
it('processes the delete', function() {
|
||||
it('processes the delete', function () {
|
||||
expect(this.UpdateMerger.deleteUpdate).to.have.been.calledWith(
|
||||
this.userId,
|
||||
this.projects.active1._id,
|
||||
@@ -411,13 +411,13 @@ function expectDeleteProcessed() {
|
||||
}
|
||||
|
||||
function expectDeleteNotProcessed() {
|
||||
it('does not process the delete', function() {
|
||||
it('does not process the delete', function () {
|
||||
expect(this.UpdateMerger.deleteUpdate).not.to.have.been.called
|
||||
})
|
||||
}
|
||||
|
||||
function expectProjectDeleted() {
|
||||
it('deletes the project', function() {
|
||||
it('deletes the project', function () {
|
||||
expect(
|
||||
this.ProjectDeleter.markAsDeletedByExternalSource
|
||||
).to.have.been.calledWith(this.projects.active1._id)
|
||||
@@ -425,7 +425,7 @@ function expectProjectDeleted() {
|
||||
}
|
||||
|
||||
function expectProjectNotDeleted() {
|
||||
it('does not delete the project', function() {
|
||||
it('does not delete the project', function () {
|
||||
expect(this.ProjectDeleter.markAsDeletedByExternalSource).not.to.have.been
|
||||
.called
|
||||
})
|
||||
|
||||
@@ -21,12 +21,12 @@ const siteUrl = 'http://www.localhost:3000'
|
||||
const httpAuthSiteUrl = `http://${httpUsername}:${httpPass}@www.localhost:3000`
|
||||
const filestoreUrl = 'filestore.sharelatex.com'
|
||||
|
||||
describe('TpdsUpdateSender', function() {
|
||||
beforeEach(function() {
|
||||
describe('TpdsUpdateSender', function () {
|
||||
beforeEach(function () {
|
||||
this.fakeUser = {
|
||||
_id: '12390i'
|
||||
}
|
||||
this.requestQueuer = function(queue, meth, opts, callback) {}
|
||||
this.requestQueuer = function (queue, meth, opts, callback) {}
|
||||
const memberIds = [userId, collaberatorRef, readOnlyRef]
|
||||
this.CollaboratorsGetter = {
|
||||
promises: {
|
||||
@@ -70,13 +70,13 @@ describe('TpdsUpdateSender', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('enqueue', function() {
|
||||
it('should not call request if there is no tpdsworker url', async function() {
|
||||
describe('enqueue', function () {
|
||||
it('should not call request if there is no tpdsworker url', async function () {
|
||||
await this.updateSender.promises.enqueue(null, null, null)
|
||||
this.request.should.not.have.been.called
|
||||
})
|
||||
|
||||
it('should post the message to the tpdsworker', async function() {
|
||||
it('should post the message to the tpdsworker', async function () {
|
||||
this.settings.apis.tpdsworker = { url: 'www.tpdsworker.env' }
|
||||
const group0 = 'myproject'
|
||||
const method0 = 'somemethod0'
|
||||
@@ -92,12 +92,12 @@ describe('TpdsUpdateSender', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('sending updates', function() {
|
||||
beforeEach(function() {
|
||||
describe('sending updates', function () {
|
||||
beforeEach(function () {
|
||||
this.settings.apis.tpdsworker = { url: 'www.tpdsworker.env' }
|
||||
})
|
||||
|
||||
it('queues a post the file with user and file id', async function() {
|
||||
it('queues a post the file with user and file id', async function () {
|
||||
const fileId = '4545345'
|
||||
const path = '/some/path/here.jpg'
|
||||
|
||||
@@ -149,7 +149,7 @@ describe('TpdsUpdateSender', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('post doc with stream origin of docstore', async function() {
|
||||
it('post doc with stream origin of docstore', async function () {
|
||||
const docId = '4545345'
|
||||
const path = '/some/path/here.tex'
|
||||
const lines = ['line1', 'line2', 'line3']
|
||||
@@ -201,7 +201,7 @@ describe('TpdsUpdateSender', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('deleting entity', async function() {
|
||||
it('deleting entity', async function () {
|
||||
const path = '/path/here/t.tex'
|
||||
|
||||
await this.updateSender.promises.deleteEntity({
|
||||
@@ -246,7 +246,7 @@ describe('TpdsUpdateSender', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('moving entity', async function() {
|
||||
it('moving entity', async function () {
|
||||
const startPath = 'staring/here/file.tex'
|
||||
const endPath = 'ending/here/file.tex'
|
||||
|
||||
@@ -294,7 +294,7 @@ describe('TpdsUpdateSender', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should be able to rename a project using the move entity func', async function() {
|
||||
it('should be able to rename a project using the move entity func', async function () {
|
||||
const oldProjectName = '/oldProjectName/'
|
||||
const newProjectName = '/newProjectName/'
|
||||
|
||||
@@ -341,7 +341,7 @@ describe('TpdsUpdateSender', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('pollDropboxForUser', async function() {
|
||||
it('pollDropboxForUser', async function () {
|
||||
await this.updateSender.promises.pollDropboxForUser(userId)
|
||||
|
||||
const {
|
||||
|
||||
@@ -6,8 +6,8 @@ const modulePath = require('path').join(
|
||||
)
|
||||
const BufferedStream = require('bufferedstream')
|
||||
|
||||
describe('UpdateMerger :', function() {
|
||||
beforeEach(function() {
|
||||
describe('UpdateMerger :', function () {
|
||||
beforeEach(function () {
|
||||
this.updateMerger = SandboxedModule.require(modulePath, {
|
||||
requires: {
|
||||
fs: (this.fs = { unlink: sinon.stub().callsArgWith(1) }),
|
||||
@@ -42,9 +42,9 @@ describe('UpdateMerger :', function() {
|
||||
this.callback = sinon.stub()
|
||||
})
|
||||
|
||||
describe('mergeUpdate', function() {
|
||||
describe('doc updates for a new doc', function() {
|
||||
beforeEach(function() {
|
||||
describe('mergeUpdate', function () {
|
||||
describe('doc updates for a new doc', function () {
|
||||
beforeEach(function () {
|
||||
this.FileTypeManager.getType = sinon
|
||||
.stub()
|
||||
.yields(null, { binary: false, encoding: 'utf-8' })
|
||||
@@ -59,11 +59,11 @@ describe('UpdateMerger :', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should look at the file contents', function() {
|
||||
it('should look at the file contents', function () {
|
||||
this.FileTypeManager.getType.called.should.equal(true)
|
||||
})
|
||||
|
||||
it('should process update as doc', function() {
|
||||
it('should process update as doc', function () {
|
||||
this.updateMerger.p.processDoc
|
||||
.calledWith(
|
||||
this.project_id,
|
||||
@@ -75,13 +75,13 @@ describe('UpdateMerger :', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('removes the temp file from disk', function() {
|
||||
it('removes the temp file from disk', function () {
|
||||
this.fs.unlink.calledWith(this.fsPath).should.equal(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('file updates for a new file ', function() {
|
||||
beforeEach(function() {
|
||||
describe('file updates for a new file ', function () {
|
||||
beforeEach(function () {
|
||||
this.FileTypeManager.getType = sinon
|
||||
.stub()
|
||||
.yields(null, { binary: true })
|
||||
@@ -96,11 +96,11 @@ describe('UpdateMerger :', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should look at the file contents', function() {
|
||||
it('should look at the file contents', function () {
|
||||
this.FileTypeManager.getType.called.should.equal(true)
|
||||
})
|
||||
|
||||
it('should process update as file', function() {
|
||||
it('should process update as file', function () {
|
||||
this.updateMerger.p.processFile
|
||||
.calledWith(
|
||||
this.project_id,
|
||||
@@ -112,13 +112,13 @@ describe('UpdateMerger :', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('removes the temp file from disk', function() {
|
||||
it('removes the temp file from disk', function () {
|
||||
this.fs.unlink.calledWith(this.fsPath).should.equal(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('doc updates for an existing doc', function() {
|
||||
beforeEach(function() {
|
||||
describe('doc updates for an existing doc', function () {
|
||||
beforeEach(function () {
|
||||
this.FileTypeManager.getType = sinon
|
||||
.stub()
|
||||
.yields(null, { binary: false, encoding: 'utf-8' })
|
||||
@@ -133,11 +133,11 @@ describe('UpdateMerger :', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should look at the file contents', function() {
|
||||
it('should look at the file contents', function () {
|
||||
this.FileTypeManager.getType.called.should.equal(true)
|
||||
})
|
||||
|
||||
it('should process update as doc', function() {
|
||||
it('should process update as doc', function () {
|
||||
this.updateMerger.p.processDoc
|
||||
.calledWith(
|
||||
this.project_id,
|
||||
@@ -149,13 +149,13 @@ describe('UpdateMerger :', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('removes the temp file from disk', function() {
|
||||
it('removes the temp file from disk', function () {
|
||||
this.fs.unlink.calledWith(this.fsPath).should.equal(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('file updates for an existing file', function() {
|
||||
beforeEach(function() {
|
||||
describe('file updates for an existing file', function () {
|
||||
beforeEach(function () {
|
||||
this.FileTypeManager.getType = sinon
|
||||
.stub()
|
||||
.yields(null, { binary: true })
|
||||
@@ -170,11 +170,11 @@ describe('UpdateMerger :', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should look at the file contents', function() {
|
||||
it('should look at the file contents', function () {
|
||||
this.FileTypeManager.getType.called.should.equal(true)
|
||||
})
|
||||
|
||||
it('should process update as file', function() {
|
||||
it('should process update as file', function () {
|
||||
this.updateMerger.p.processFile
|
||||
.calledWith(
|
||||
this.project_id,
|
||||
@@ -186,14 +186,14 @@ describe('UpdateMerger :', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('removes the temp file from disk', function() {
|
||||
it('removes the temp file from disk', function () {
|
||||
this.fs.unlink.calledWith(this.fsPath).should.equal(true)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('file updates for an existing doc', function() {
|
||||
beforeEach(function() {
|
||||
describe('file updates for an existing doc', function () {
|
||||
beforeEach(function () {
|
||||
this.FileTypeManager.getType = sinon.stub().yields(null, { binary: true })
|
||||
this.updateMerger.deleteUpdate = sinon.stub().yields()
|
||||
this.updateMerger.p.processFile = sinon.stub().yields()
|
||||
@@ -207,11 +207,11 @@ describe('UpdateMerger :', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should look at the file contents', function() {
|
||||
it('should look at the file contents', function () {
|
||||
this.FileTypeManager.getType.called.should.equal(true)
|
||||
})
|
||||
|
||||
it('should delete the existing doc', function() {
|
||||
it('should delete the existing doc', function () {
|
||||
this.updateMerger.deleteUpdate
|
||||
.calledWith(
|
||||
this.user_id,
|
||||
@@ -222,7 +222,7 @@ describe('UpdateMerger :', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should process update as file', function() {
|
||||
it('should process update as file', function () {
|
||||
this.updateMerger.p.processFile
|
||||
.calledWith(
|
||||
this.project_id,
|
||||
@@ -234,13 +234,13 @@ describe('UpdateMerger :', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('removes the temp file from disk', function() {
|
||||
it('removes the temp file from disk', function () {
|
||||
this.fs.unlink.calledWith(this.fsPath).should.equal(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('doc updates for an existing file', function() {
|
||||
beforeEach(function() {
|
||||
describe('doc updates for an existing file', function () {
|
||||
beforeEach(function () {
|
||||
this.FileTypeManager.getType = sinon.stub().yields(null, { binary: true })
|
||||
this.updateMerger.deleteUpdate = sinon.stub().yields()
|
||||
this.updateMerger.p.processFile = sinon.stub().yields()
|
||||
@@ -254,15 +254,15 @@ describe('UpdateMerger :', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should look at the file contents', function() {
|
||||
it('should look at the file contents', function () {
|
||||
this.FileTypeManager.getType.called.should.equal(true)
|
||||
})
|
||||
|
||||
it('should not delete the existing file', function() {
|
||||
it('should not delete the existing file', function () {
|
||||
this.updateMerger.deleteUpdate.called.should.equal(false)
|
||||
})
|
||||
|
||||
it('should process update as file', function() {
|
||||
it('should process update as file', function () {
|
||||
this.updateMerger.p.processFile
|
||||
.calledWith(
|
||||
this.project_id,
|
||||
@@ -274,13 +274,13 @@ describe('UpdateMerger :', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('removes the temp file from disk', function() {
|
||||
it('removes the temp file from disk', function () {
|
||||
this.fs.unlink.calledWith(this.fsPath).should.equal(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('deleteUpdate', function() {
|
||||
beforeEach(function() {
|
||||
describe('deleteUpdate', function () {
|
||||
beforeEach(function () {
|
||||
this.EditorController.deleteEntityWithPath = sinon.stub().yields()
|
||||
this.updateMerger.deleteUpdate(
|
||||
this.user_id,
|
||||
@@ -291,16 +291,16 @@ describe('UpdateMerger :', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should delete the entity in the editor controller', function() {
|
||||
it('should delete the entity in the editor controller', function () {
|
||||
this.EditorController.deleteEntityWithPath
|
||||
.calledWith(this.project_id, this.docPath, this.source, this.user_id)
|
||||
.should.equal(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('private methods', function() {
|
||||
describe('processDoc', function() {
|
||||
beforeEach(function() {
|
||||
describe('private methods', function () {
|
||||
describe('processDoc', function () {
|
||||
beforeEach(function () {
|
||||
this.docLines =
|
||||
'\\documentclass{article}\n\\usepackage[utf8]{inputenc}\n\n\\title{42}\n\\author{Jane Doe}\n\\date{June 2011}'
|
||||
this.updateMerger.p.readFileIntoTextArray = sinon
|
||||
@@ -318,13 +318,13 @@ describe('UpdateMerger :', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('reads the temp file from disk', function() {
|
||||
it('reads the temp file from disk', function () {
|
||||
this.updateMerger.p.readFileIntoTextArray
|
||||
.calledWith(this.fsPath)
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should upsert the doc in the editor controller', function() {
|
||||
it('should upsert the doc in the editor controller', function () {
|
||||
this.EditorController.upsertDocWithPath
|
||||
.calledWith(
|
||||
this.project_id,
|
||||
@@ -337,8 +337,8 @@ describe('UpdateMerger :', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('processFile', function() {
|
||||
beforeEach(function() {
|
||||
describe('processFile', function () {
|
||||
beforeEach(function () {
|
||||
this.EditorController.upsertFileWithPath = sinon.stub().yields()
|
||||
this.updateMerger.p.processFile(
|
||||
this.project_id,
|
||||
@@ -350,7 +350,7 @@ describe('UpdateMerger :', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should upsert the file in the editor controller', function() {
|
||||
it('should upsert the file in the editor controller', function () {
|
||||
this.EditorController.upsertFileWithPath
|
||||
.calledWith(
|
||||
this.project_id,
|
||||
|
||||
Reference in New Issue
Block a user