소스 검색

More tests for indexAll

Shane Kilkelly 10 년 전
부모
커밋
3a700a5af2
1개의 변경된 파일과 54개의 추가작업 그리고 0개의 파일을 삭제
  1. 54 0
      services/web/test/UnitTests/coffee/ReferencesSearch/ReferencesSearchHandlerTests.coffee

+ 54 - 0
services/web/test/UnitTests/coffee/ReferencesSearch/ReferencesSearchHandlerTests.coffee

@@ -234,6 +234,60 @@ describe 'ReferencesSearchHandler', ->
 				expect(data).to.equal @fakeResponseData
 				done()
 
+		describe 'when Project.findPopulatedById produces an error', ->
+
+			beforeEach ->
+				@Project.findPopulatedById.callsArgWith(1, new Error('woops'))
+
+			it 'should produce an error', (done) ->
+				@call (err, data) =>
+					expect(err).to.not.equal null
+					expect(err).to.be.instanceof Error
+					expect(data).to.equal undefined
+					done()
+
+			it 'should not send request', (done) ->
+				@call (err, data) =>
+					@request.post.callCount.should.equal 0
+					done()
+
+		describe 'when _isFullIndex produces an error', ->
+
+			beforeEach ->
+				@Project.findPopulatedById.callsArgWith(1, null, @fakeProject)
+				@handler._isFullIndex.callsArgWith(1, new Error('woops'))
+
+			it 'should produce an error', (done) ->
+				@call (err, data) =>
+					expect(err).to.not.equal null
+					expect(err).to.be.instanceof Error
+					expect(data).to.equal undefined
+					done()
+
+			it 'should not send request', (done) ->
+				@call (err, data) =>
+					@request.post.callCount.should.equal 0
+					done()
+
+		describe 'when flushDocToMongo produces an error', ->
+
+			beforeEach ->
+				@Project.findPopulatedById.callsArgWith(1, null, @fakeProject)
+				@handler._isFullIndex.callsArgWith(1, false)
+				@DocumentUpdaterHandler.flushDocToMongo.callsArgWith(2, new Error('woops'))
+
+			it 'should produce an error', (done) ->
+				@call (err, data) =>
+					expect(err).to.not.equal null
+					expect(err).to.be.instanceof Error
+					expect(data).to.equal undefined
+					done()
+
+			it 'should not send request', (done) ->
+				@call (err, data) =>
+					@request.post.callCount.should.equal 0
+					done()
+
 
 	describe '_findBibDocIds', ->