decaffeinate: Run post-processing cleanups on DiffCodecTests.coffee and 23 other files

This commit is contained in:
decaffeinate 2020-05-06 12:11:22 +02:00 committed by Tim Alby
parent c781526af0
commit 21850f1e6f
24 changed files with 207 additions and 44 deletions

View file

@ -1,3 +1,10 @@
/* eslint-disable
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:
* DS102: Remove unnecessary code created because of implicit returns
@ -22,7 +29,7 @@ describe("DiffCodec", function() {
it("should insert new text correctly", function(done) {
this.before = ["hello world"];
this.after = ["hello beautiful world"];
return this.DiffCodec.diffAsShareJsOp(this.before, this.after, function(error, ops) {
return this.DiffCodec.diffAsShareJsOp(this.before, this.after, (error, ops) => {
expect(ops).to.deep.equal([{
i: "beautiful ",
p: 6
@ -35,7 +42,7 @@ describe("DiffCodec", function() {
it("should shift later inserts by previous inserts", function(done) {
this.before = ["the boy played with the ball"];
this.after = ["the tall boy played with the red ball"];
return this.DiffCodec.diffAsShareJsOp(this.before, this.after, function(error, ops) {
return this.DiffCodec.diffAsShareJsOp(this.before, this.after, (error, ops) => {
expect(ops).to.deep.equal([
{ i: "tall ", p: 4 },
{ i: "red ", p: 29 }
@ -47,7 +54,7 @@ describe("DiffCodec", function() {
it("should delete text correctly", function(done) {
this.before = ["hello beautiful world"];
this.after = ["hello world"];
return this.DiffCodec.diffAsShareJsOp(this.before, this.after, function(error, ops) {
return this.DiffCodec.diffAsShareJsOp(this.before, this.after, (error, ops) => {
expect(ops).to.deep.equal([{
d: "beautiful ",
p: 6
@ -61,7 +68,7 @@ describe("DiffCodec", function() {
return it("should shift later deletes by the first deletes", function(done) {
this.before = ["the tall boy played with the red ball"];
this.after = ["the boy played with the ball"];
return this.DiffCodec.diffAsShareJsOp(this.before, this.after, function(error, ops) {
return this.DiffCodec.diffAsShareJsOp(this.before, this.after, (error, ops) => {
expect(ops).to.deep.equal([
{ d: "tall ", p: 4 },
{ d: "red ", p: 24 }

View file

@ -1,3 +1,10 @@
/* eslint-disable
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:
* DS102: Remove unnecessary code created because of implicit returns
@ -115,7 +122,7 @@ describe("DispatchManager", function() {
});
});
return describe("run", () => it("should call _waitForUpdateThenDispatchWorker until shutting down", function(done) {
return describe("run", function() { return it("should call _waitForUpdateThenDispatchWorker until shutting down", function(done) {
let callCount = 0;
this.worker._waitForUpdateThenDispatchWorker = callback => {
if (callback == null) { callback = function(error) {}; }
@ -134,7 +141,7 @@ describe("DispatchManager", function() {
var checkStatus = () => {
if (!this.settings.shuttingDown) { // retry until shutdown
setTimeout(checkStatus, 100);
return;
} else {
this.worker._waitForUpdateThenDispatchWorker.callCount.should.equal(3);
return done();
@ -142,6 +149,6 @@ describe("DispatchManager", function() {
};
return checkStatus();
}));
}); });
});
});

View file

@ -1,3 +1,9 @@
/* eslint-disable
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
@ -60,7 +66,7 @@ describe("DocumentManager", function() {
return this.lastUpdatedBy = 'last-author-id';
});
afterEach(() => tk.reset());
afterEach(function() { return tk.reset(); });
describe("flushAndDeleteDoc", function() {
describe("successfully", function() {
@ -111,7 +117,7 @@ describe("DocumentManager", function() {
});
});
return describe("when ignoring flush errors", () => it("should remove the doc from redis", function(done) {
return describe("when ignoring flush errors", function() { return it("should remove the doc from redis", function(done) {
return this.DocumentManager.flushAndDeleteDoc(this.project_id, this.doc_id, { ignoreFlushErrors: true }, error => {
if (error != null) {
return done(error);
@ -119,7 +125,7 @@ describe("DocumentManager", function() {
this.RedisManager.removeDocFromMemory.called.should.equal(true);
return done();
});
}));
}); });
});
});
@ -303,7 +309,7 @@ describe("DocumentManager", function() {
});
});
describe("setDoc", () => describe("with plain tex lines", function() {
describe("setDoc", function() { return describe("with plain tex lines", function() {
beforeEach(function() {
this.beforeLines = ["before", "lines"];
this.afterLines = ["after", "lines"];
@ -417,7 +423,7 @@ describe("DocumentManager", function() {
op.u.should.equal(true));
});
});
}));
}); });
describe("acceptChanges", function() {
beforeEach(function() {

View file

@ -1,3 +1,9 @@
/* eslint-disable
mocha/no-nested-tests,
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

View file

@ -1,3 +1,10 @@
/* eslint-disable
camelcase,
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

View file

@ -1,3 +1,9 @@
/* eslint-disable
no-return-assign,
no-unused-vars,
*/
// 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

View file

@ -1,3 +1,10 @@
/* eslint-disable
camelcase,
handle-callback-err,
no-unused-vars,
*/
// 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
@ -46,7 +53,7 @@ describe('LockManager - checking the lock', function(){
it('should return true if the key does not exists', function(done){
existsStub.yields(null, "0");
return LockManager.checkLock(doc_id, function(err, free){
return LockManager.checkLock(doc_id, (err, free) => {
free.should.equal(true);
return done();
});
@ -54,7 +61,7 @@ describe('LockManager - checking the lock', function(){
return it('should return false if the key does exists', function(done){
existsStub.yields(null, "1");
return LockManager.checkLock(doc_id, function(err, free){
return LockManager.checkLock(doc_id, (err, free) => {
free.should.equal(false);
return done();
});

View file

@ -1,3 +1,10 @@
/* eslint-disable
camelcase,
no-return-assign,
no-unused-vars,
*/
// 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

View file

@ -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

View file

@ -1,3 +1,10 @@
/* eslint-disable
camelcase,
no-return-assign,
no-unused-vars,
*/
// 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

View file

@ -1,3 +1,9 @@
/* eslint-disable
no-return-assign,
no-unused-vars,
*/
// 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

View file

@ -1,3 +1,10 @@
/* eslint-disable
camelcase,
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
@ -46,7 +53,7 @@ describe("ProjectHistoryRedisManager", function() {
);
});
afterEach(() => tk.reset());
afterEach(function() { return tk.reset(); });
describe("queueOps", function() {
beforeEach(function() {
@ -145,8 +152,8 @@ describe("ProjectHistoryRedisManager", function() {
.should.equal(true);
});
describe("queueResyncProjectStructure", () => it("should queue an update", function() {}));
describe("queueResyncProjectStructure", function() { return it("should queue an update", function() {}); });
return describe("queueResyncDocContent", () => it("should queue an update", function() {}));
return describe("queueResyncDocContent", function() { return it("should queue an update", function() {}); });
});
});

View file

@ -1,3 +1,10 @@
/* eslint-disable
camelcase,
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

View file

@ -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

View file

@ -1,3 +1,9 @@
/* eslint-disable
no-return-assign,
no-unused-vars,
*/
// 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

View file

@ -1,3 +1,9 @@
/* eslint-disable
no-return-assign,
no-unused-vars,
*/
// 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

View file

@ -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

View file

@ -1,3 +1,9 @@
/* eslint-disable
no-return-assign,
no-unused-vars,
*/
// 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

View file

@ -1,3 +1,10 @@
/* eslint-disable
camelcase,
no-return-assign,
no-unused-vars,
*/
// 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

View file

@ -1,3 +1,11 @@
/* eslint-disable
camelcase,
mocha/no-identical-title,
no-return-assign,
no-unused-vars,
*/
// 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
@ -66,6 +74,7 @@ describe("RedisManager", function() {
constructor() {
this.start = new Date();
}
done() {
const timeSpan = new Date - this.start;
return timeSpan;
@ -86,7 +95,7 @@ describe("RedisManager", function() {
return this.callback = sinon.stub();
});
afterEach(() => tk.reset());
afterEach(function() { return tk.reset(); });
describe("getDoc", function() {
beforeEach(function() {

View file

@ -1,3 +1,10 @@
/* eslint-disable
camelcase,
mocha/no-identical-title,
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
@ -218,38 +225,38 @@ describe("ShareJS text type", function() {
});
});
describe("comment / insert", () => it("should not do anything", function() {
describe("comment / insert", function() { return it("should not do anything", function() {
const dest = [];
text._tc(dest, { i: "foo", p: 6 }, { c: "bar", p: 3 });
return dest.should.deep.equal([{ i: "foo", p: 6 }]);
}));
}); });
describe("comment / delete", () => it("should not do anything", function() {
describe("comment / delete", function() { return it("should not do anything", function() {
const dest = [];
text._tc(dest, { d: "foo", p: 6 }, { c: "bar", p: 3 });
return dest.should.deep.equal([{ d: "foo", p: 6 }]);
}));
}); });
return describe("comment / comment", () => it("should not do anything", function() {
return describe("comment / comment", function() { return it("should not do anything", function() {
const dest = [];
text._tc(dest, { c: "foo", p: 6 }, { c: "bar", p: 3 });
return dest.should.deep.equal([{ c: "foo", p: 6 }]);
}));
}); });
});
describe("apply", function() {
it("should apply an insert", () => text.apply("foo", [{ i: "bar", p: 2 }]).should.equal("fobaro"));
it("should apply an insert", function() { return text.apply("foo", [{ i: "bar", p: 2 }]).should.equal("fobaro"); });
it("should apply a delete", () => text.apply("foo123bar", [{ d: "123", p: 3 }]).should.equal("foobar"));
it("should apply a delete", function() { return text.apply("foo123bar", [{ d: "123", p: 3 }]).should.equal("foobar"); });
it("should do nothing with a comment", () => text.apply("foo123bar", [{ c: "123", p: 3 }]).should.equal("foo123bar"));
it("should do nothing with a comment", function() { return text.apply("foo123bar", [{ c: "123", p: 3 }]).should.equal("foo123bar"); });
it("should throw an error when deleted content does not match", () => ((() => text.apply("foo123bar", [{ d: "456", p: 3 }]))).should.throw(Error));
it("should throw an error when deleted content does not match", function() { return ((() => text.apply("foo123bar", [{ d: "456", p: 3 }]))).should.throw(Error); });
return it("should throw an error when comment content does not match", () => ((() => text.apply("foo123bar", [{ c: "456", p: 3 }]))).should.throw(Error));
return it("should throw an error when comment content does not match", function() { return ((() => text.apply("foo123bar", [{ c: "456", p: 3 }]))).should.throw(Error); });
});
return describe("applying ops and comments in different orders", () => it("should not matter which op or comment is applied first", function() {
return describe("applying ops and comments in different orders", function() { return it("should not matter which op or comment is applied first", function() {
let length, p;
let asc, end;
let asc1, end1;
@ -263,7 +270,7 @@ describe("ShareJS text type", function() {
const applySnapshot = (snapshot, op) => text.apply(snapshot, op);
const applyRanges = function(rangesTracker, ops) {
for (let op of Array.from(ops)) {
for (const op of Array.from(ops)) {
rangesTracker.applyOp(op, {});
}
return rangesTracker;
@ -271,14 +278,14 @@ describe("ShareJS text type", function() {
const commentsEqual = function(comments1, comments2) {
if (comments1.length !== comments2.length) { return false; }
comments1.sort(function(a,b) {
comments1.sort((a,b) => {
if ((a.offset - b.offset) === 0) {
return a.length - b.length;
} else {
return a.offset - b.offset;
}
});
comments2.sort(function(a,b) {
comments2.sort((a,b) => {
if ((a.offset - b.offset) === 0) {
return a.length - b.length;
} else {
@ -299,19 +306,19 @@ describe("ShareJS text type", function() {
const OPS = [];
// Insert ops
for (p = 0, end = SNAPSHOT.length, asc = 0 <= end; asc ? p <= end : p >= end; asc ? p++ : p--) {
for (p = 0, end = SNAPSHOT.length, asc = end >= 0; asc ? p <= end : p >= end; asc ? p++ : p--) {
OPS.push({i: "a", p});
OPS.push({i: "bc", p});
}
for (p = 0, end1 = SNAPSHOT.length-1, asc1 = 0 <= end1; asc1 ? p <= end1 : p >= end1; asc1 ? p++ : p--) {
for (p = 0, end1 = SNAPSHOT.length-1, asc1 = end1 >= 0; asc1 ? p <= end1 : p >= end1; asc1 ? p++ : p--) {
var asc2, end2;
for (length = 1, end2 = SNAPSHOT.length - p, asc2 = 1 <= end2; asc2 ? length <= end2 : length >= end2; asc2 ? length++ : length--) {
for (length = 1, end2 = SNAPSHOT.length - p, asc2 = end2 >= 1; asc2 ? length <= end2 : length >= end2; asc2 ? length++ : length--) {
OPS.push({d: SNAPSHOT.slice(p, p+length), p});
}
}
for (p = 0, end3 = SNAPSHOT.length-1, asc3 = 0 <= end3; asc3 ? p <= end3 : p >= end3; asc3 ? p++ : p--) {
for (p = 0, end3 = SNAPSHOT.length-1, asc3 = end3 >= 0; asc3 ? p <= end3 : p >= end3; asc3 ? p++ : p--) {
var asc4, end4;
for (length = 1, end4 = SNAPSHOT.length - p, asc4 = 1 <= end4; asc4 ? length <= end4 : length >= end4; asc4 ? length++ : length--) {
for (length = 1, end4 = SNAPSHOT.length - p, asc4 = end4 >= 1; asc4 ? length <= end4 : length >= end4; asc4 ? length++ : length--) {
OPS.push({c: SNAPSHOT.slice(p, p+length), p, t: this.t});
}
}
@ -321,7 +328,7 @@ describe("ShareJS text type", function() {
for (var op1 of Array.from(OPS)) {
result.push((() => {
const result1 = [];
for (let op2 of Array.from(OPS)) {
for (const op2 of Array.from(OPS)) {
const op1_t = transform(op1, op2, "left");
const op2_t = transform(op2, op1, "right");
@ -354,5 +361,5 @@ describe("ShareJS text type", function() {
}
return result;
})();
}));
}); });
});

View file

@ -1,3 +1,9 @@
/* eslint-disable
no-return-assign,
no-unused-vars,
*/
// 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
@ -107,7 +113,7 @@ describe("ShareJsDB", function() {
});
});
return describe("writeOps", () => describe("writing an op", function() {
return describe("writeOps", function() { return describe("writing an op", function() {
beforeEach(function() {
this.opData = {
op: {p: 20, t: "foo"},
@ -125,5 +131,5 @@ describe("ShareJsDB", function() {
this.callback.called.should.equal(true);
return (this.callback.args[0][0] != null).should.equal(false);
});
}));
}); });
});

View file

@ -1,3 +1,9 @@
/* eslint-disable
no-return-assign,
no-unused-vars,
*/
// 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

View file

@ -1,3 +1,9 @@
/* eslint-disable
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
@ -350,7 +356,7 @@ describe("UpdateManager", function() {
});
describe("_addProjectHistoryMetadataToOps", () => it("should add projectHistoryId, pathname and doc_length metadata to the ops", function() {
describe("_addProjectHistoryMetadataToOps", function() { return it("should add projectHistoryId, pathname and doc_length metadata to the ops", function() {
const lines = [
'some',
'test',
@ -387,7 +393,7 @@ describe("UpdateManager", function() {
doc_length: 23
} // 14 - 'qux' + 'bazbaz'
}]);
}));
}); });
return describe("lockUpdatesAndDo", function() {
beforeEach(function() {