Merge pull request #3495 from overleaf/ae-prettier-2
Upgrade Prettier to v2 GitOrigin-RevId: 85aa3fa1acb6332c4f58c46165a43d1a51471f33
This commit is contained in:
@@ -18,8 +18,8 @@ const modulePath =
|
||||
const MockRequest = require('../helpers/MockRequest')
|
||||
const MockResponse = require('../helpers/MockResponse')
|
||||
|
||||
describe('ReferencesController', function() {
|
||||
beforeEach(function() {
|
||||
describe('ReferencesController', function () {
|
||||
beforeEach(function () {
|
||||
this.projectId = '2222'
|
||||
this.controller = SandboxedModule.require(modulePath, {
|
||||
requires: {
|
||||
@@ -51,8 +51,8 @@ describe('ReferencesController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('indexAll', function() {
|
||||
beforeEach(function() {
|
||||
describe('indexAll', function () {
|
||||
beforeEach(function () {
|
||||
this.req.body = { shouldBroadcast: false }
|
||||
this.ReferencesHandler.indexAll.callsArgWith(
|
||||
1,
|
||||
@@ -65,7 +65,7 @@ describe('ReferencesController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should not produce an error', function(done) {
|
||||
it('should not produce an error', function (done) {
|
||||
return this.call(() => {
|
||||
this.res.sendStatus.callCount.should.equal(0)
|
||||
this.res.sendStatus.calledWith(500).should.equal(false)
|
||||
@@ -74,7 +74,7 @@ describe('ReferencesController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should return data', function(done) {
|
||||
it('should return data', function (done) {
|
||||
return this.call(() => {
|
||||
this.res.json.callCount.should.equal(1)
|
||||
this.res.json.calledWith(this.fakeResponseData).should.equal(true)
|
||||
@@ -82,7 +82,7 @@ describe('ReferencesController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should call ReferencesHandler.indexAll', function(done) {
|
||||
it('should call ReferencesHandler.indexAll', function (done) {
|
||||
return this.call(() => {
|
||||
this.ReferencesHandler.indexAll.callCount.should.equal(1)
|
||||
this.ReferencesHandler.indexAll
|
||||
@@ -92,8 +92,8 @@ describe('ReferencesController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when shouldBroadcast is true', function() {
|
||||
beforeEach(function() {
|
||||
describe('when shouldBroadcast is true', function () {
|
||||
beforeEach(function () {
|
||||
this.ReferencesHandler.index.callsArgWith(
|
||||
2,
|
||||
null,
|
||||
@@ -102,14 +102,14 @@ describe('ReferencesController', function() {
|
||||
return (this.req.body.shouldBroadcast = true)
|
||||
})
|
||||
|
||||
it('should call EditorRealTimeController.emitToRoom', function(done) {
|
||||
it('should call EditorRealTimeController.emitToRoom', function (done) {
|
||||
return this.call(() => {
|
||||
this.EditorRealTimeController.emitToRoom.callCount.should.equal(1)
|
||||
return done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should not produce an error', function(done) {
|
||||
it('should not produce an error', function (done) {
|
||||
return this.call(() => {
|
||||
this.res.sendStatus.callCount.should.equal(0)
|
||||
this.res.sendStatus.calledWith(500).should.equal(false)
|
||||
@@ -118,7 +118,7 @@ describe('ReferencesController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should still return data', function(done) {
|
||||
it('should still return data', function (done) {
|
||||
return this.call(() => {
|
||||
this.res.json.callCount.should.equal(1)
|
||||
this.res.json.calledWith(this.fakeResponseData).should.equal(true)
|
||||
@@ -127,8 +127,8 @@ describe('ReferencesController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when shouldBroadcast is false', function() {
|
||||
beforeEach(function() {
|
||||
describe('when shouldBroadcast is false', function () {
|
||||
beforeEach(function () {
|
||||
this.ReferencesHandler.index.callsArgWith(
|
||||
2,
|
||||
null,
|
||||
@@ -137,14 +137,14 @@ describe('ReferencesController', function() {
|
||||
return (this.req.body.shouldBroadcast = false)
|
||||
})
|
||||
|
||||
it('should not call EditorRealTimeController.emitToRoom', function(done) {
|
||||
it('should not call EditorRealTimeController.emitToRoom', function (done) {
|
||||
return this.call(() => {
|
||||
this.EditorRealTimeController.emitToRoom.callCount.should.equal(0)
|
||||
return done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should not produce an error', function(done) {
|
||||
it('should not produce an error', function (done) {
|
||||
return this.call(() => {
|
||||
this.res.sendStatus.callCount.should.equal(0)
|
||||
this.res.sendStatus.calledWith(500).should.equal(false)
|
||||
@@ -153,7 +153,7 @@ describe('ReferencesController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should still return data', function(done) {
|
||||
it('should still return data', function (done) {
|
||||
return this.call(() => {
|
||||
this.res.json.callCount.should.equal(1)
|
||||
this.res.json.calledWith(this.fakeResponseData).should.equal(true)
|
||||
@@ -163,8 +163,8 @@ describe('ReferencesController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('there is no data', function() {
|
||||
beforeEach(function() {
|
||||
describe('there is no data', function () {
|
||||
beforeEach(function () {
|
||||
this.ReferencesHandler.indexAll.callsArgWith(1)
|
||||
return (this.call = callback => {
|
||||
this.controller.indexAll(this.req, this.res)
|
||||
@@ -172,14 +172,14 @@ describe('ReferencesController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should not call EditorRealTimeController.emitToRoom', function(done) {
|
||||
it('should not call EditorRealTimeController.emitToRoom', function (done) {
|
||||
return this.call(() => {
|
||||
this.EditorRealTimeController.emitToRoom.callCount.should.equal(0)
|
||||
return done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should not produce an error', function(done) {
|
||||
it('should not produce an error', function (done) {
|
||||
return this.call(() => {
|
||||
this.res.sendStatus.callCount.should.equal(0)
|
||||
this.res.sendStatus.calledWith(500).should.equal(false)
|
||||
@@ -188,7 +188,7 @@ describe('ReferencesController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should send a response with an empty keys list', function(done) {
|
||||
it('should send a response with an empty keys list', function (done) {
|
||||
return this.call(() => {
|
||||
this.res.json.called.should.equal(true)
|
||||
this.res.json
|
||||
@@ -199,16 +199,16 @@ describe('ReferencesController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('index', function() {
|
||||
beforeEach(function() {
|
||||
describe('index', function () {
|
||||
beforeEach(function () {
|
||||
return (this.call = callback => {
|
||||
this.controller.index(this.req, this.res)
|
||||
return callback()
|
||||
})
|
||||
})
|
||||
|
||||
describe('with docIds as an array and shouldBroadcast as false', function() {
|
||||
beforeEach(function() {
|
||||
describe('with docIds as an array and shouldBroadcast as false', function () {
|
||||
beforeEach(function () {
|
||||
return this.ReferencesHandler.index.callsArgWith(
|
||||
2,
|
||||
null,
|
||||
@@ -216,7 +216,7 @@ describe('ReferencesController', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should call ReferencesHandler.index', function(done) {
|
||||
it('should call ReferencesHandler.index', function (done) {
|
||||
return this.call(() => {
|
||||
this.ReferencesHandler.index.callCount.should.equal(1)
|
||||
this.ReferencesHandler.index
|
||||
@@ -226,7 +226,7 @@ describe('ReferencesController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should return data', function(done) {
|
||||
it('should return data', function (done) {
|
||||
return this.call(() => {
|
||||
this.res.json.callCount.should.equal(1)
|
||||
this.res.json.calledWith(this.fakeResponseData).should.equal(true)
|
||||
@@ -234,7 +234,7 @@ describe('ReferencesController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should not produce an error', function(done) {
|
||||
it('should not produce an error', function (done) {
|
||||
return this.call(() => {
|
||||
this.res.sendStatus.callCount.should.equal(0)
|
||||
this.res.sendStatus.calledWith(500).should.equal(false)
|
||||
@@ -243,15 +243,15 @@ describe('ReferencesController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should not call EditorRealTimController.emitToRoom', function(done) {
|
||||
it('should not call EditorRealTimController.emitToRoom', function (done) {
|
||||
return this.call(() => {
|
||||
this.EditorRealTimeController.emitToRoom.callCount.should.equal(0)
|
||||
return done()
|
||||
})
|
||||
})
|
||||
|
||||
describe('when ReferencesHandler.index produces an error', function() {
|
||||
beforeEach(function() {
|
||||
describe('when ReferencesHandler.index produces an error', function () {
|
||||
beforeEach(function () {
|
||||
return this.ReferencesHandler.index.callsArgWith(
|
||||
2,
|
||||
new Error('woops'),
|
||||
@@ -259,7 +259,7 @@ describe('ReferencesController', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should produce an error response', function(done) {
|
||||
it('should produce an error response', function (done) {
|
||||
return this.call(() => {
|
||||
this.res.sendStatus.callCount.should.equal(1)
|
||||
this.res.sendStatus.calledWith(500).should.equal(true)
|
||||
@@ -269,8 +269,8 @@ describe('ReferencesController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when shouldBroadcast is true', function() {
|
||||
beforeEach(function() {
|
||||
describe('when shouldBroadcast is true', function () {
|
||||
beforeEach(function () {
|
||||
this.ReferencesHandler.index.callsArgWith(
|
||||
2,
|
||||
null,
|
||||
@@ -279,14 +279,14 @@ describe('ReferencesController', function() {
|
||||
return (this.req.body.shouldBroadcast = true)
|
||||
})
|
||||
|
||||
it('should call EditorRealTimeController.emitToRoom', function(done) {
|
||||
it('should call EditorRealTimeController.emitToRoom', function (done) {
|
||||
return this.call(() => {
|
||||
this.EditorRealTimeController.emitToRoom.callCount.should.equal(1)
|
||||
return done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should not produce an error', function(done) {
|
||||
it('should not produce an error', function (done) {
|
||||
return this.call(() => {
|
||||
this.res.sendStatus.callCount.should.equal(0)
|
||||
this.res.sendStatus.calledWith(500).should.equal(false)
|
||||
@@ -295,7 +295,7 @@ describe('ReferencesController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should still return data', function(done) {
|
||||
it('should still return data', function (done) {
|
||||
return this.call(() => {
|
||||
this.res.json.callCount.should.equal(1)
|
||||
this.res.json.calledWith(this.fakeResponseData).should.equal(true)
|
||||
@@ -304,12 +304,12 @@ describe('ReferencesController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('with missing docIds', function() {
|
||||
beforeEach(function() {
|
||||
describe('with missing docIds', function () {
|
||||
beforeEach(function () {
|
||||
return delete this.req.body.docIds
|
||||
})
|
||||
|
||||
it('should produce an error response', function(done) {
|
||||
it('should produce an error response', function (done) {
|
||||
return this.call(() => {
|
||||
this.res.sendStatus.callCount.should.equal(1)
|
||||
this.res.sendStatus.calledWith(400).should.equal(true)
|
||||
@@ -317,7 +317,7 @@ describe('ReferencesController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should not call ReferencesHandler.index', function(done) {
|
||||
it('should not call ReferencesHandler.index', function (done) {
|
||||
return this.call(() => {
|
||||
this.ReferencesHandler.index.callCount.should.equal(0)
|
||||
return done()
|
||||
@@ -325,12 +325,12 @@ describe('ReferencesController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('with invalid docIds', function() {
|
||||
beforeEach(function() {
|
||||
describe('with invalid docIds', function () {
|
||||
beforeEach(function () {
|
||||
return (this.req.body.docIds = 42)
|
||||
})
|
||||
|
||||
it('should produce an error response', function(done) {
|
||||
it('should produce an error response', function (done) {
|
||||
return this.call(() => {
|
||||
this.res.sendStatus.callCount.should.equal(1)
|
||||
this.res.sendStatus.calledWith(400).should.equal(true)
|
||||
@@ -338,7 +338,7 @@ describe('ReferencesController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should not call ReferencesHandler.index', function(done) {
|
||||
it('should not call ReferencesHandler.index', function (done) {
|
||||
return this.call(() => {
|
||||
this.ReferencesHandler.index.callCount.should.equal(0)
|
||||
return done()
|
||||
|
||||
@@ -17,8 +17,8 @@ const { assert, expect } = require('chai')
|
||||
const sinon = require('sinon')
|
||||
const modulePath = '../../../../app/src/Features/References/ReferencesHandler'
|
||||
|
||||
describe('ReferencesHandler', function() {
|
||||
beforeEach(function() {
|
||||
describe('ReferencesHandler', function () {
|
||||
beforeEach(function () {
|
||||
this.projectId = '222'
|
||||
this.fakeProject = {
|
||||
_id: this.projectId,
|
||||
@@ -78,8 +78,8 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('index', function() {
|
||||
beforeEach(function() {
|
||||
describe('index', function () {
|
||||
beforeEach(function () {
|
||||
sinon.stub(this.handler, '_findBibDocIds')
|
||||
sinon.stub(this.handler, '_findBibFileIds')
|
||||
sinon.stub(this.handler, '_isFullIndex').callsArgWith(1, null, true)
|
||||
@@ -94,19 +94,19 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when references feature is disabled', function() {
|
||||
beforeEach(function() {
|
||||
describe('when references feature is disabled', function () {
|
||||
beforeEach(function () {
|
||||
this.Features.hasFeature.withArgs('references').returns(false)
|
||||
})
|
||||
|
||||
it('should not try to retrieve any user information', function(done) {
|
||||
it('should not try to retrieve any user information', function (done) {
|
||||
this.call(() => {
|
||||
this.UserGetter.getUser.callCount.should.equal(0)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should not produce an error', function(done) {
|
||||
it('should not produce an error', function (done) {
|
||||
return this.call(err => {
|
||||
expect(err).to.equal(undefined)
|
||||
return done()
|
||||
@@ -114,19 +114,19 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('with docIds as an array', function() {
|
||||
beforeEach(function() {
|
||||
describe('with docIds as an array', function () {
|
||||
beforeEach(function () {
|
||||
return (this.docIds = ['aaa', 'ccc'])
|
||||
})
|
||||
|
||||
it('should not call _findBibDocIds', function(done) {
|
||||
it('should not call _findBibDocIds', function (done) {
|
||||
return this.call((err, data) => {
|
||||
this.handler._findBibDocIds.callCount.should.equal(0)
|
||||
return done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should call ProjectGetter.getProject', function(done) {
|
||||
it('should call ProjectGetter.getProject', function (done) {
|
||||
return this.call((err, data) => {
|
||||
this.ProjectGetter.getProject.callCount.should.equal(1)
|
||||
this.ProjectGetter.getProject
|
||||
@@ -136,14 +136,14 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should not call _findBibDocIds', function(done) {
|
||||
it('should not call _findBibDocIds', function (done) {
|
||||
return this.call((err, data) => {
|
||||
this.handler._findBibDocIds.callCount.should.equal(0)
|
||||
return done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should call DocumentUpdaterHandler.flushDocToMongo', function(done) {
|
||||
it('should call DocumentUpdaterHandler.flushDocToMongo', function (done) {
|
||||
return this.call((err, data) => {
|
||||
this.DocumentUpdaterHandler.flushDocToMongo.callCount.should.equal(2)
|
||||
this.docIds.forEach(docId => {
|
||||
@@ -155,7 +155,7 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should make a request to references service', function(done) {
|
||||
it('should make a request to references service', function (done) {
|
||||
return this.call((err, data) => {
|
||||
this.request.post.callCount.should.equal(1)
|
||||
const arg = this.request.post.firstCall.args[0]
|
||||
@@ -166,14 +166,14 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should not produce an error', function(done) {
|
||||
it('should not produce an error', function (done) {
|
||||
return this.call((err, data) => {
|
||||
expect(err).to.equal(null)
|
||||
return done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should return data', function(done) {
|
||||
it('should return data', function (done) {
|
||||
return this.call((err, data) => {
|
||||
expect(data).to.not.equal(null)
|
||||
expect(data).to.not.equal(undefined)
|
||||
@@ -183,12 +183,12 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when ProjectGetter.getProject produces an error', function() {
|
||||
beforeEach(function() {
|
||||
describe('when ProjectGetter.getProject produces an error', function () {
|
||||
beforeEach(function () {
|
||||
return this.ProjectGetter.getProject.callsArgWith(2, new Error('woops'))
|
||||
})
|
||||
|
||||
it('should produce an error', function(done) {
|
||||
it('should produce an error', function (done) {
|
||||
return this.call((err, data) => {
|
||||
expect(err).to.not.equal(null)
|
||||
expect(err).to.be.instanceof(Error)
|
||||
@@ -197,7 +197,7 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should not send request', function(done) {
|
||||
it('should not send request', function (done) {
|
||||
return this.call((err, data) => {
|
||||
this.request.post.callCount.should.equal(0)
|
||||
return done()
|
||||
@@ -205,13 +205,13 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when _isFullIndex produces an error', function() {
|
||||
beforeEach(function() {
|
||||
describe('when _isFullIndex produces an error', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectGetter.getProject.callsArgWith(2, null, this.fakeProject)
|
||||
return this.handler._isFullIndex.callsArgWith(1, new Error('woops'))
|
||||
})
|
||||
|
||||
it('should produce an error', function(done) {
|
||||
it('should produce an error', function (done) {
|
||||
return this.call((err, data) => {
|
||||
expect(err).to.not.equal(null)
|
||||
expect(err).to.be.instanceof(Error)
|
||||
@@ -220,7 +220,7 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should not send request', function(done) {
|
||||
it('should not send request', function (done) {
|
||||
return this.call((err, data) => {
|
||||
this.request.post.callCount.should.equal(0)
|
||||
return done()
|
||||
@@ -228,8 +228,8 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when flushDocToMongo produces an error', function() {
|
||||
beforeEach(function() {
|
||||
describe('when flushDocToMongo produces an error', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectGetter.getProject.callsArgWith(2, null, this.fakeProject)
|
||||
this.handler._isFullIndex.callsArgWith(1, false)
|
||||
return this.DocumentUpdaterHandler.flushDocToMongo.callsArgWith(
|
||||
@@ -238,7 +238,7 @@ describe('ReferencesHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should produce an error', function(done) {
|
||||
it('should produce an error', function (done) {
|
||||
return this.call((err, data) => {
|
||||
expect(err).to.not.equal(null)
|
||||
expect(err).to.be.instanceof(Error)
|
||||
@@ -247,7 +247,7 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should not send request', function(done) {
|
||||
it('should not send request', function (done) {
|
||||
return this.call((err, data) => {
|
||||
this.request.post.callCount.should.equal(0)
|
||||
return done()
|
||||
@@ -255,15 +255,15 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when request produces an error', function() {
|
||||
beforeEach(function() {
|
||||
describe('when request produces an error', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectGetter.getProject.callsArgWith(2, null, this.fakeProject)
|
||||
this.handler._isFullIndex.callsArgWith(1, null, false)
|
||||
this.DocumentUpdaterHandler.flushDocToMongo.callsArgWith(2, null)
|
||||
return this.request.post.callsArgWith(1, new Error('woops'))
|
||||
})
|
||||
|
||||
it('should produce an error', function(done) {
|
||||
it('should produce an error', function (done) {
|
||||
return this.call((err, data) => {
|
||||
expect(err).to.not.equal(null)
|
||||
expect(err).to.be.instanceof(Error)
|
||||
@@ -273,8 +273,8 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when request responds with error status', function() {
|
||||
beforeEach(function() {
|
||||
describe('when request responds with error status', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectGetter.getProject.callsArgWith(2, null, this.fakeProject)
|
||||
this.handler._isFullIndex.callsArgWith(1, null, false)
|
||||
return this.request.post.callsArgWith(
|
||||
@@ -285,7 +285,7 @@ describe('ReferencesHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should produce an error', function(done) {
|
||||
it('should produce an error', function (done) {
|
||||
return this.call((err, data) => {
|
||||
expect(err).to.not.equal(null)
|
||||
expect(err).to.be.instanceof(Error)
|
||||
@@ -296,8 +296,8 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('indexAll', function() {
|
||||
beforeEach(function() {
|
||||
describe('indexAll', function () {
|
||||
beforeEach(function () {
|
||||
sinon.stub(this.handler, '_findBibDocIds').returns(['aaa', 'ccc'])
|
||||
sinon.stub(this.handler, '_findBibFileIds').returns(['fff', 'ggg'])
|
||||
sinon.stub(this.handler, '_isFullIndex').callsArgWith(1, null, true)
|
||||
@@ -312,7 +312,7 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should call _findBibDocIds', function(done) {
|
||||
it('should call _findBibDocIds', function (done) {
|
||||
return this.call((err, data) => {
|
||||
this.handler._findBibDocIds.callCount.should.equal(1)
|
||||
this.handler._findBibDocIds
|
||||
@@ -322,7 +322,7 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should call _findBibFileIds', function(done) {
|
||||
it('should call _findBibFileIds', function (done) {
|
||||
return this.call((err, data) => {
|
||||
this.handler._findBibDocIds.callCount.should.equal(1)
|
||||
this.handler._findBibDocIds
|
||||
@@ -332,14 +332,14 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should call DocumentUpdaterHandler.flushDocToMongo', function(done) {
|
||||
it('should call DocumentUpdaterHandler.flushDocToMongo', function (done) {
|
||||
return this.call((err, data) => {
|
||||
this.DocumentUpdaterHandler.flushDocToMongo.callCount.should.equal(2)
|
||||
return done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should make a request to references service', function(done) {
|
||||
it('should make a request to references service', function (done) {
|
||||
return this.call((err, data) => {
|
||||
this.request.post.callCount.should.equal(1)
|
||||
const arg = this.request.post.firstCall.args[0]
|
||||
@@ -350,14 +350,14 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should not produce an error', function(done) {
|
||||
it('should not produce an error', function (done) {
|
||||
return this.call((err, data) => {
|
||||
expect(err).to.equal(null)
|
||||
return done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should return data', function(done) {
|
||||
it('should return data', function (done) {
|
||||
return this.call((err, data) => {
|
||||
expect(data).to.not.equal(null)
|
||||
expect(data).to.not.equal(undefined)
|
||||
@@ -366,12 +366,12 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when ProjectGetter.getProject produces an error', function() {
|
||||
beforeEach(function() {
|
||||
describe('when ProjectGetter.getProject produces an error', function () {
|
||||
beforeEach(function () {
|
||||
return this.ProjectGetter.getProject.callsArgWith(2, new Error('woops'))
|
||||
})
|
||||
|
||||
it('should produce an error', function(done) {
|
||||
it('should produce an error', function (done) {
|
||||
return this.call((err, data) => {
|
||||
expect(err).to.not.equal(null)
|
||||
expect(err).to.be.instanceof(Error)
|
||||
@@ -380,7 +380,7 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should not send request', function(done) {
|
||||
it('should not send request', function (done) {
|
||||
return this.call((err, data) => {
|
||||
this.request.post.callCount.should.equal(0)
|
||||
return done()
|
||||
@@ -388,13 +388,13 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when _isFullIndex produces an error', function() {
|
||||
beforeEach(function() {
|
||||
describe('when _isFullIndex produces an error', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectGetter.getProject.callsArgWith(2, null, this.fakeProject)
|
||||
return this.handler._isFullIndex.callsArgWith(1, new Error('woops'))
|
||||
})
|
||||
|
||||
it('should produce an error', function(done) {
|
||||
it('should produce an error', function (done) {
|
||||
return this.call((err, data) => {
|
||||
expect(err).to.not.equal(null)
|
||||
expect(err).to.be.instanceof(Error)
|
||||
@@ -403,7 +403,7 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should not send request', function(done) {
|
||||
it('should not send request', function (done) {
|
||||
return this.call((err, data) => {
|
||||
this.request.post.callCount.should.equal(0)
|
||||
return done()
|
||||
@@ -411,8 +411,8 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when flushDocToMongo produces an error', function() {
|
||||
beforeEach(function() {
|
||||
describe('when flushDocToMongo produces an error', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectGetter.getProject.callsArgWith(2, null, this.fakeProject)
|
||||
this.handler._isFullIndex.callsArgWith(1, false)
|
||||
return this.DocumentUpdaterHandler.flushDocToMongo.callsArgWith(
|
||||
@@ -421,7 +421,7 @@ describe('ReferencesHandler', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should produce an error', function(done) {
|
||||
it('should produce an error', function (done) {
|
||||
return this.call((err, data) => {
|
||||
expect(err).to.not.equal(null)
|
||||
expect(err).to.be.instanceof(Error)
|
||||
@@ -430,7 +430,7 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should not send request', function(done) {
|
||||
it('should not send request', function (done) {
|
||||
return this.call((err, data) => {
|
||||
this.request.post.callCount.should.equal(0)
|
||||
return done()
|
||||
@@ -439,8 +439,8 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('_findBibDocIds', function() {
|
||||
beforeEach(function() {
|
||||
describe('_findBibDocIds', function () {
|
||||
beforeEach(function () {
|
||||
this.fakeProject = {
|
||||
rootFolder: [
|
||||
{
|
||||
@@ -457,20 +457,20 @@ describe('ReferencesHandler', function() {
|
||||
return (this.expectedIds = ['aaa', 'ccc'])
|
||||
})
|
||||
|
||||
it('should select the correct docIds', function() {
|
||||
it('should select the correct docIds', function () {
|
||||
const result = this.handler._findBibDocIds(this.fakeProject)
|
||||
return expect(result).to.deep.equal(this.expectedIds)
|
||||
})
|
||||
|
||||
it('should not error with a non array of folders from dirty data', function() {
|
||||
it('should not error with a non array of folders from dirty data', function () {
|
||||
this.fakeProject.rootFolder[0].folders[0].folders = {}
|
||||
const result = this.handler._findBibDocIds(this.fakeProject)
|
||||
return expect(result).to.deep.equal(this.expectedIds)
|
||||
})
|
||||
})
|
||||
|
||||
describe('_findBibFileIds', function() {
|
||||
beforeEach(function() {
|
||||
describe('_findBibFileIds', function () {
|
||||
beforeEach(function () {
|
||||
this.fakeProject = {
|
||||
rootFolder: [
|
||||
{
|
||||
@@ -492,14 +492,14 @@ describe('ReferencesHandler', function() {
|
||||
return (this.expectedIds = ['ddd', 'ghg'])
|
||||
})
|
||||
|
||||
it('should select the correct docIds', function() {
|
||||
it('should select the correct docIds', function () {
|
||||
const result = this.handler._findBibFileIds(this.fakeProject)
|
||||
return expect(result).to.deep.equal(this.expectedIds)
|
||||
})
|
||||
})
|
||||
|
||||
describe('_isFullIndex', function() {
|
||||
beforeEach(function() {
|
||||
describe('_isFullIndex', function () {
|
||||
beforeEach(function () {
|
||||
this.fakeProject = { owner_ref: (this.owner_ref = 'owner-ref-123') }
|
||||
this.owner = {
|
||||
features: {
|
||||
@@ -515,12 +515,12 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('with references feature on', function() {
|
||||
beforeEach(function() {
|
||||
describe('with references feature on', function () {
|
||||
beforeEach(function () {
|
||||
return (this.owner.features.references = true)
|
||||
})
|
||||
|
||||
it('should return true', function() {
|
||||
it('should return true', function () {
|
||||
return this.call((err, isFullIndex) => {
|
||||
expect(err).to.equal(null)
|
||||
return expect(isFullIndex).to.equal(true)
|
||||
@@ -528,12 +528,12 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('with references feature off', function() {
|
||||
beforeEach(function() {
|
||||
describe('with references feature off', function () {
|
||||
beforeEach(function () {
|
||||
return (this.owner.features.references = false)
|
||||
})
|
||||
|
||||
it('should return false', function() {
|
||||
it('should return false', function () {
|
||||
return this.call((err, isFullIndex) => {
|
||||
expect(err).to.equal(null)
|
||||
return expect(isFullIndex).to.equal(false)
|
||||
@@ -541,15 +541,15 @@ describe('ReferencesHandler', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('with referencesSearch', function() {
|
||||
beforeEach(function() {
|
||||
describe('with referencesSearch', function () {
|
||||
beforeEach(function () {
|
||||
return (this.owner.features = {
|
||||
referencesSearch: true,
|
||||
references: false
|
||||
})
|
||||
})
|
||||
|
||||
it('should return true', function() {
|
||||
it('should return true', function () {
|
||||
return this.call((err, isFullIndex) => {
|
||||
expect(err).to.equal(null)
|
||||
return expect(isFullIndex).to.equal(true)
|
||||
|
||||
Reference in New Issue
Block a user