mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Test remaining failure cases.
This commit is contained in:
parent
ffb149b923
commit
877ea1d376
1 changed files with 23 additions and 1 deletions
|
@ -77,13 +77,14 @@ describe "ReferencesSearchController", ->
|
|||
beforeEach ->
|
||||
@req.body = {docId: 'some_weird_id'}
|
||||
@ProjectLocator.findElement.callsArgWith(1, new Error('not found'), null)
|
||||
@ReferencesSearchHandler.indexFile.callsArgWith(2, null)
|
||||
|
||||
it 'should call ProjectLocator.findElement', (done) ->
|
||||
@res.send = (status) =>
|
||||
@ProjectLocator.findElement.calledOnce.should.equal true
|
||||
arg =
|
||||
project_id: @project_id
|
||||
element_id: @doc_id,
|
||||
element_id: 'some_weird_id',
|
||||
type: 'doc'
|
||||
@ProjectLocator.findElement.calledWith(arg).should.equal true
|
||||
done()
|
||||
|
@ -94,3 +95,24 @@ describe "ReferencesSearchController", ->
|
|||
status.should.equal 500
|
||||
done()
|
||||
@controller.indexFile(@req, @res)
|
||||
|
||||
describe 'when the ReferencesSearchHandler produces an error', ->
|
||||
|
||||
beforeEach ->
|
||||
@req.body = {docId: @doc_id}
|
||||
@ProjectLocator.findElement.callsArgWith(1, null, {})
|
||||
@ReferencesSearchHandler.indexFile.callsArgWith(2, new Error('something went wrong'))
|
||||
|
||||
it 'should call ReferencesSearchHandler.indexFile', (done) ->
|
||||
@res.send = (status) =>
|
||||
@ReferencesSearchHandler.indexFile.calledOnce.should.equal true
|
||||
expected_url = "http://some.url/project/2222/doc/3333"
|
||||
@ReferencesSearchHandler.indexFile.calledWith(@project_id, expected_url).should.equal true
|
||||
done()
|
||||
@controller.indexFile(@req, @res)
|
||||
|
||||
it 'should produce a 500 response', (done) ->
|
||||
@res.send = (status) =>
|
||||
status.should.equal 500
|
||||
done()
|
||||
@controller.indexFile(@req, @res)
|
||||
|
|
Loading…
Reference in a new issue