mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
decaffeinate: Run post-processing cleanups on DiffGeneratorTests.coffee and 13 other files
This commit is contained in:
parent
86a9593ec0
commit
a35c69c0c8
14 changed files with 139 additions and 65 deletions
|
@ -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
|
||||
|
@ -25,52 +31,46 @@ describe("DiffGenerator", function() {
|
|||
};});
|
||||
|
||||
describe("rewindOp", function() {
|
||||
describe("rewinding an insert", () =>
|
||||
it("should undo the insert", function() {
|
||||
describe("rewinding an insert", function() { return it("should undo the insert", function() {
|
||||
const content = "hello world";
|
||||
const rewoundContent = this.DiffGenerator.rewindOp(content, { p: 6, i: "wo" });
|
||||
return rewoundContent.should.equal("hello rld");
|
||||
})
|
||||
}); }
|
||||
);
|
||||
|
||||
describe("rewinding a delete", () =>
|
||||
it("should undo the delete", function() {
|
||||
describe("rewinding a delete", function() { return it("should undo the delete", function() {
|
||||
const content = "hello rld";
|
||||
const rewoundContent = this.DiffGenerator.rewindOp(content, { p: 6, d: "wo" });
|
||||
return rewoundContent.should.equal("hello world");
|
||||
})
|
||||
}); }
|
||||
);
|
||||
|
||||
describe("with an inconsistent update", () =>
|
||||
it("should throw an error", function() {
|
||||
describe("with an inconsistent update", function() { return it("should throw an error", function() {
|
||||
const content = "hello world";
|
||||
return expect( () => {
|
||||
return this.DiffGenerator.rewindOp(content, { p: 6, i: "foo" });
|
||||
}).to.throw(this.DiffGenerator.ConsistencyError);
|
||||
})
|
||||
}); }
|
||||
);
|
||||
|
||||
return describe("with an update which is beyond the length of the content", () =>
|
||||
it("should undo the insert as if it were at the end of the content", function() {
|
||||
return describe("with an update which is beyond the length of the content", function() { return it("should undo the insert as if it were at the end of the content", function() {
|
||||
const content = "foobar";
|
||||
const rewoundContent = this.DiffGenerator.rewindOp(content, { p: 4, i: "bar" });
|
||||
return rewoundContent.should.equal("foo");
|
||||
})
|
||||
}); }
|
||||
);
|
||||
});
|
||||
|
||||
describe("rewindUpdate", () =>
|
||||
it("should rewind ops in reverse", function() {
|
||||
describe("rewindUpdate", function() { return it("should rewind ops in reverse", function() {
|
||||
const content = "aaabbbccc";
|
||||
const update =
|
||||
{op: [{ p: 3, i: "bbb" }, { p: 6, i: "ccc" }]};
|
||||
const rewoundContent = this.DiffGenerator.rewindUpdate(content, update);
|
||||
return rewoundContent.should.equal("aaa");
|
||||
})
|
||||
}); }
|
||||
);
|
||||
|
||||
describe("rewindUpdates", () =>
|
||||
it("should rewind updates in reverse", function() {
|
||||
describe("rewindUpdates", function() { return it("should rewind updates in reverse", function() {
|
||||
const content = "aaabbbccc";
|
||||
const updates = [
|
||||
{ op: [{ p: 3, i: "bbb" }] },
|
||||
|
@ -78,7 +78,7 @@ describe("DiffGenerator", function() {
|
|||
];
|
||||
const rewoundContent = this.DiffGenerator.rewindUpdates(content, updates);
|
||||
return rewoundContent.should.equal("aaa");
|
||||
})
|
||||
}); }
|
||||
);
|
||||
|
||||
describe("buildDiff", function() {
|
||||
|
@ -122,8 +122,7 @@ describe("DiffGenerator", function() {
|
|||
});
|
||||
|
||||
describe("compressDiff", function() {
|
||||
describe("with adjacent inserts with the same user_id", () =>
|
||||
it("should create one update with combined meta data and min/max timestamps", function() {
|
||||
describe("with adjacent inserts with the same user_id", function() { return it("should create one update with combined meta data and min/max timestamps", function() {
|
||||
const diff = this.DiffGenerator.compressDiff([
|
||||
{ i: "foo", meta: { start_ts: 10, end_ts: 20, user: { id: this.user_id } }},
|
||||
{ i: "bar", meta: { start_ts: 5, end_ts: 15, user: { id: this.user_id } }}
|
||||
|
@ -131,22 +130,20 @@ describe("DiffGenerator", function() {
|
|||
return expect(diff).to.deep.equal([
|
||||
{ i: "foobar", meta: { start_ts: 5, end_ts: 20, user: { id: this.user_id } }}
|
||||
]);
|
||||
})
|
||||
}); }
|
||||
);
|
||||
|
||||
describe("with adjacent inserts with different user_ids", () =>
|
||||
it("should leave the inserts unchanged", function() {
|
||||
describe("with adjacent inserts with different user_ids", function() { return it("should leave the inserts unchanged", function() {
|
||||
const input = [
|
||||
{ i: "foo", meta: { start_ts: 10, end_ts: 20, user: { id: this.user_id } }},
|
||||
{ i: "bar", meta: { start_ts: 5, end_ts: 15, user: { id: this.user_id_2 } }}
|
||||
];
|
||||
const output = this.DiffGenerator.compressDiff(input);
|
||||
return expect(output).to.deep.equal(input);
|
||||
})
|
||||
}); }
|
||||
);
|
||||
|
||||
describe("with adjacent deletes with the same user_id", () =>
|
||||
it("should create one update with combined meta data and min/max timestamps", function() {
|
||||
describe("with adjacent deletes with the same user_id", function() { return it("should create one update with combined meta data and min/max timestamps", function() {
|
||||
const diff = this.DiffGenerator.compressDiff([
|
||||
{ d: "foo", meta: { start_ts: 10, end_ts: 20, user: { id: this.user_id } }},
|
||||
{ d: "bar", meta: { start_ts: 5, end_ts: 15, user: { id: this.user_id } }}
|
||||
|
@ -154,18 +151,17 @@ describe("DiffGenerator", function() {
|
|||
return expect(diff).to.deep.equal([
|
||||
{ d: "foobar", meta: { start_ts: 5, end_ts: 20, user: { id: this.user_id } }}
|
||||
]);
|
||||
})
|
||||
}); }
|
||||
);
|
||||
|
||||
return describe("with adjacent deletes with different user_ids", () =>
|
||||
it("should leave the deletes unchanged", function() {
|
||||
return describe("with adjacent deletes with different user_ids", function() { return it("should leave the deletes unchanged", function() {
|
||||
const input = [
|
||||
{ d: "foo", meta: { start_ts: 10, end_ts: 20, user: { id: this.user_id } }},
|
||||
{ d: "bar", meta: { start_ts: 5, end_ts: 15, user: { id: this.user_id_2 } }}
|
||||
];
|
||||
const output = this.DiffGenerator.compressDiff(input);
|
||||
return expect(output).to.deep.equal(input);
|
||||
})
|
||||
}); }
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -331,8 +327,7 @@ describe("DiffGenerator", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("deleting over existing deletes", () =>
|
||||
it("should delete across multiple (u)changed and (d)deleted text parts", function() {
|
||||
describe("deleting over existing deletes", function() { return it("should delete across multiple (u)changed and (d)deleted text parts", function() {
|
||||
const diff = this.DiffGenerator.applyUpdateToDiff(
|
||||
[ { u: "foo" }, { d: "baz", meta: this.meta }, { u: "bar" } ],
|
||||
{ op: [{ p: 2, d: "ob" }], meta: this.meta }
|
||||
|
@ -344,7 +339,7 @@ describe("DiffGenerator", function() {
|
|||
{ d: "b", meta: this.meta },
|
||||
{ u: "ar" }
|
||||
]);
|
||||
})
|
||||
}); }
|
||||
);
|
||||
|
||||
describe("deleting when the text doesn't match", function() {
|
||||
|
@ -376,8 +371,7 @@ describe("DiffGenerator", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("when the last update in the existing diff is a delete", () =>
|
||||
it("should insert the new update before the delete", function() {
|
||||
describe("when the last update in the existing diff is a delete", function() { return it("should insert the new update before the delete", function() {
|
||||
const diff = this.DiffGenerator.applyUpdateToDiff(
|
||||
[ { u: "foo" }, { d: "bar", meta: this.meta } ],
|
||||
{ op: [{ p: 3, i: "baz" }], meta: this.meta }
|
||||
|
@ -387,11 +381,10 @@ describe("DiffGenerator", function() {
|
|||
{ i: "baz", meta: this.meta },
|
||||
{ d: "bar", meta: this.meta }
|
||||
]);
|
||||
})
|
||||
}); }
|
||||
);
|
||||
|
||||
return describe("when the only update in the existing diff is a delete", () =>
|
||||
it("should insert the new update after the delete", function() {
|
||||
return describe("when the only update in the existing diff is a delete", function() { return it("should insert the new update after the delete", function() {
|
||||
const diff = this.DiffGenerator.applyUpdateToDiff(
|
||||
[ { d: "bar", meta: this.meta } ],
|
||||
{ op: [{ p: 0, i: "baz" }], meta: this.meta }
|
||||
|
@ -400,7 +393,7 @@ describe("DiffGenerator", function() {
|
|||
{ d: "bar", meta: this.meta },
|
||||
{ i: "baz", meta: this.meta }
|
||||
]);
|
||||
})
|
||||
}); }
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
/* eslint-disable
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
mocha/no-nested-tests,
|
||||
no-return-assign,
|
||||
no-undef,
|
||||
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
|
||||
|
@ -95,8 +105,7 @@ describe("LockManager", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("deleteLock", () =>
|
||||
beforeEach(function() {
|
||||
describe("deleteLock", function() { return beforeEach(function() {
|
||||
beforeEach(function() {
|
||||
this.rclient.del = sinon.stub().callsArg(1);
|
||||
return this.LockManager.deleteLock(this.key, this.callback);
|
||||
|
@ -111,7 +120,7 @@ describe("LockManager", function() {
|
|||
return it("should call the callback", function() {
|
||||
return this.callback.called.should.equal(true);
|
||||
});
|
||||
})
|
||||
}); }
|
||||
);
|
||||
|
||||
describe("getLock", function() {
|
||||
|
|
|
@ -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
|
||||
|
@ -28,7 +34,7 @@ describe("MongoManager", function() {
|
|||
return this.project_id = ObjectId().toString();
|
||||
});
|
||||
|
||||
afterEach(() => tk.reset());
|
||||
afterEach(function() { return tk.reset(); });
|
||||
|
||||
describe("getLastCompressedUpdate", function() {
|
||||
beforeEach(function() {
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
/* eslint-disable
|
||||
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
|
||||
|
@ -38,7 +45,7 @@ describe("PackManager", function() {
|
|||
return this.PackManager.MAX_COUNT = 512;
|
||||
});
|
||||
|
||||
afterEach(() => tk.reset());
|
||||
afterEach(function() { return tk.reset(); });
|
||||
|
||||
describe("insertCompressedUpdates", function() {
|
||||
beforeEach(function() {
|
||||
|
@ -195,8 +202,7 @@ describe("PackManager", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("flushCompressedUpdates", () =>
|
||||
describe("when there is no previous update", function() {
|
||||
describe("flushCompressedUpdates", function() { return describe("when there is no previous update", function() {
|
||||
beforeEach(function() {
|
||||
return this.PackManager.flushCompressedUpdates(this.project_id, this.doc_id, null, this.newUpdates, true, this.callback);
|
||||
});
|
||||
|
@ -223,7 +229,7 @@ describe("PackManager", function() {
|
|||
return this.callback.called.should.equal(true);
|
||||
});
|
||||
});
|
||||
})
|
||||
}); }
|
||||
);
|
||||
|
||||
describe("when there is a recent previous update in mongo that expires", function() {
|
||||
|
@ -454,9 +460,9 @@ describe("PackManager", 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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
@ -494,8 +500,7 @@ describe("UpdateCompressor", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("noop - insert", () =>
|
||||
it("should leave them untouched", function() {
|
||||
describe("noop - insert", function() { return it("should leave them untouched", function() {
|
||||
return expect(this.UpdateCompressor.compressUpdates([{
|
||||
op: this.UpdateCompressor.NOOP,
|
||||
meta: { ts: this.ts1, user_id: this.user_id
|
||||
|
@ -518,11 +523,10 @@ describe("UpdateCompressor", function() {
|
|||
},
|
||||
v: 43
|
||||
}]);
|
||||
})
|
||||
}); }
|
||||
);
|
||||
|
||||
return describe("noop - delete", () =>
|
||||
it("should leave them untouched", function() {
|
||||
return describe("noop - delete", function() { return it("should leave them untouched", function() {
|
||||
return expect(this.UpdateCompressor.compressUpdates([{
|
||||
op: this.UpdateCompressor.NOOP,
|
||||
meta: { ts: this.ts1, user_id: this.user_id
|
||||
|
@ -545,13 +549,11 @@ describe("UpdateCompressor", function() {
|
|||
},
|
||||
v: 43
|
||||
}]);
|
||||
})
|
||||
}); }
|
||||
);
|
||||
});
|
||||
|
||||
return describe("compressRawUpdates", () =>
|
||||
describe("merging in-place with an array op", () =>
|
||||
it("should not change the existing last updates", function() {
|
||||
return describe("compressRawUpdates", function() { return describe("merging in-place with an array op", function() { return it("should not change the existing last updates", function() {
|
||||
return expect(this.UpdateCompressor.compressRawUpdates({
|
||||
op: [ {"p":1000,"d":"hello"}, {"p":1000,"i":"HELLO()"} ],
|
||||
meta: { start_ts: this.ts1, end_ts: this.ts1, user_id: this.user_id
|
||||
|
@ -574,15 +576,15 @@ describe("UpdateCompressor", function() {
|
|||
},
|
||||
v: 43
|
||||
}]);
|
||||
})
|
||||
)
|
||||
}); }
|
||||
); }
|
||||
);
|
||||
});
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -27,7 +33,7 @@ describe("UpdateTrimmer", function() {
|
|||
return this.project_id = "mock-project-id";
|
||||
});
|
||||
|
||||
afterEach(() => tk.reset());
|
||||
afterEach(function() { return tk.reset(); });
|
||||
|
||||
return describe("shouldTrimUpdates", function() {
|
||||
beforeEach(function() {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue