From 24ac4d4935838654ee32ae143a5ba4462f715f0f Mon Sep 17 00:00:00 2001 From: decaffeinate Date: Wed, 6 May 2020 12:12:36 +0200 Subject: [PATCH] decaffeinate: Run post-processing cleanups on ApplyingUpdatesToADocTests.coffee and 14 other files --- .../coffee/ApplyingUpdatesToADocTests.js | 30 +++++++++++-------- .../ApplyingUpdatesToProjectStructureTests.js | 29 +++++++++++------- .../coffee/DeletingADocumentTests.js | 7 ++++- .../coffee/DeletingAProjectTests.js | 18 +++++++---- .../coffee/FlushingAProjectTests.js | 10 +++++-- .../acceptance/coffee/FlushingDocsTests.js | 18 +++++++---- .../coffee/GettingADocumentTests.js | 28 ++++++++++------- .../coffee/GettingProjectDocsTests.js | 6 ++++ .../test/acceptance/coffee/RangesTests.js | 28 ++++++++++------- .../coffee/SettingADocumentTests.js | 13 ++++++-- .../coffee/helpers/DocUpdaterApp.js | 5 ++++ .../coffee/helpers/DocUpdaterClient.js | 28 ++++++++++------- .../coffee/helpers/MockProjectHistoryApi.js | 10 +++++-- .../coffee/helpers/MockTrackChangesApi.js | 12 ++++++-- .../acceptance/coffee/helpers/MockWebApi.js | 15 +++++++--- 15 files changed, 175 insertions(+), 82 deletions(-) diff --git a/services/document-updater/test/acceptance/coffee/ApplyingUpdatesToADocTests.js b/services/document-updater/test/acceptance/coffee/ApplyingUpdatesToADocTests.js index b5259dc7d5..928e656d03 100644 --- a/services/document-updater/test/acceptance/coffee/ApplyingUpdatesToADocTests.js +++ b/services/document-updater/test/acceptance/coffee/ApplyingUpdatesToADocTests.js @@ -1,3 +1,9 @@ +/* eslint-disable + camelcase, + handle-callback-err, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. /* * decaffeinate suggestions: * DS101: Remove unnecessary use of Array.from @@ -47,14 +53,14 @@ describe("Applying updates to a doc", function() { sinon.spy(MockWebApi, "getDocument"); this.startTime = Date.now(); MockWebApi.insertDoc(this.project_id, this.doc_id, {lines: this.lines, version: this.version}); - DocUpdaterClient.sendUpdate(this.project_id, this.doc_id, this.update, function(error) { + DocUpdaterClient.sendUpdate(this.project_id, this.doc_id, this.update, (error) => { if (error != null) { throw error; } return setTimeout(done, 200); }); return null; }); - after(() => MockWebApi.getDocument.restore()); + after(function() { return MockWebApi.getDocument.restore(); }); it("should load the document from the web API", function() { return MockWebApi.getDocument @@ -107,7 +113,7 @@ describe("Applying updates to a doc", function() { this.timeout = 10000; this.second_update = Object.create(this.update); this.second_update.v = this.version + 1; - DocUpdaterClient.sendUpdate(this.project_id, this.doc_id, this.second_update, function(error) { + DocUpdaterClient.sendUpdate(this.project_id, this.doc_id, this.second_update, (error) => { if (error != null) { throw error; } return setTimeout(done, 200); }); @@ -133,7 +139,7 @@ describe("Applying updates to a doc", function() { DocUpdaterClient.preloadDoc(this.project_id, this.doc_id, error => { if (error != null) { throw error; } sinon.spy(MockWebApi, "getDocument"); - return DocUpdaterClient.sendUpdate(this.project_id, this.doc_id, this.update, function(error) { + return DocUpdaterClient.sendUpdate(this.project_id, this.doc_id, this.update, (error) => { if (error != null) { throw error; } return setTimeout(done, 200); }); @@ -141,9 +147,9 @@ describe("Applying updates to a doc", function() { return null; }); - after(() => MockWebApi.getDocument.restore()); + after(function() { return MockWebApi.getDocument.restore(); }); - it("should not need to call the web api", () => MockWebApi.getDocument.called.should.equal(false)); + it("should not need to call the web api", function() { return MockWebApi.getDocument.called.should.equal(false); }); it("should update the doc", function(done) { DocUpdaterClient.getDoc(this.project_id, this.doc_id, (error, res, doc) => { @@ -181,7 +187,7 @@ describe("Applying updates to a doc", function() { DocUpdaterClient.preloadDoc(this.project_id, this.doc_id, error => { if (error != null) { throw error; } sinon.spy(MockWebApi, "getDocument"); - return DocUpdaterClient.sendUpdate(this.project_id, this.doc_id, this.update, function(error) { + return DocUpdaterClient.sendUpdate(this.project_id, this.doc_id, this.update, (error) => { if (error != null) { throw error; } return setTimeout(done, 200); }); @@ -189,7 +195,7 @@ describe("Applying updates to a doc", function() { return null; }); - after(() => MockWebApi.getDocument.restore()); + after(function() { return MockWebApi.getDocument.restore(); }); it("should update the doc", function(done) { DocUpdaterClient.getDoc(this.project_id, this.doc_id, (error, res, doc) => { @@ -345,7 +351,7 @@ describe("Applying updates to a doc", function() { DocUpdaterClient.subscribeToAppliedOps(this.messageCallback = sinon.stub()); - DocUpdaterClient.sendUpdate(this.project_id, this.doc_id, this.broken_update, function(error) { + DocUpdaterClient.sendUpdate(this.project_id, this.doc_id, this.broken_update, (error) => { if (error != null) { throw error; } return setTimeout(done, 200); }); @@ -404,9 +410,9 @@ describe("Applying updates to a doc", function() { return null; }); - after(() => MockTrackChangesApi.flushDoc.restore()); + after(function() { return MockTrackChangesApi.flushDoc.restore(); }); - return it("should flush the doc twice", () => MockTrackChangesApi.flushDoc.calledTwice.should.equal(true)); + return it("should flush the doc twice", function() { return MockTrackChangesApi.flushDoc.calledTwice.should.equal(true); }); }); describe("when there is no version in Mongo", function() { @@ -421,7 +427,7 @@ describe("Applying updates to a doc", function() { op: this.update.op, v: 0 }; - DocUpdaterClient.sendUpdate(this.project_id, this.doc_id, update, function(error) { + DocUpdaterClient.sendUpdate(this.project_id, this.doc_id, update, (error) => { if (error != null) { throw error; } return setTimeout(done, 200); }); diff --git a/services/document-updater/test/acceptance/coffee/ApplyingUpdatesToProjectStructureTests.js b/services/document-updater/test/acceptance/coffee/ApplyingUpdatesToProjectStructureTests.js index 3875cf28d1..d20c3f8aef 100644 --- a/services/document-updater/test/acceptance/coffee/ApplyingUpdatesToProjectStructureTests.js +++ b/services/document-updater/test/acceptance/coffee/ApplyingUpdatesToProjectStructureTests.js @@ -1,3 +1,10 @@ +/* eslint-disable + camelcase, + handle-callback-err, + no-return-assign, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. /* * decaffeinate suggestions: * DS102: Remove unnecessary code created because of implicit returns @@ -33,7 +40,7 @@ describe("Applying updates to a project's structure", function() { this.fileUpdates = [ this.fileUpdate ]; return DocUpdaterApp.ensureRunning(error => { if (error != null) { throw error; } - return DocUpdaterClient.sendProjectUpdate(this.project_id, this.user_id, [], this.fileUpdates, this.version, function(error) { + return DocUpdaterClient.sendProjectUpdate(this.project_id, this.user_id, [], this.fileUpdates, this.version, (error) => { if (error != null) { throw error; } return setTimeout(done, 200); }); @@ -70,7 +77,7 @@ describe("Applying updates to a project's structure", function() { describe("when the document is not loaded", function() { before(function(done) { this.project_id = DocUpdaterClient.randomId(); - DocUpdaterClient.sendProjectUpdate(this.project_id, this.user_id, this.docUpdates, [], this.version, function(error) { + DocUpdaterClient.sendProjectUpdate(this.project_id, this.user_id, this.docUpdates, [], this.version, (error) => { if (error != null) { throw error; } return setTimeout(done, 200); }); @@ -102,7 +109,7 @@ describe("Applying updates to a project's structure", function() { DocUpdaterClient.preloadDoc(this.project_id, this.docUpdate.id, error => { if (error != null) { throw error; } sinon.spy(MockWebApi, "getDocument"); - return DocUpdaterClient.sendProjectUpdate(this.project_id, this.user_id, this.docUpdates, [], this.version, function(error) { + return DocUpdaterClient.sendProjectUpdate(this.project_id, this.user_id, this.docUpdates, [], this.version, (error) => { if (error != null) { throw error; } return setTimeout(done, 200); }); @@ -110,7 +117,7 @@ describe("Applying updates to a project's structure", function() { return null; }); - after(() => MockWebApi.getDocument.restore()); + after(function() { return MockWebApi.getDocument.restore(); }); it("should update the doc", function(done) { DocUpdaterClient.getDoc(this.project_id, this.docUpdate.id, (error, res, doc) => { @@ -167,7 +174,7 @@ describe("Applying updates to a project's structure", function() { return describe("when the documents are not loaded", function() { before(function(done) { this.project_id = DocUpdaterClient.randomId(); - DocUpdaterClient.sendProjectUpdate(this.project_id, this.user_id, this.docUpdates, this.fileUpdates, this.version, function(error) { + DocUpdaterClient.sendProjectUpdate(this.project_id, this.user_id, this.docUpdates, this.fileUpdates, this.version, (error) => { if (error != null) { throw error; } return setTimeout(done, 200); }); @@ -227,7 +234,7 @@ describe("Applying updates to a project's structure", function() { url: 'filestore.example.com' }; this.fileUpdates = [ this.fileUpdate ]; - DocUpdaterClient.sendProjectUpdate(this.project_id, this.user_id, [], this.fileUpdates, this.version, function(error) { + DocUpdaterClient.sendProjectUpdate(this.project_id, this.user_id, [], this.fileUpdates, this.version, (error) => { if (error != null) { throw error; } return setTimeout(done, 200); }); @@ -261,7 +268,7 @@ describe("Applying updates to a project's structure", function() { docLines: 'a\nb' }; this.docUpdates = [ this.docUpdate ]; - DocUpdaterClient.sendProjectUpdate(this.project_id, this.user_id, this.docUpdates, [], this.version, function(error) { + DocUpdaterClient.sendProjectUpdate(this.project_id, this.user_id, this.docUpdates, [], this.version, (error) => { if (error != null) { throw error; } return setTimeout(done, 200); }); @@ -308,7 +315,7 @@ describe("Applying updates to a project's structure", function() { const userId = this.project_id; DocUpdaterClient.sendProjectUpdate(projectId, userId, updates.slice(0, 250), [], this.version0, function(error) { if (error != null) { throw error; } - return DocUpdaterClient.sendProjectUpdate(projectId, userId, updates.slice(250), [], this.version1, function(error) { + return DocUpdaterClient.sendProjectUpdate(projectId, userId, updates.slice(250), [], this.version1, (error) => { if (error != null) { throw error; } return setTimeout(done, 2000); }); @@ -316,7 +323,7 @@ describe("Applying updates to a project's structure", function() { return null; }); - after(() => MockProjectHistoryApi.flushProject.restore()); + after(function() { return MockProjectHistoryApi.flushProject.restore(); }); return it("should flush project history", function() { return MockProjectHistoryApi.flushProject.calledWith(this.project_id).should.equal(true); @@ -346,7 +353,7 @@ describe("Applying updates to a project's structure", function() { const userId = this.project_id; DocUpdaterClient.sendProjectUpdate(projectId, userId, updates.slice(0, 10), [], this.version0, function(error) { if (error != null) { throw error; } - return DocUpdaterClient.sendProjectUpdate(projectId, userId, updates.slice(10), [], this.version1, function(error) { + return DocUpdaterClient.sendProjectUpdate(projectId, userId, updates.slice(10), [], this.version1, (error) => { if (error != null) { throw error; } return setTimeout(done, 2000); }); @@ -354,7 +361,7 @@ describe("Applying updates to a project's structure", function() { return null; }); - after(() => MockProjectHistoryApi.flushProject.restore()); + after(function() { return MockProjectHistoryApi.flushProject.restore(); }); return it("should not flush project history", function() { return MockProjectHistoryApi.flushProject.calledWith(this.project_id).should.equal(false); diff --git a/services/document-updater/test/acceptance/coffee/DeletingADocumentTests.js b/services/document-updater/test/acceptance/coffee/DeletingADocumentTests.js index 527ec2edd2..73f61646cf 100644 --- a/services/document-updater/test/acceptance/coffee/DeletingADocumentTests.js +++ b/services/document-updater/test/acceptance/coffee/DeletingADocumentTests.js @@ -1,3 +1,8 @@ +/* eslint-disable + handle-callback-err, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. /* * decaffeinate suggestions: * DS101: Remove unnecessary use of Array.from @@ -118,7 +123,7 @@ describe("Deleting a document", function() { return this.statusCode.should.equal(204); }); - it("should not need to send the updated document to the web api", () => MockWebApi.setDocument.called.should.equal(false)); + it("should not need to send the updated document to the web api", function() { return MockWebApi.setDocument.called.should.equal(false); }); it("should need to reload the doc if read again", function(done) { MockWebApi.getDocument.called.should.equal.false; diff --git a/services/document-updater/test/acceptance/coffee/DeletingAProjectTests.js b/services/document-updater/test/acceptance/coffee/DeletingAProjectTests.js index b60d04bd40..74e1afd0b1 100644 --- a/services/document-updater/test/acceptance/coffee/DeletingAProjectTests.js +++ b/services/document-updater/test/acceptance/coffee/DeletingAProjectTests.js @@ -1,3 +1,9 @@ +/* eslint-disable + camelcase, + handle-callback-err, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. /* * decaffeinate suggestions: * DS101: Remove unnecessary use of Array.from @@ -45,7 +51,7 @@ describe("Deleting a project", function() { }, updatedLines: ["four", "four and a half", "five", "six"] }]; - for (let doc of Array.from(this.docs)) { + for (const doc of Array.from(this.docs)) { MockWebApi.insertDoc(this.project_id, doc.id, { lines: doc.lines, version: doc.update.v @@ -110,7 +116,7 @@ describe("Deleting a project", function() { return callback(); }); }; - }), function() { + }), () => { MockWebApi.getDocument.restore(); return done(); }); @@ -158,11 +164,11 @@ describe("Deleting a project", function() { return this.statusCode.should.equal(204); }); - it("should not send any documents to the web api", () => MockWebApi.setDocument.called.should.equal(false)); + it("should not send any documents to the web api", function() { return MockWebApi.setDocument.called.should.equal(false); }); - it("should not flush any docs in track changes", () => MockTrackChangesApi.flushDoc.called.should.equal(false)); + it("should not flush any docs in track changes", function() { return MockTrackChangesApi.flushDoc.called.should.equal(false); }); - return it("should not flush to project history", () => MockProjectHistoryApi.flushProject.called.should.equal(false)); + return it("should not flush to project history", function() { return MockProjectHistoryApi.flushProject.called.should.equal(false); }); }); return describe("with the background=true parameter from realtime and a request to flush the queue", function() { @@ -211,7 +217,7 @@ describe("Deleting a project", function() { MockTrackChangesApi.flushDoc.calledWith(doc.id).should.equal(true)); }); - return it("should flush to project history", () => MockProjectHistoryApi.flushProject.called.should.equal(true)); + return it("should flush to project history", function() { return MockProjectHistoryApi.flushProject.called.should.equal(true); }); }); }); diff --git a/services/document-updater/test/acceptance/coffee/FlushingAProjectTests.js b/services/document-updater/test/acceptance/coffee/FlushingAProjectTests.js index e70798ee27..ea45d4af26 100644 --- a/services/document-updater/test/acceptance/coffee/FlushingAProjectTests.js +++ b/services/document-updater/test/acceptance/coffee/FlushingAProjectTests.js @@ -1,3 +1,9 @@ +/* eslint-disable + camelcase, + handle-callback-err, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. /* * decaffeinate suggestions: * DS101: Remove unnecessary use of Array.from @@ -43,7 +49,7 @@ describe("Flushing a project", function() { }, updatedLines: ["four", "four and a half", "five", "six"] }]; - for (let doc of Array.from(this.docs)) { + for (const doc of Array.from(this.docs)) { MockWebApi.insertDoc(this.project_id, doc.id, { lines: doc.lines, version: doc.update.v @@ -77,7 +83,7 @@ describe("Flushing a project", function() { }); }); - after(() => MockWebApi.setDocument.restore()); + after(function() { return MockWebApi.setDocument.restore(); }); it("should return a 204 status code", function() { return this.statusCode.should.equal(204); diff --git a/services/document-updater/test/acceptance/coffee/FlushingDocsTests.js b/services/document-updater/test/acceptance/coffee/FlushingDocsTests.js index 761a388d3e..5d8c066f20 100644 --- a/services/document-updater/test/acceptance/coffee/FlushingDocsTests.js +++ b/services/document-updater/test/acceptance/coffee/FlushingDocsTests.js @@ -1,3 +1,11 @@ +/* eslint-disable + camelcase, + handle-callback-err, + no-return-assign, + no-unused-vars, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. /* * decaffeinate suggestions: * DS101: Remove unnecessary use of Array.from @@ -49,7 +57,7 @@ describe("Flushing a doc to Mongo", function() { }); }); - after(() => MockWebApi.setDocument.restore()); + after(function() { return MockWebApi.setDocument.restore(); }); it("should flush the updated doc lines and version to the web api", function() { return MockWebApi.setDocument @@ -76,9 +84,9 @@ describe("Flushing a doc to Mongo", function() { return DocUpdaterClient.flushDoc(this.project_id, this.doc_id, done); }); - after(() => MockWebApi.setDocument.restore()); + after(function() { return MockWebApi.setDocument.restore(); }); - return it("should not flush the doc to the web api", () => MockWebApi.setDocument.called.should.equal(false)); + return it("should not flush the doc to the web api", function() { return MockWebApi.setDocument.called.should.equal(false); }); }); return describe("when the web api http request takes a long time on first request", function() { @@ -89,7 +97,7 @@ describe("Flushing a doc to Mongo", function() { version: this.version }); let t = 30000; - sinon.stub(MockWebApi, "setDocument", function(project_id, doc_id, lines, version, ranges, lastUpdatedAt, lastUpdatedBy, callback) { + sinon.stub(MockWebApi, "setDocument", (project_id, doc_id, lines, version, ranges, lastUpdatedAt, lastUpdatedBy, callback) => { if (callback == null) { callback = function(error) {}; } setTimeout(callback, t); return t = 0; @@ -97,7 +105,7 @@ describe("Flushing a doc to Mongo", function() { return DocUpdaterClient.preloadDoc(this.project_id, this.doc_id, done); }); - after(() => MockWebApi.setDocument.restore()); + after(function() { return MockWebApi.setDocument.restore(); }); return it("should still work", function(done) { const start = Date.now(); diff --git a/services/document-updater/test/acceptance/coffee/GettingADocumentTests.js b/services/document-updater/test/acceptance/coffee/GettingADocumentTests.js index 273ee1c3f0..ad51413387 100644 --- a/services/document-updater/test/acceptance/coffee/GettingADocumentTests.js +++ b/services/document-updater/test/acceptance/coffee/GettingADocumentTests.js @@ -1,3 +1,9 @@ +/* eslint-disable + camelcase, + handle-callback-err, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. /* * decaffeinate suggestions: * DS101: Remove unnecessary use of Array.from @@ -33,7 +39,7 @@ describe("Getting a document", function() { return DocUpdaterClient.getDoc(this.project_id, this.doc_id, (error, res, returnedDoc) => { this.returnedDoc = returnedDoc; return done(); }); }); - after(() => MockWebApi.getDocument.restore()); + after(function() { return MockWebApi.getDocument.restore(); }); it("should load the document from the web API", function() { return MockWebApi.getDocument @@ -62,9 +68,9 @@ describe("Getting a document", function() { }); }); - after(() => MockWebApi.getDocument.restore()); + after(function() { return MockWebApi.getDocument.restore(); }); - it("should not load the document from the web API", () => MockWebApi.getDocument.called.should.equal(false)); + it("should not load the document from the web API", function() { return MockWebApi.getDocument.called.should.equal(false); }); return it("should return the document lines", function() { return this.returnedDoc.lines.should.deep.equal(this.lines); @@ -91,7 +97,7 @@ describe("Getting a document", function() { }); }); - after(() => MockWebApi.getDocument.restore()); + after(function() { return MockWebApi.getDocument.restore(); }); describe("when the ops are loaded", function() { before(function(done) { @@ -134,7 +140,7 @@ describe("Getting a document", function() { describe("when the web api returns an error", function() { before(function(done) { [this.project_id, this.doc_id] = Array.from([DocUpdaterClient.randomId(), DocUpdaterClient.randomId()]); - sinon.stub(MockWebApi, "getDocument", function(project_id, doc_id, callback) { + sinon.stub(MockWebApi, "getDocument", (project_id, doc_id, callback) => { if (callback == null) { callback = function(error, doc) {}; } return callback(new Error("oops")); }); @@ -144,7 +150,7 @@ describe("Getting a document", function() { }); }); - after(() => MockWebApi.getDocument.restore()); + after(function() { return MockWebApi.getDocument.restore(); }); return it("should return 500", function() { return this.statusCode.should.equal(500); @@ -155,14 +161,14 @@ describe("Getting a document", function() { before(function(done) { this.timeout = 10000; [this.project_id, this.doc_id] = Array.from([DocUpdaterClient.randomId(), DocUpdaterClient.randomId()]); - sinon.stub(MockWebApi, "getDocument", function(project_id, doc_id, callback) { + sinon.stub(MockWebApi, "getDocument", (project_id, doc_id, callback) => { if (callback == null) { callback = function(error, doc) {}; } return setTimeout(callback, 30000); }); return done(); }); - after(() => MockWebApi.getDocument.restore()); + after(function() { return MockWebApi.getDocument.restore(); }); return it("should return quickly(ish)", function(done) { const start = Date.now(); @@ -178,9 +184,9 @@ describe("Getting a document", function() { function __range__(left, right, inclusive) { - let range = []; - let ascending = left < right; - let end = !inclusive ? right : ascending ? right + 1 : right - 1; + const range = []; + const ascending = left < right; + const end = !inclusive ? right : ascending ? right + 1 : right - 1; for (let i = left; ascending ? i < end : i > end; ascending ? i++ : i--) { range.push(i); } diff --git a/services/document-updater/test/acceptance/coffee/GettingProjectDocsTests.js b/services/document-updater/test/acceptance/coffee/GettingProjectDocsTests.js index e974070468..cd5d359dd5 100644 --- a/services/document-updater/test/acceptance/coffee/GettingProjectDocsTests.js +++ b/services/document-updater/test/acceptance/coffee/GettingProjectDocsTests.js @@ -1,3 +1,9 @@ +/* eslint-disable + handle-callback-err, + no-unused-vars, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. /* * decaffeinate suggestions: * DS101: Remove unnecessary use of Array.from diff --git a/services/document-updater/test/acceptance/coffee/RangesTests.js b/services/document-updater/test/acceptance/coffee/RangesTests.js index e7ba085b04..e5daa62018 100644 --- a/services/document-updater/test/acceptance/coffee/RangesTests.js +++ b/services/document-updater/test/acceptance/coffee/RangesTests.js @@ -1,3 +1,9 @@ +/* eslint-disable + handle-callback-err, + no-unused-vars, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. /* * decaffeinate suggestions: * DS101: Remove unnecessary use of Array.from @@ -19,7 +25,7 @@ const DocUpdaterClient = require("./helpers/DocUpdaterClient"); const DocUpdaterApp = require("./helpers/DocUpdaterApp"); describe("Ranges", function() { - before(done => DocUpdaterApp.ensureRunning(done)); + before(function(done) { return DocUpdaterApp.ensureRunning(done); }); describe("tracking changes from ops", function() { before(function(done) { @@ -51,7 +57,7 @@ describe("Ranges", function() { version: 0 }); const jobs = []; - for (let update of Array.from(this.updates)) { + for (const update of Array.from(this.updates)) { (update => { return jobs.push(callback => DocUpdaterClient.sendUpdate(this.project_id, this.doc.id, update, callback)); })(update); @@ -61,7 +67,7 @@ describe("Ranges", function() { if (error != null) { throw error; } return DocUpdaterClient.preloadDoc(this.project_id, this.doc.id, error => { if (error != null) { throw error; } - return async.series(jobs, function(error) { + return async.series(jobs, (error) => { if (error != null) { throw error; } return done(); }); @@ -102,14 +108,14 @@ describe("Ranges", function() { version: 0 }); const jobs = []; - for (let update of Array.from(this.updates)) { + for (const update of Array.from(this.updates)) { (update => { return jobs.push(callback => DocUpdaterClient.sendUpdate(this.project_id, this.doc.id, update, callback)); })(update); } return DocUpdaterClient.preloadDoc(this.project_id, this.doc.id, error => { if (error != null) { throw error; } - return async.series(jobs, function(error) { + return async.series(jobs, (error) => { if (error != null) { throw error; } return setTimeout(done, 200); }); @@ -153,14 +159,14 @@ describe("Ranges", function() { version: 0 }); const jobs = []; - for (let update of Array.from(this.updates)) { + for (const update of Array.from(this.updates)) { (update => { return jobs.push(callback => DocUpdaterClient.sendUpdate(this.project_id, this.doc.id, update, callback)); })(update); } return DocUpdaterClient.preloadDoc(this.project_id, this.doc.id, error => { if (error != null) { throw error; } - return async.series(jobs, function(error) { + return async.series(jobs, (error) => { if (error != null) { throw error; } return setTimeout(done, 200); }); @@ -212,7 +218,7 @@ describe("Ranges", function() { }); return DocUpdaterClient.preloadDoc(this.project_id, this.doc.id, error => { if (error != null) { throw error; } - return DocUpdaterClient.sendUpdate(this.project_id, this.doc.id, this.update, function(error) { + return DocUpdaterClient.sendUpdate(this.project_id, this.doc.id, this.update, (error) => { if (error != null) { throw error; } return setTimeout(done, 200); }); @@ -367,14 +373,14 @@ describe("Ranges", function() { version: 0 }); const jobs = []; - for (let update of Array.from(this.updates)) { + for (const update of Array.from(this.updates)) { (update => { return jobs.push(callback => DocUpdaterClient.sendUpdate(this.project_id, this.doc.id, update, callback)); })(update); } return DocUpdaterClient.preloadDoc(this.project_id, this.doc.id, error => { if (error != null) { throw error; } - return async.series(jobs, function(error) { + return async.series(jobs, (error) => { if (error != null) { throw error; } return setTimeout(done, 200); }); @@ -423,7 +429,7 @@ describe("Ranges", function() { meta: { user_id: this.user_id } }]; const jobs = []; - for (let update of Array.from(this.updates)) { + for (const update of Array.from(this.updates)) { (update => { return jobs.push(callback => DocUpdaterClient.sendUpdate(this.project_id, this.doc_id, update, callback)); })(update); diff --git a/services/document-updater/test/acceptance/coffee/SettingADocumentTests.js b/services/document-updater/test/acceptance/coffee/SettingADocumentTests.js index 1255a0a938..61fba26f17 100644 --- a/services/document-updater/test/acceptance/coffee/SettingADocumentTests.js +++ b/services/document-updater/test/acceptance/coffee/SettingADocumentTests.js @@ -1,3 +1,10 @@ +/* eslint-disable + camelcase, + handle-callback-err, + no-return-assign, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. /* * decaffeinate suggestions: * DS101: Remove unnecessary use of Array.from @@ -182,11 +189,11 @@ describe("Setting a document", function() { return this.statusCode.should.equal(413); }); - it("should not send the updated doc lines to the web api", () => MockWebApi.setDocument.called.should.equal(false)); + it("should not send the updated doc lines to the web api", function() { return MockWebApi.setDocument.called.should.equal(false); }); - it("should not flush track changes", () => MockTrackChangesApi.flushDoc.called.should.equal(false)); + it("should not flush track changes", function() { return MockTrackChangesApi.flushDoc.called.should.equal(false); }); - return it("should not flush project history", () => MockProjectHistoryApi.flushProject.called.should.equal(false)); + return it("should not flush project history", function() { return MockProjectHistoryApi.flushProject.called.should.equal(false); }); }); describe("when the updated doc is large but under the bodyParser and HTTPController size limit", function() { diff --git a/services/document-updater/test/acceptance/coffee/helpers/DocUpdaterApp.js b/services/document-updater/test/acceptance/coffee/helpers/DocUpdaterApp.js index 985458819a..a08fd82fac 100644 --- a/services/document-updater/test/acceptance/coffee/helpers/DocUpdaterApp.js +++ b/services/document-updater/test/acceptance/coffee/helpers/DocUpdaterApp.js @@ -1,3 +1,8 @@ +/* eslint-disable + handle-callback-err, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. /* * decaffeinate suggestions: * DS101: Remove unnecessary use of Array.from diff --git a/services/document-updater/test/acceptance/coffee/helpers/DocUpdaterClient.js b/services/document-updater/test/acceptance/coffee/helpers/DocUpdaterClient.js index 09fad8c8f7..9f55291cd0 100644 --- a/services/document-updater/test/acceptance/coffee/helpers/DocUpdaterClient.js +++ b/services/document-updater/test/acceptance/coffee/helpers/DocUpdaterClient.js @@ -1,3 +1,9 @@ +/* eslint-disable + camelcase, + handle-callback-err, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. /* * decaffeinate suggestions: * DS101: Remove unnecessary use of Array.from @@ -30,10 +36,10 @@ module.exports = (DocUpdaterClient = { sendUpdate(project_id, doc_id, update, callback) { if (callback == null) { callback = function(error) {}; } - return rclient.rpush(keys.pendingUpdates({doc_id}), JSON.stringify(update), function(error){ + return rclient.rpush(keys.pendingUpdates({doc_id}), JSON.stringify(update), (error) => { if (error != null) { return callback(error); } const doc_key = `${project_id}:${doc_id}`; - return rclient.sadd("DocsWithPendingUpdates", doc_key, function(error) { + return rclient.sadd("DocsWithPendingUpdates", doc_key, (error) => { if (error != null) { return callback(error); } return rclient.rpush("pending-updates-list", doc_key, callback); }); @@ -42,10 +48,10 @@ module.exports = (DocUpdaterClient = { sendUpdates(project_id, doc_id, updates, callback) { if (callback == null) { callback = function(error) {}; } - return DocUpdaterClient.preloadDoc(project_id, doc_id, function(error) { + return DocUpdaterClient.preloadDoc(project_id, doc_id, (error) => { if (error != null) { return callback(error); } const jobs = []; - for (let update of Array.from(updates)) { + for (const update of Array.from(updates)) { ((update => jobs.push(callback => DocUpdaterClient.sendUpdate(project_id, doc_id, update, callback))))(update); } return async.series(jobs, err => DocUpdaterClient.waitForPendingUpdates(project_id, doc_id, callback)); @@ -53,7 +59,7 @@ module.exports = (DocUpdaterClient = { }, waitForPendingUpdates(project_id, doc_id, callback) { - return async.retry({times: 30, interval: 100}, cb => rclient.llen(keys.pendingUpdates({doc_id}), function(err, length) { + return async.retry({times: 30, interval: 100}, cb => rclient.llen(keys.pendingUpdates({doc_id}), (err, length) => { if (length > 0) { return cb(new Error("updates still pending")); } else { @@ -65,7 +71,7 @@ module.exports = (DocUpdaterClient = { getDoc(project_id, doc_id, callback) { if (callback == null) { callback = function(error, res, body) {}; } - return request.get(`http://localhost:3003/project/${project_id}/doc/${doc_id}`, function(error, res, body) { + return request.get(`http://localhost:3003/project/${project_id}/doc/${doc_id}`, (error, res, body) => { if ((body != null) && (res.statusCode >= 200) && (res.statusCode < 300)) { body = JSON.parse(body); } @@ -75,7 +81,7 @@ module.exports = (DocUpdaterClient = { getDocAndRecentOps(project_id, doc_id, fromVersion, callback) { if (callback == null) { callback = function(error, res, body) {}; } - return request.get(`http://localhost:3003/project/${project_id}/doc/${doc_id}?fromVersion=${fromVersion}`, function(error, res, body) { + return request.get(`http://localhost:3003/project/${project_id}/doc/${doc_id}?fromVersion=${fromVersion}`, (error, res, body) => { if ((body != null) && (res.statusCode >= 200) && (res.statusCode < 300)) { body = JSON.parse(body); } @@ -143,7 +149,7 @@ module.exports = (DocUpdaterClient = { getProjectDocs(project_id, projectStateHash, callback) { if (callback == null) { callback = function() {}; } - return request.get(`http://localhost:3003/project/${project_id}/doc?state=${projectStateHash}`, function(error, res, body) { + return request.get(`http://localhost:3003/project/${project_id}/doc?state=${projectStateHash}`, (error, res, body) => { if ((body != null) && (res.statusCode >= 200) && (res.statusCode < 300)) { body = JSON.parse(body); } @@ -161,9 +167,9 @@ module.exports = (DocUpdaterClient = { }); function __range__(left, right, inclusive) { - let range = []; - let ascending = left < right; - let end = !inclusive ? right : ascending ? right + 1 : right - 1; + const range = []; + const ascending = left < right; + const end = !inclusive ? right : ascending ? right + 1 : right - 1; for (let i = left; ascending ? i < end : i > end; ascending ? i++ : i--) { range.push(i); } diff --git a/services/document-updater/test/acceptance/coffee/helpers/MockProjectHistoryApi.js b/services/document-updater/test/acceptance/coffee/helpers/MockProjectHistoryApi.js index ba084fd108..84e2d7075c 100644 --- a/services/document-updater/test/acceptance/coffee/helpers/MockProjectHistoryApi.js +++ b/services/document-updater/test/acceptance/coffee/helpers/MockProjectHistoryApi.js @@ -1,3 +1,9 @@ +/* eslint-disable + camelcase, + handle-callback-err, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. /* * decaffeinate suggestions: * DS102: Remove unnecessary code created because of implicit returns @@ -16,7 +22,7 @@ module.exports = (MockProjectHistoryApi = { run() { app.post("/project/:project_id/flush", (req, res, next) => { - return this.flushProject(req.params.project_id, function(error) { + return this.flushProject(req.params.project_id, (error) => { if (error != null) { return res.sendStatus(500); } else { @@ -25,7 +31,7 @@ module.exports = (MockProjectHistoryApi = { }); }); - return app.listen(3054, function(error) { + return app.listen(3054, (error) => { if (error != null) { throw error; } }); } diff --git a/services/document-updater/test/acceptance/coffee/helpers/MockTrackChangesApi.js b/services/document-updater/test/acceptance/coffee/helpers/MockTrackChangesApi.js index bd217d5545..ef14b85beb 100644 --- a/services/document-updater/test/acceptance/coffee/helpers/MockTrackChangesApi.js +++ b/services/document-updater/test/acceptance/coffee/helpers/MockTrackChangesApi.js @@ -1,3 +1,9 @@ +/* eslint-disable + camelcase, + handle-callback-err, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. /* * decaffeinate suggestions: * DS102: Remove unnecessary code created because of implicit returns @@ -16,7 +22,7 @@ module.exports = (MockTrackChangesApi = { run() { app.post("/project/:project_id/doc/:doc_id/flush", (req, res, next) => { - return this.flushDoc(req.params.doc_id, function(error) { + return this.flushDoc(req.params.doc_id, (error) => { if (error != null) { return res.sendStatus(500); } else { @@ -25,9 +31,9 @@ module.exports = (MockTrackChangesApi = { }); }); - return app.listen(3015, function(error) { + return app.listen(3015, (error) => { if (error != null) { throw error; } - }).on("error", function(error) { + }).on("error", (error) => { console.error("error starting MockTrackChangesApi:", error.message); return process.exit(1); }); diff --git a/services/document-updater/test/acceptance/coffee/helpers/MockWebApi.js b/services/document-updater/test/acceptance/coffee/helpers/MockWebApi.js index 5069c20cb6..653dc3bf2a 100644 --- a/services/document-updater/test/acceptance/coffee/helpers/MockWebApi.js +++ b/services/document-updater/test/acceptance/coffee/helpers/MockWebApi.js @@ -1,3 +1,10 @@ +/* eslint-disable + camelcase, + handle-callback-err, + no-return-assign, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. /* * decaffeinate suggestions: * DS102: Remove unnecessary code created because of implicit returns @@ -41,7 +48,7 @@ module.exports = (MockWebApi = { run() { app.get("/project/:project_id/doc/:doc_id", (req, res, next) => { - return this.getDocument(req.params.project_id, req.params.doc_id, function(error, doc) { + return this.getDocument(req.params.project_id, req.params.doc_id, (error, doc) => { if (error != null) { return res.sendStatus(500); } else if (doc != null) { @@ -53,7 +60,7 @@ module.exports = (MockWebApi = { }); app.post("/project/:project_id/doc/:doc_id", bodyParser.json({limit: MAX_REQUEST_SIZE}), (req, res, next) => { - return MockWebApi.setDocument(req.params.project_id, req.params.doc_id, req.body.lines, req.body.version, req.body.ranges, req.body.lastUpdatedAt, req.body.lastUpdatedBy, function(error) { + return MockWebApi.setDocument(req.params.project_id, req.params.doc_id, req.body.lines, req.body.version, req.body.ranges, req.body.lastUpdatedAt, req.body.lastUpdatedBy, (error) => { if (error != null) { return res.sendStatus(500); } else { @@ -62,9 +69,9 @@ module.exports = (MockWebApi = { }); }); - return app.listen(3000, function(error) { + return app.listen(3000, (error) => { if (error != null) { throw error; } - }).on("error", function(error) { + }).on("error", (error) => { console.error("error starting MockWebApi:", error.message); return process.exit(1); });