Przeglądaj źródła

decaffeinate: Run post-processing cleanups on DocArchiveManagerTests.coffee and 4 other files

decaffeinate 6 lat temu
rodzic
commit
6e498152fd

+ 26 - 18
services/docstore/test/unit/coffee/DocArchiveManagerTests.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:
  * decaffeinate suggestions:
  * DS101: Remove unnecessary use of Array.from
  * DS101: Remove unnecessary use of Array.from
@@ -261,7 +269,7 @@ describe("DocArchiveManager", function() {
 			this.MongoManager.getArchivedProjectDocs = sinon.stub().callsArgWith(1, null, this.archivedDocs);
 			this.MongoManager.getArchivedProjectDocs = sinon.stub().callsArgWith(1, null, this.archivedDocs);
 			this.DocArchiveManager.unarchiveDoc = sinon.stub().callsArgWith(2, null);
 			this.DocArchiveManager.unarchiveDoc = sinon.stub().callsArgWith(2, null);
 			return this.DocArchiveManager.unArchiveAllDocs(this.project_id, err=> {
 			return this.DocArchiveManager.unArchiveAllDocs(this.project_id, err=> {
-				for (let doc of Array.from(this.archivedDocs)) {
+				for (const doc of Array.from(this.archivedDocs)) {
 					this.DocArchiveManager.unarchiveDoc.calledWith(this.project_id, doc._id).should.equal(true);
 					this.DocArchiveManager.unarchiveDoc.calledWith(this.project_id, doc._id).should.equal(true);
 				}
 				}
 				should.not.exist(err);
 				should.not.exist(err);
@@ -299,7 +307,7 @@ describe("DocArchiveManager", function() {
 		it("should destroy all the docs", function(done){
 		it("should destroy all the docs", function(done){
 			this.DocArchiveManager.destroyDoc = sinon.stub().callsArgWith(2, null);
 			this.DocArchiveManager.destroyDoc = sinon.stub().callsArgWith(2, null);
 			return this.DocArchiveManager.destroyAllDocs(this.project_id, err=> {
 			return this.DocArchiveManager.destroyAllDocs(this.project_id, err=> {
-				for (let doc of Array.from(this.mixedDocs)) {
+				for (const doc of Array.from(this.mixedDocs)) {
 					this.DocArchiveManager.destroyDoc.calledWith(this.project_id, doc._id).should.equal(true);
 					this.DocArchiveManager.destroyDoc.calledWith(this.project_id, doc._id).should.equal(true);
 				}
 				}
 				should.not.exist(err);
 				should.not.exist(err);
@@ -337,7 +345,7 @@ describe("DocArchiveManager", function() {
 				return expect(err).not.to.exist;
 				return expect(err).not.to.exist;
 			});
 			});
 
 
-			for (let doc of Array.from(this.mixedDocs)) {
+			for (const doc of Array.from(this.mixedDocs)) {
 				sinon.assert.calledWith(this.MongoManager.destroyDoc, doc._id);
 				sinon.assert.calledWith(this.MongoManager.destroyDoc, doc._id);
 			}
 			}
 
 
@@ -346,14 +354,14 @@ describe("DocArchiveManager", function() {
 	});
 	});
 	
 	
 	describe("_s3DocToMongoDoc", function() {
 	describe("_s3DocToMongoDoc", function() {
-		describe("with the old schema", () => it("should return the docs lines", function(done) {
-            return this.DocArchiveManager._s3DocToMongoDoc(["doc", "lines"], function(error, doc) {
+		describe("with the old schema", function() { return it("should return the docs lines", function(done) {
+            return this.DocArchiveManager._s3DocToMongoDoc(["doc", "lines"], (error, doc) => {
                 expect(doc).to.deep.equal({
                 expect(doc).to.deep.equal({
                     lines: ["doc", "lines"]
                     lines: ["doc", "lines"]
                 });
                 });
                 return done();
                 return done();
             });
             });
-        }));
+        }); });
 		
 		
 		describe("with the new schema", function() {
 		describe("with the new schema", function() {
 			it("should return the doc lines and ranges", function(done) {
 			it("should return the doc lines and ranges", function(done) {
@@ -362,7 +370,7 @@ describe("DocArchiveManager", function() {
 					lines: ["doc", "lines"],
 					lines: ["doc", "lines"],
 					ranges: {"json": "ranges"},
 					ranges: {"json": "ranges"},
 					schema_v: 1
 					schema_v: 1
-				}, function(error, doc) {
+				}, (error, doc) => {
 					expect(doc).to.deep.equal({
 					expect(doc).to.deep.equal({
 						lines: ["doc", "lines"],
 						lines: ["doc", "lines"],
 						ranges: {"mongo": "ranges"}
 						ranges: {"mongo": "ranges"}
@@ -375,7 +383,7 @@ describe("DocArchiveManager", function() {
 				return this.DocArchiveManager._s3DocToMongoDoc({
 				return this.DocArchiveManager._s3DocToMongoDoc({
 					lines: ["doc", "lines"],
 					lines: ["doc", "lines"],
 					schema_v: 1
 					schema_v: 1
-				}, function(error, doc) {
+				}, (error, doc) => {
 					expect(doc).to.deep.equal({
 					expect(doc).to.deep.equal({
 						lines: ["doc", "lines"]
 						lines: ["doc", "lines"]
 					});
 					});
@@ -384,23 +392,23 @@ describe("DocArchiveManager", function() {
 			});
 			});
 		});
 		});
 		
 		
-		return describe("with an unrecognised schema", () => it("should return an error", function(done) {
+		return describe("with an unrecognised schema", function() { return it("should return an error", function(done) {
             return this.DocArchiveManager._s3DocToMongoDoc({
             return this.DocArchiveManager._s3DocToMongoDoc({
                 schema_v: 2
                 schema_v: 2
-            }, function(error, doc) {
+            }, (error, doc) => {
                 expect(error).to.exist;
                 expect(error).to.exist;
                 return done();
                 return done();
             });
             });
-        }));
+        }); });
 	});
 	});
 	
 	
 	return describe("_mongoDocToS3Doc", function() {
 	return describe("_mongoDocToS3Doc", function() {
-		describe("with a valid doc", () => it("should return the json version", function(done) {
+		describe("with a valid doc", function() { return it("should return the json version", function(done) {
             let doc;
             let doc;
             return this.DocArchiveManager._mongoDocToS3Doc((doc = {
             return this.DocArchiveManager._mongoDocToS3Doc((doc = {
                 lines: ["doc", "lines"],
                 lines: ["doc", "lines"],
                 ranges: { "mock": "ranges" }
                 ranges: { "mock": "ranges" }
-            }), function(err, s3_doc) {
+            }), (err, s3_doc) => {
                 expect(s3_doc).to.equal(JSON.stringify({
                 expect(s3_doc).to.equal(JSON.stringify({
                     lines: ["doc", "lines"],
                     lines: ["doc", "lines"],
                     ranges: { "mock": "ranges" },
                     ranges: { "mock": "ranges" },
@@ -409,7 +417,7 @@ describe("DocArchiveManager", function() {
                 );
                 );
                 return done();
                 return done();
             });
             });
-        }));
+        }); });
 			
 			
 		describe("with null bytes in the result", function() {
 		describe("with null bytes in the result", function() {
 			beforeEach(function() {
 			beforeEach(function() {
@@ -425,19 +433,19 @@ describe("DocArchiveManager", function() {
 				return this.DocArchiveManager._mongoDocToS3Doc({
 				return this.DocArchiveManager._mongoDocToS3Doc({
 					lines: ["doc", "lines"],
 					lines: ["doc", "lines"],
 					ranges: { "mock": "ranges" }
 					ranges: { "mock": "ranges" }
-				}, function(err, s3_doc) {
+				}, (err, s3_doc) => {
 					expect(err).to.exist;
 					expect(err).to.exist;
 					return done();
 					return done();
 				});
 				});
 			});
 			});
 		});
 		});
 		
 		
-		return describe("without doc lines", () => it("should return an error", function(done) {
-            return this.DocArchiveManager._mongoDocToS3Doc({}, function(err, s3_doc) {
+		return describe("without doc lines", function() { return it("should return an error", function(done) {
+            return this.DocArchiveManager._mongoDocToS3Doc({}, (err, s3_doc) => {
                 expect(err).to.exist;
                 expect(err).to.exist;
                 return done();
                 return done();
             });
             });
-        }));
+        }); });
 	});
 	});
 });
 });
 			
 			

+ 11 - 2
services/docstore/test/unit/coffee/DocManagerTests.js

@@ -1,3 +1,12 @@
+/* eslint-disable
+    camelcase,
+    handle-callback-err,
+    no-dupe-keys,
+    no-return-assign,
+    no-unused-vars,
+*/
+// TODO: This file was created by bulk-decaffeinate.
+// Fix any style issues and re-enable lint.
 /*
 /*
  * decaffeinate suggestions:
  * decaffeinate suggestions:
  * DS102: Remove unnecessary code created because of implicit returns
  * DS102: Remove unnecessary code created because of implicit returns
@@ -143,7 +152,7 @@ describe("DocManager", function() {
 			});
 			});
 
 
 			it("should error if inS3 is not set to true", function(done){
 			it("should error if inS3 is not set to true", function(done){
-				return this.DocManager._getDoc(this.project_id, this.doc_id, {inS3: false}, function(err){
+				return this.DocManager._getDoc(this.project_id, this.doc_id, {inS3: false}, (err) => {
 					expect(err).to.exist;
 					expect(err).to.exist;
 					return done();
 					return done();
 				});
 				});
@@ -158,7 +167,7 @@ describe("DocManager", function() {
 			});
 			});
 
 
 			return it("should not error if inS3 is set to true", function(done){
 			return it("should not error if inS3 is set to true", function(done){
-				return this.DocManager._getDoc(this.project_id, this.doc_id, {inS3: true}, function(err){
+				return this.DocManager._getDoc(this.project_id, this.doc_id, {inS3: true}, (err) => {
 					expect(err).to.not.exist;
 					expect(err).to.not.exist;
 					return done();
 					return done();
 				});
 				});

+ 8 - 2
services/docstore/test/unit/coffee/HttpControllerTests.js

@@ -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:
  * decaffeinate suggestions:
  * DS102: Remove unnecessary code created because of implicit returns
  * DS102: Remove unnecessary code created because of implicit returns
@@ -222,7 +228,7 @@ describe("HttpController", function() {
 		});
 		});
 	});
 	});
 
 
-	describe("getAllRanges", () => describe("normally", function() {
+	describe("getAllRanges", function() { return describe("normally", function() {
         beforeEach(function() {
         beforeEach(function() {
             this.req.params =
             this.req.params =
                 {project_id: this.project_id};
                 {project_id: this.project_id};
@@ -254,7 +260,7 @@ describe("HttpController", function() {
                 }])
                 }])
                 .should.equal(true);
                 .should.equal(true);
         });
         });
-    }));
+    }); });
 
 
 	describe("updateDoc", function() {
 	describe("updateDoc", function() {
 		beforeEach(function() {
 		beforeEach(function() {

+ 10 - 4
services/docstore/test/unit/coffee/MongoManagerTests.js

@@ -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:
  * decaffeinate suggestions:
  * DS102: Remove unnecessary code created because of implicit returns
  * DS102: Remove unnecessary code created because of implicit returns
@@ -111,9 +117,9 @@ describe("MongoManager", function() {
 			return this.MongoManager.upsertIntoDocCollection(this.project_id, this.doc_id, {lines: this.lines}, err=> {
 			return this.MongoManager.upsertIntoDocCollection(this.project_id, this.doc_id, {lines: this.lines}, err=> {
 				const args = this.db.docs.update.args[0];
 				const args = this.db.docs.update.args[0];
 				assert.deepEqual(args[0], {_id: ObjectId(this.doc_id)});
 				assert.deepEqual(args[0], {_id: ObjectId(this.doc_id)});
-				assert.equal(args[1]["$set"]["lines"], this.lines);
-				assert.equal(args[1]["$inc"]["rev"], 1);
-				assert.deepEqual(args[1]["$set"]["project_id"], ObjectId(this.project_id));
+				assert.equal(args[1].$set.lines, this.lines);
+				assert.equal(args[1].$inc.rev, 1);
+				assert.deepEqual(args[1].$set.project_id, ObjectId(this.project_id));
 				return done();
 				return done();
 			});
 			});
 		});
 		});
@@ -136,7 +142,7 @@ describe("MongoManager", function() {
 			return this.MongoManager.markDocAsDeleted(this.project_id, this.doc_id, err=> {
 			return this.MongoManager.markDocAsDeleted(this.project_id, this.doc_id, err=> {
 				const args = this.db.docs.update.args[0];
 				const args = this.db.docs.update.args[0];
 				assert.deepEqual(args[0], {_id: ObjectId(this.doc_id), project_id: ObjectId(this.project_id)});
 				assert.deepEqual(args[0], {_id: ObjectId(this.doc_id), project_id: ObjectId(this.project_id)});
-				assert.equal(args[1]["$set"]["deleted"], true);
+				assert.equal(args[1].$set.deleted, true);
 				return done();
 				return done();
 			});
 			});
 		});
 		});

+ 13 - 6
services/docstore/test/unit/coffee/RangeManagerTests.js

@@ -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:
  * decaffeinate suggestions:
  * DS102: Remove unnecessary code created because of implicit returns
  * DS102: Remove unnecessary code created because of implicit returns
@@ -137,20 +144,20 @@ describe("RangeManager", function() {
 			return this.ranges_copy = this.RangeManager.jsonRangesToMongo(JSON.parse(JSON.stringify(this.ranges)));
 			return this.ranges_copy = this.RangeManager.jsonRangesToMongo(JSON.parse(JSON.stringify(this.ranges)));
 		});
 		});
 
 
-		describe("with a blank new range", () => it("should throw an error", function() {
+		describe("with a blank new range", function() { return it("should throw an error", function() {
             return expect(() => {
             return expect(() => {
                 return this.RangeManager.shouldUpdateRanges(this.ranges, null);
                 return this.RangeManager.shouldUpdateRanges(this.ranges, null);
             }).to.throw(Error);
             }).to.throw(Error);
-        }));
+        }); });
 		
 		
-		describe("with a blank old range", () => it("should treat it like {}", function() {
+		describe("with a blank old range", function() { return it("should treat it like {}", function() {
             this.RangeManager.shouldUpdateRanges(null, {}).should.equal(false);
             this.RangeManager.shouldUpdateRanges(null, {}).should.equal(false);
             return this.RangeManager.shouldUpdateRanges(null, this.ranges).should.equal(true);
             return this.RangeManager.shouldUpdateRanges(null, this.ranges).should.equal(true);
-        }));
+        }); });
 		
 		
-		describe("with no changes", () => it("should return false", function() {
+		describe("with no changes", function() { return it("should return false", function() {
             return this.RangeManager.shouldUpdateRanges(this.ranges, this.ranges_copy).should.equal(false);
             return this.RangeManager.shouldUpdateRanges(this.ranges, this.ranges_copy).should.equal(false);
-        }));
+        }); });
 		
 		
 		return describe("with changes", function() {
 		return describe("with changes", function() {
 			it("should return true when the change id changes", function() {
 			it("should return true when the change id changes", function() {