|
@@ -21,7 +21,11 @@ describe 'ReferencesHandler', ->
|
|
|
{name: 'two.txt', _id: 'bbb'},
|
|
{name: 'two.txt', _id: 'bbb'},
|
|
|
]
|
|
]
|
|
|
folders: [
|
|
folders: [
|
|
|
- {docs: [{name: 'three.bib', _id: 'ccc'}], folders: []}
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ docs: [{name: 'three.bib', _id: 'ccc'}],
|
|
|
|
|
+ fileRefs: [{name: 'four.bib', _id: 'ghg'}],
|
|
|
|
|
+ folders: []
|
|
|
|
|
+ }
|
|
|
]
|
|
]
|
|
|
]
|
|
]
|
|
|
@docIds = ['aaa', 'ccc']
|
|
@docIds = ['aaa', 'ccc']
|
|
@@ -34,6 +38,7 @@ describe 'ReferencesHandler', ->
|
|
|
apis:
|
|
apis:
|
|
|
references: {url: 'http://some.url/references'}
|
|
references: {url: 'http://some.url/references'}
|
|
|
docstore: {url: 'http://some.url/docstore'}
|
|
docstore: {url: 'http://some.url/docstore'}
|
|
|
|
|
+ filestore: {url: 'http://some.url/filestore'}
|
|
|
}
|
|
}
|
|
|
'request': @request = {
|
|
'request': @request = {
|
|
|
get: sinon.stub()
|
|
get: sinon.stub()
|
|
@@ -56,6 +61,7 @@ describe 'ReferencesHandler', ->
|
|
|
|
|
|
|
|
beforeEach ->
|
|
beforeEach ->
|
|
|
sinon.stub(@handler, '_findBibDocIds')
|
|
sinon.stub(@handler, '_findBibDocIds')
|
|
|
|
|
+ sinon.stub(@handler, '_findBibFileIds')
|
|
|
sinon.stub(@handler, '_isFullIndex').callsArgWith(1, null, true)
|
|
sinon.stub(@handler, '_isFullIndex').callsArgWith(1, null, true)
|
|
|
@request.post.callsArgWith(1, null, {statusCode: 200}, @fakeResponseData)
|
|
@request.post.callsArgWith(1, null, {statusCode: 200}, @fakeResponseData)
|
|
|
@call = (callback) =>
|
|
@call = (callback) =>
|
|
@@ -198,6 +204,7 @@ describe 'ReferencesHandler', ->
|
|
|
|
|
|
|
|
beforeEach ->
|
|
beforeEach ->
|
|
|
sinon.stub(@handler, '_findBibDocIds').returns(['aaa', 'ccc'])
|
|
sinon.stub(@handler, '_findBibDocIds').returns(['aaa', 'ccc'])
|
|
|
|
|
+ sinon.stub(@handler, '_findBibFileIds').returns(['fff', 'ggg'])
|
|
|
sinon.stub(@handler, '_isFullIndex').callsArgWith(1, null, true)
|
|
sinon.stub(@handler, '_isFullIndex').callsArgWith(1, null, true)
|
|
|
@request.post.callsArgWith(1, null, {statusCode: 200}, @fakeResponseData)
|
|
@request.post.callsArgWith(1, null, {statusCode: 200}, @fakeResponseData)
|
|
|
@call = (callback) =>
|
|
@call = (callback) =>
|
|
@@ -209,6 +216,12 @@ describe 'ReferencesHandler', ->
|
|
|
@handler._findBibDocIds.calledWith(@fakeProject).should.equal true
|
|
@handler._findBibDocIds.calledWith(@fakeProject).should.equal true
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
|
|
|
+ it 'should call _findBibFileIds', (done) ->
|
|
|
|
|
+ @call (err, data) =>
|
|
|
|
|
+ @handler._findBibDocIds.callCount.should.equal 1
|
|
|
|
|
+ @handler._findBibDocIds.calledWith(@fakeProject).should.equal true
|
|
|
|
|
+ done()
|
|
|
|
|
+
|
|
|
it 'should call DocumentUpdaterHandler.flushDocToMongo', (done) ->
|
|
it 'should call DocumentUpdaterHandler.flushDocToMongo', (done) ->
|
|
|
@call (err, data) =>
|
|
@call (err, data) =>
|
|
|
@DocumentUpdaterHandler.flushDocToMongo.callCount.should.equal 2
|
|
@DocumentUpdaterHandler.flushDocToMongo.callCount.should.equal 2
|
|
@@ -219,7 +232,7 @@ describe 'ReferencesHandler', ->
|
|
|
@request.post.callCount.should.equal 1
|
|
@request.post.callCount.should.equal 1
|
|
|
arg = @request.post.firstCall.args[0]
|
|
arg = @request.post.firstCall.args[0]
|
|
|
expect(arg.json).to.have.all.keys 'docUrls', 'fullIndex'
|
|
expect(arg.json).to.have.all.keys 'docUrls', 'fullIndex'
|
|
|
- expect(arg.json.docUrls.length).to.equal 2
|
|
|
|
|
|
|
+ expect(arg.json.docUrls.length).to.equal 4
|
|
|
expect(arg.json.fullIndex).to.equal true
|
|
expect(arg.json.fullIndex).to.equal true
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
@@ -309,6 +322,32 @@ describe 'ReferencesHandler', ->
|
|
|
result = @handler._findBibDocIds(@fakeProject)
|
|
result = @handler._findBibDocIds(@fakeProject)
|
|
|
expect(result).to.deep.equal @expectedIds
|
|
expect(result).to.deep.equal @expectedIds
|
|
|
|
|
|
|
|
|
|
+ describe '_findBibFileIds', ->
|
|
|
|
|
+
|
|
|
|
|
+ beforeEach ->
|
|
|
|
|
+ @fakeProject =
|
|
|
|
|
+ rootFolder: [
|
|
|
|
|
+ docs: [
|
|
|
|
|
+ {name: 'one.bib', _id: 'aaa'},
|
|
|
|
|
+ {name: 'two.txt', _id: 'bbb'},
|
|
|
|
|
+ ]
|
|
|
|
|
+ fileRefs: [
|
|
|
|
|
+ {name: 'other.bib', _id: 'ddd'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ folders: [
|
|
|
|
|
+ {
|
|
|
|
|
+ docs: [{name: 'three.bib', _id: 'ccc'}],
|
|
|
|
|
+ fileRefs: [{name: 'four.bib', _id: 'ghg'}],
|
|
|
|
|
+ folders: []
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ ]
|
|
|
|
|
+ @expectedIds = ['ddd', 'ghg']
|
|
|
|
|
+
|
|
|
|
|
+ it 'should select the correct docIds', ->
|
|
|
|
|
+ result = @handler._findBibFileIds(@fakeProject)
|
|
|
|
|
+ expect(result).to.deep.equal @expectedIds
|
|
|
|
|
+
|
|
|
describe '_isFullIndex', ->
|
|
describe '_isFullIndex', ->
|
|
|
|
|
|
|
|
beforeEach ->
|
|
beforeEach ->
|