|
|
@@ -1,23 +1,6 @@
|
|
|
-/* eslint-disable
|
|
|
- max-len,
|
|
|
- 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
|
|
|
- * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
- */
|
|
|
-const should = require('chai').should()
|
|
|
-const spies = require('chai-spies')
|
|
|
-const chai = require('chai').use(spies)
|
|
|
const sinon = require('sinon')
|
|
|
const SandboxedModule = require('sandboxed-module')
|
|
|
-const { assert } = require('chai')
|
|
|
const path = require('path')
|
|
|
-const _ = require('underscore')
|
|
|
const { ObjectId } = require('mongojs')
|
|
|
const modulePath = path.join(
|
|
|
__dirname,
|
|
|
@@ -48,7 +31,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
}
|
|
|
|
|
|
this.callback = sinon.stub()
|
|
|
- return (this.handler = SandboxedModule.require(modulePath, {
|
|
|
+ this.handler = SandboxedModule.require(modulePath, {
|
|
|
globals: {
|
|
|
console: console
|
|
|
},
|
|
|
@@ -71,18 +54,18 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }))
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
describe('flushProjectToMongo', function() {
|
|
|
describe('successfully', function() {
|
|
|
beforeEach(function() {
|
|
|
this.request.callsArgWith(1, null, { statusCode: 204 }, '')
|
|
|
- return this.handler.flushProjectToMongo(this.project_id, this.callback)
|
|
|
+ this.handler.flushProjectToMongo(this.project_id, this.callback)
|
|
|
})
|
|
|
|
|
|
it('should flush the document from the document updater', function() {
|
|
|
- return this.request
|
|
|
+ this.request
|
|
|
.calledWithMatch({
|
|
|
url: `${this.settings.apis.documentupdater.url}/project/${
|
|
|
this.project_id
|
|
|
@@ -93,7 +76,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should call the callback with no error', function() {
|
|
|
- return this.callback.calledWith(null).should.equal(true)
|
|
|
+ this.callback.calledWith(null).should.equal(true)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
@@ -105,22 +88,22 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
null,
|
|
|
null
|
|
|
)
|
|
|
- return this.handler.flushProjectToMongo(this.project_id, this.callback)
|
|
|
+ this.handler.flushProjectToMongo(this.project_id, this.callback)
|
|
|
})
|
|
|
|
|
|
it('should return an error to the callback', function() {
|
|
|
- return this.callback.calledWith(this.error).should.equal(true)
|
|
|
+ this.callback.calledWith(this.error).should.equal(true)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
describe('when the document updater returns a failure error code', function() {
|
|
|
beforeEach(function() {
|
|
|
this.request.callsArgWith(1, null, { statusCode: 500 }, '')
|
|
|
- return this.handler.flushProjectToMongo(this.project_id, this.callback)
|
|
|
+ this.handler.flushProjectToMongo(this.project_id, this.callback)
|
|
|
})
|
|
|
|
|
|
it('should return the callback with an error', function() {
|
|
|
- return this.callback
|
|
|
+ this.callback
|
|
|
.calledWith(
|
|
|
new Error('doc updater returned failure status code: 500')
|
|
|
)
|
|
|
@@ -133,14 +116,14 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
describe('successfully', function() {
|
|
|
beforeEach(function() {
|
|
|
this.request.callsArgWith(1, null, { statusCode: 204 }, '')
|
|
|
- return this.handler.flushProjectToMongoAndDelete(
|
|
|
+ this.handler.flushProjectToMongoAndDelete(
|
|
|
this.project_id,
|
|
|
this.callback
|
|
|
)
|
|
|
})
|
|
|
|
|
|
it('should delete the project from the document updater', function() {
|
|
|
- return this.request
|
|
|
+ this.request
|
|
|
.calledWithMatch({
|
|
|
url: `${this.settings.apis.documentupdater.url}/project/${
|
|
|
this.project_id
|
|
|
@@ -151,7 +134,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should call the callback with no error', function() {
|
|
|
- return this.callback.calledWith(null).should.equal(true)
|
|
|
+ this.callback.calledWith(null).should.equal(true)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
@@ -163,28 +146,28 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
null,
|
|
|
null
|
|
|
)
|
|
|
- return this.handler.flushProjectToMongoAndDelete(
|
|
|
+ this.handler.flushProjectToMongoAndDelete(
|
|
|
this.project_id,
|
|
|
this.callback
|
|
|
)
|
|
|
})
|
|
|
|
|
|
it('should return an error to the callback', function() {
|
|
|
- return this.callback.calledWith(this.error).should.equal(true)
|
|
|
+ this.callback.calledWith(this.error).should.equal(true)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
describe('when the document updater returns a failure error code', function() {
|
|
|
beforeEach(function() {
|
|
|
this.request.callsArgWith(1, null, { statusCode: 500 }, '')
|
|
|
- return this.handler.flushProjectToMongoAndDelete(
|
|
|
+ this.handler.flushProjectToMongoAndDelete(
|
|
|
this.project_id,
|
|
|
this.callback
|
|
|
)
|
|
|
})
|
|
|
|
|
|
it('should return the callback with an error', function() {
|
|
|
- return this.callback
|
|
|
+ this.callback
|
|
|
.calledWith(
|
|
|
new Error('doc updater returned failure status code: 500')
|
|
|
)
|
|
|
@@ -197,7 +180,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
describe('successfully', function() {
|
|
|
beforeEach(function() {
|
|
|
this.request.callsArgWith(1, null, { statusCode: 204 }, '')
|
|
|
- return this.handler.flushDocToMongo(
|
|
|
+ this.handler.flushDocToMongo(
|
|
|
this.project_id,
|
|
|
this.doc_id,
|
|
|
this.callback
|
|
|
@@ -205,7 +188,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should flush the document from the document updater', function() {
|
|
|
- return this.request
|
|
|
+ this.request
|
|
|
.calledWithMatch({
|
|
|
url: `${this.settings.apis.documentupdater.url}/project/${
|
|
|
this.project_id
|
|
|
@@ -216,7 +199,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should call the callback with no error', function() {
|
|
|
- return this.callback.calledWith(null).should.equal(true)
|
|
|
+ this.callback.calledWith(null).should.equal(true)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
@@ -228,7 +211,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
null,
|
|
|
null
|
|
|
)
|
|
|
- return this.handler.flushDocToMongo(
|
|
|
+ this.handler.flushDocToMongo(
|
|
|
this.project_id,
|
|
|
this.doc_id,
|
|
|
this.callback
|
|
|
@@ -236,14 +219,14 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should return an error to the callback', function() {
|
|
|
- return this.callback.calledWith(this.error).should.equal(true)
|
|
|
+ this.callback.calledWith(this.error).should.equal(true)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
describe('when the document updater returns a failure error code', function() {
|
|
|
beforeEach(function() {
|
|
|
this.request.callsArgWith(1, null, { statusCode: 500 }, '')
|
|
|
- return this.handler.flushDocToMongo(
|
|
|
+ this.handler.flushDocToMongo(
|
|
|
this.project_id,
|
|
|
this.doc_id,
|
|
|
this.callback
|
|
|
@@ -251,7 +234,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should return the callback with an error', function() {
|
|
|
- return this.callback
|
|
|
+ this.callback
|
|
|
.calledWith(
|
|
|
new Error('doc updater returned failure status code: 500')
|
|
|
)
|
|
|
@@ -264,15 +247,11 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
describe('successfully', function() {
|
|
|
beforeEach(function() {
|
|
|
this.request.callsArgWith(1, null, { statusCode: 204 }, '')
|
|
|
- return this.handler.deleteDoc(
|
|
|
- this.project_id,
|
|
|
- this.doc_id,
|
|
|
- this.callback
|
|
|
- )
|
|
|
+ this.handler.deleteDoc(this.project_id, this.doc_id, this.callback)
|
|
|
})
|
|
|
|
|
|
it('should delete the document from the document updater', function() {
|
|
|
- return this.request
|
|
|
+ this.request
|
|
|
.calledWithMatch({
|
|
|
url: `${this.settings.apis.documentupdater.url}/project/${
|
|
|
this.project_id
|
|
|
@@ -283,7 +262,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should call the callback with no error', function() {
|
|
|
- return this.callback.calledWith(null).should.equal(true)
|
|
|
+ this.callback.calledWith(null).should.equal(true)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
@@ -295,30 +274,22 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
null,
|
|
|
null
|
|
|
)
|
|
|
- return this.handler.deleteDoc(
|
|
|
- this.project_id,
|
|
|
- this.doc_id,
|
|
|
- this.callback
|
|
|
- )
|
|
|
+ this.handler.deleteDoc(this.project_id, this.doc_id, this.callback)
|
|
|
})
|
|
|
|
|
|
it('should return an error to the callback', function() {
|
|
|
- return this.callback.calledWith(this.error).should.equal(true)
|
|
|
+ this.callback.calledWith(this.error).should.equal(true)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
describe('when the document updater returns a failure error code', function() {
|
|
|
beforeEach(function() {
|
|
|
this.request.callsArgWith(1, null, { statusCode: 500 }, '')
|
|
|
- return this.handler.deleteDoc(
|
|
|
- this.project_id,
|
|
|
- this.doc_id,
|
|
|
- this.callback
|
|
|
- )
|
|
|
+ this.handler.deleteDoc(this.project_id, this.doc_id, this.callback)
|
|
|
})
|
|
|
|
|
|
it('should return the callback with an error', function() {
|
|
|
- return this.callback
|
|
|
+ this.callback
|
|
|
.calledWith(
|
|
|
new Error('doc updater returned failure status code: 500')
|
|
|
)
|
|
|
@@ -329,13 +300,13 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
|
|
|
describe('setDocument', function() {
|
|
|
beforeEach(function() {
|
|
|
- return (this.source = 'dropbox')
|
|
|
+ this.source = 'dropbox'
|
|
|
})
|
|
|
|
|
|
describe('successfully', function() {
|
|
|
beforeEach(function() {
|
|
|
this.request.callsArgWith(1, null, { statusCode: 204 }, '')
|
|
|
- return this.handler.setDocument(
|
|
|
+ this.handler.setDocument(
|
|
|
this.project_id,
|
|
|
this.doc_id,
|
|
|
this.user_id,
|
|
|
@@ -346,7 +317,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should set the document in the document updater', function() {
|
|
|
- return this.request
|
|
|
+ this.request
|
|
|
.calledWith({
|
|
|
url: `${this.settings.apis.documentupdater.url}/project/${
|
|
|
this.project_id
|
|
|
@@ -362,7 +333,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should call the callback with no error', function() {
|
|
|
- return this.callback.calledWith(null).should.equal(true)
|
|
|
+ this.callback.calledWith(null).should.equal(true)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
@@ -374,7 +345,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
null,
|
|
|
null
|
|
|
)
|
|
|
- return this.handler.setDocument(
|
|
|
+ this.handler.setDocument(
|
|
|
this.project_id,
|
|
|
this.doc_id,
|
|
|
this.user_id,
|
|
|
@@ -385,14 +356,14 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should return an error to the callback', function() {
|
|
|
- return this.callback.calledWith(this.error).should.equal(true)
|
|
|
+ this.callback.calledWith(this.error).should.equal(true)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
describe('when the document updater returns a failure error code', function() {
|
|
|
beforeEach(function() {
|
|
|
this.request.callsArgWith(1, null, { statusCode: 500 }, '')
|
|
|
- return this.handler.setDocument(
|
|
|
+ this.handler.setDocument(
|
|
|
this.project_id,
|
|
|
this.doc_id,
|
|
|
this.user_id,
|
|
|
@@ -403,7 +374,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should return the callback with an error', function() {
|
|
|
- return this.callback
|
|
|
+ this.callback
|
|
|
.calledWith(
|
|
|
new Error('doc updater returned failure status code: 500')
|
|
|
)
|
|
|
@@ -423,7 +394,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
}
|
|
|
this.fromVersion = 2
|
|
|
this.request.callsArgWith(1, null, { statusCode: 200 }, this.body)
|
|
|
- return this.handler.getDocument(
|
|
|
+ this.handler.getDocument(
|
|
|
this.project_id,
|
|
|
this.doc_id,
|
|
|
this.fromVersion,
|
|
|
@@ -432,7 +403,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should get the document from the document updater', function() {
|
|
|
- return this.request
|
|
|
+ this.request
|
|
|
.calledWith({
|
|
|
url: `${this.settings.apis.documentupdater.url}/project/${
|
|
|
this.project_id
|
|
|
@@ -444,7 +415,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should call the callback with the lines and version', function() {
|
|
|
- return this.callback
|
|
|
+ this.callback
|
|
|
.calledWith(null, this.lines, this.version, this.ranges, this.ops)
|
|
|
.should.equal(true)
|
|
|
})
|
|
|
@@ -458,7 +429,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
null,
|
|
|
null
|
|
|
)
|
|
|
- return this.handler.getDocument(
|
|
|
+ this.handler.getDocument(
|
|
|
this.project_id,
|
|
|
this.doc_id,
|
|
|
this.fromVersion,
|
|
|
@@ -467,14 +438,14 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should return an error to the callback', function() {
|
|
|
- return this.callback.calledWith(this.error).should.equal(true)
|
|
|
+ this.callback.calledWith(this.error).should.equal(true)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
describe('when the document updater returns a failure error code', function() {
|
|
|
beforeEach(function() {
|
|
|
this.request.callsArgWith(1, null, { statusCode: 500 }, '')
|
|
|
- return this.handler.getDocument(
|
|
|
+ this.handler.getDocument(
|
|
|
this.project_id,
|
|
|
this.doc_id,
|
|
|
this.fromVersion,
|
|
|
@@ -483,7 +454,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should return the callback with an error', function() {
|
|
|
- return this.callback
|
|
|
+ this.callback
|
|
|
.calledWith(
|
|
|
new Error('doc updater returned failure status code: 500')
|
|
|
)
|
|
|
@@ -494,7 +465,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
|
|
|
describe('getProjectDocsIfMatch', function() {
|
|
|
beforeEach(function() {
|
|
|
- return (this.project_state_hash = '1234567890abcdef')
|
|
|
+ this.project_state_hash = '1234567890abcdef'
|
|
|
})
|
|
|
|
|
|
describe('successfully', function() {
|
|
|
@@ -509,7 +480,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
this.request.post = sinon
|
|
|
.stub()
|
|
|
.callsArgWith(1, null, { statusCode: 200 }, this.body)
|
|
|
- return this.handler.getProjectDocsIfMatch(
|
|
|
+ this.handler.getProjectDocsIfMatch(
|
|
|
this.project_id,
|
|
|
this.project_state_hash,
|
|
|
this.callback
|
|
|
@@ -520,13 +491,11 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
const url = `${this.settings.apis.documentupdater.url}/project/${
|
|
|
this.project_id
|
|
|
}/get_and_flush_if_old?state=${this.project_state_hash}`
|
|
|
- return this.request.post.calledWith(url).should.equal(true)
|
|
|
+ this.request.post.calledWith(url).should.equal(true)
|
|
|
})
|
|
|
|
|
|
it('should call the callback with the documents', function() {
|
|
|
- return this.callback
|
|
|
- .calledWithExactly(null, this.docs)
|
|
|
- .should.equal(true)
|
|
|
+ this.callback.calledWithExactly(null, this.docs).should.equal(true)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
@@ -540,7 +509,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
null,
|
|
|
null
|
|
|
)
|
|
|
- return this.handler.getProjectDocsIfMatch(
|
|
|
+ this.handler.getProjectDocsIfMatch(
|
|
|
this.project_id,
|
|
|
this.project_state_hash,
|
|
|
this.callback
|
|
|
@@ -548,7 +517,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should return an error to the callback', function() {
|
|
|
- return this.callback.calledWith(this.error).should.equal(true)
|
|
|
+ this.callback.calledWith(this.error).should.equal(true)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
@@ -557,7 +526,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
this.request.post = sinon
|
|
|
.stub()
|
|
|
.callsArgWith(1, null, { statusCode: 409 }, 'Conflict')
|
|
|
- return this.handler.getProjectDocsIfMatch(
|
|
|
+ this.handler.getProjectDocsIfMatch(
|
|
|
this.project_id,
|
|
|
this.project_state_hash,
|
|
|
this.callback
|
|
|
@@ -565,7 +534,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should return the callback with no documents', function() {
|
|
|
- return this.callback.alwaysCalledWithExactly().should.equal(true)
|
|
|
+ this.callback.alwaysCalledWithExactly().should.equal(true)
|
|
|
})
|
|
|
})
|
|
|
})
|
|
|
@@ -574,11 +543,11 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
describe('successfully', function() {
|
|
|
beforeEach(function() {
|
|
|
this.request.callsArgWith(1, null, { statusCode: 200 })
|
|
|
- return this.handler.clearProjectState(this.project_id, this.callback)
|
|
|
+ this.handler.clearProjectState(this.project_id, this.callback)
|
|
|
})
|
|
|
|
|
|
it('should clear the project state from the document updater', function() {
|
|
|
- return this.request
|
|
|
+ this.request
|
|
|
.calledWithMatch({
|
|
|
url: `${this.settings.apis.documentupdater.url}/project/${
|
|
|
this.project_id
|
|
|
@@ -589,7 +558,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should call the callback', function() {
|
|
|
- return this.callback.calledWith(null).should.equal(true)
|
|
|
+ this.callback.calledWith(null).should.equal(true)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
@@ -601,22 +570,22 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
null,
|
|
|
null
|
|
|
)
|
|
|
- return this.handler.clearProjectState(this.project_id, this.callback)
|
|
|
+ this.handler.clearProjectState(this.project_id, this.callback)
|
|
|
})
|
|
|
|
|
|
it('should return an error to the callback', function() {
|
|
|
- return this.callback.calledWith(this.error).should.equal(true)
|
|
|
+ this.callback.calledWith(this.error).should.equal(true)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
describe('when the document updater returns an error code', function() {
|
|
|
beforeEach(function() {
|
|
|
this.request.callsArgWith(1, null, { statusCode: 500 }, null)
|
|
|
- return this.handler.clearProjectState(this.project_id, this.callback)
|
|
|
+ this.handler.clearProjectState(this.project_id, this.callback)
|
|
|
})
|
|
|
|
|
|
it('should return the callback with no documents', function() {
|
|
|
- return this.callback
|
|
|
+ this.callback
|
|
|
.calledWith(
|
|
|
new Error('doc updater returned failure status code: 500')
|
|
|
)
|
|
|
@@ -627,13 +596,13 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
|
|
|
describe('acceptChanges', function() {
|
|
|
beforeEach(function() {
|
|
|
- return (this.change_id = 'mock-change-id-1')
|
|
|
+ this.change_id = 'mock-change-id-1'
|
|
|
})
|
|
|
|
|
|
describe('successfully', function() {
|
|
|
beforeEach(function() {
|
|
|
this.request.callsArgWith(1, null, { statusCode: 200 }, this.body)
|
|
|
- return this.handler.acceptChanges(
|
|
|
+ this.handler.acceptChanges(
|
|
|
this.project_id,
|
|
|
this.doc_id,
|
|
|
[this.change_id],
|
|
|
@@ -642,7 +611,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should accept the change in the document updater', function() {
|
|
|
- return this.request
|
|
|
+ this.request
|
|
|
.calledWith({
|
|
|
url: `${this.settings.apis.documentupdater.url}/project/${
|
|
|
this.project_id
|
|
|
@@ -656,7 +625,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should call the callback', function() {
|
|
|
- return this.callback.calledWith(null).should.equal(true)
|
|
|
+ this.callback.calledWith(null).should.equal(true)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
@@ -668,7 +637,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
null,
|
|
|
null
|
|
|
)
|
|
|
- return this.handler.acceptChanges(
|
|
|
+ this.handler.acceptChanges(
|
|
|
this.project_id,
|
|
|
this.doc_id,
|
|
|
[this.change_id],
|
|
|
@@ -677,14 +646,14 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should return an error to the callback', function() {
|
|
|
- return this.callback.calledWith(this.error).should.equal(true)
|
|
|
+ this.callback.calledWith(this.error).should.equal(true)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
describe('when the document updater returns a failure error code', function() {
|
|
|
beforeEach(function() {
|
|
|
this.request.callsArgWith(1, null, { statusCode: 500 }, '')
|
|
|
- return this.handler.acceptChanges(
|
|
|
+ this.handler.acceptChanges(
|
|
|
this.project_id,
|
|
|
this.doc_id,
|
|
|
[this.change_id],
|
|
|
@@ -693,7 +662,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should return the callback with an error', function() {
|
|
|
- return this.callback
|
|
|
+ this.callback
|
|
|
.calledWith(
|
|
|
new Error('doc updater returned failure status code: 500')
|
|
|
)
|
|
|
@@ -704,13 +673,13 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
|
|
|
describe('deleteThread', function() {
|
|
|
beforeEach(function() {
|
|
|
- return (this.thread_id = 'mock-thread-id-1')
|
|
|
+ this.thread_id = 'mock-thread-id-1'
|
|
|
})
|
|
|
|
|
|
describe('successfully', function() {
|
|
|
beforeEach(function() {
|
|
|
this.request.callsArgWith(1, null, { statusCode: 200 }, this.body)
|
|
|
- return this.handler.deleteThread(
|
|
|
+ this.handler.deleteThread(
|
|
|
this.project_id,
|
|
|
this.doc_id,
|
|
|
this.thread_id,
|
|
|
@@ -719,7 +688,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should delete the thread in the document updater', function() {
|
|
|
- return this.request
|
|
|
+ this.request
|
|
|
.calledWithMatch({
|
|
|
url: `${this.settings.apis.documentupdater.url}/project/${
|
|
|
this.project_id
|
|
|
@@ -730,7 +699,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should call the callback', function() {
|
|
|
- return this.callback.calledWith(null).should.equal(true)
|
|
|
+ this.callback.calledWith(null).should.equal(true)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
@@ -742,7 +711,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
null,
|
|
|
null
|
|
|
)
|
|
|
- return this.handler.deleteThread(
|
|
|
+ this.handler.deleteThread(
|
|
|
this.project_id,
|
|
|
this.doc_id,
|
|
|
this.thread_id,
|
|
|
@@ -751,14 +720,14 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should return an error to the callback', function() {
|
|
|
- return this.callback.calledWith(this.error).should.equal(true)
|
|
|
+ this.callback.calledWith(this.error).should.equal(true)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
describe('when the document updater returns a failure error code', function() {
|
|
|
beforeEach(function() {
|
|
|
this.request.callsArgWith(1, null, { statusCode: 500 }, '')
|
|
|
- return this.handler.deleteThread(
|
|
|
+ this.handler.deleteThread(
|
|
|
this.project_id,
|
|
|
this.doc_id,
|
|
|
this.thread_id,
|
|
|
@@ -767,7 +736,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('should return the callback with an error', function() {
|
|
|
- return this.callback
|
|
|
+ this.callback
|
|
|
.calledWith(
|
|
|
new Error('doc updater returned failure status code: 500')
|
|
|
)
|
|
|
@@ -779,13 +748,13 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
describe('updateProjectStructure ', function() {
|
|
|
beforeEach(function() {
|
|
|
this.user_id = 1234
|
|
|
- return (this.version = 999)
|
|
|
+ this.version = 999
|
|
|
})
|
|
|
|
|
|
describe('with project history disabled', function() {
|
|
|
beforeEach(function() {
|
|
|
this.settings.apis.project_history.sendProjectStructureOps = false
|
|
|
- return this.handler.updateProjectStructure(
|
|
|
+ this.handler.updateProjectStructure(
|
|
|
this.project_id,
|
|
|
this.projectHistoryId,
|
|
|
this.user_id,
|
|
|
@@ -795,11 +764,11 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
})
|
|
|
|
|
|
it('does not make a web request', function() {
|
|
|
- return this.request.called.should.equal(false)
|
|
|
+ this.request.called.should.equal(false)
|
|
|
})
|
|
|
|
|
|
it('calls the callback', function() {
|
|
|
- return this.callback.called.should.equal(true)
|
|
|
+ this.callback.called.should.equal(true)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
@@ -809,7 +778,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
this.url = `${this.settings.apis.documentupdater.url}/project/${
|
|
|
this.project_id
|
|
|
}`
|
|
|
- return this.request.callsArgWith(1, null, { statusCode: 204 }, '')
|
|
|
+ this.request.callsArgWith(1, null, { statusCode: 204 }, '')
|
|
|
})
|
|
|
|
|
|
describe('when an entity has changed name', function() {
|
|
|
@@ -843,7 +812,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
}
|
|
|
]
|
|
|
|
|
|
- return this.handler.updateProjectStructure(
|
|
|
+ this.handler.updateProjectStructure(
|
|
|
this.project_id,
|
|
|
this.projectHistoryId,
|
|
|
this.user_id,
|
|
|
@@ -862,7 +831,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
}
|
|
|
})
|
|
|
.should.equal(true)
|
|
|
- return done()
|
|
|
+ done()
|
|
|
}
|
|
|
)
|
|
|
})
|
|
|
@@ -888,7 +857,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
}
|
|
|
]
|
|
|
|
|
|
- return this.handler.updateProjectStructure(
|
|
|
+ this.handler.updateProjectStructure(
|
|
|
this.project_id,
|
|
|
this.projectHistoryId,
|
|
|
this.user_id,
|
|
|
@@ -907,7 +876,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
}
|
|
|
})
|
|
|
.should.equal(true)
|
|
|
- return done()
|
|
|
+ done()
|
|
|
}
|
|
|
)
|
|
|
})
|
|
|
@@ -937,7 +906,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
}
|
|
|
]
|
|
|
|
|
|
- return this.handler.updateProjectStructure(
|
|
|
+ this.handler.updateProjectStructure(
|
|
|
this.project_id,
|
|
|
this.projectHistoryId,
|
|
|
this.user_id,
|
|
|
@@ -956,7 +925,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
}
|
|
|
})
|
|
|
.should.equal(true)
|
|
|
- return done()
|
|
|
+ done()
|
|
|
}
|
|
|
)
|
|
|
})
|
|
|
@@ -980,7 +949,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
}
|
|
|
]
|
|
|
|
|
|
- return this.handler.updateProjectStructure(
|
|
|
+ this.handler.updateProjectStructure(
|
|
|
this.project_id,
|
|
|
this.projectHistoryId,
|
|
|
this.user_id,
|
|
|
@@ -999,7 +968,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
}
|
|
|
})
|
|
|
.should.equal(true)
|
|
|
- return done()
|
|
|
+ done()
|
|
|
}
|
|
|
)
|
|
|
})
|
|
|
@@ -1014,14 +983,6 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
]
|
|
|
}
|
|
|
|
|
|
- const docUpdates = [
|
|
|
- {
|
|
|
- id: this.docId.toString(),
|
|
|
- pathname: '/foo',
|
|
|
- newPathname: ''
|
|
|
- }
|
|
|
- ]
|
|
|
-
|
|
|
this.handler.updateProjectStructure(
|
|
|
this.project_id,
|
|
|
this.projectHistoryId,
|
|
|
@@ -1032,7 +993,7 @@ describe('DocumentUpdaterHandler', function() {
|
|
|
|
|
|
this.callback.calledWith(new Error()).should.equal(true)
|
|
|
const firstCallArgs = this.callback.args[0]
|
|
|
- return firstCallArgs[0].message.should.equal(
|
|
|
+ firstCallArgs[0].message.should.equal(
|
|
|
'did not receive project version in changes'
|
|
|
)
|
|
|
})
|