mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Test failure conditions.
This commit is contained in:
parent
5d80ce9ca5
commit
ffb149b923
1 changed files with 38 additions and 1 deletions
|
@ -12,7 +12,10 @@ describe "ReferencesSearchController", ->
|
|||
@project_id = '2222'
|
||||
@doc_id = '3333'
|
||||
@controller = SandboxedModule.require modulePath, requires:
|
||||
'logger-sharelatex': {log: ->}
|
||||
'logger-sharelatex': {
|
||||
log: ->
|
||||
err: ->
|
||||
}
|
||||
'settings-sharelatex': @settings = {
|
||||
apis: {web: {url: 'http://some.url'}}
|
||||
}
|
||||
|
@ -57,3 +60,37 @@ describe "ReferencesSearchController", ->
|
|||
@ReferencesSearchHandler.indexFile.calledWith(@project_id, expected_url).should.equal true
|
||||
done()
|
||||
@controller.indexFile(@req, @res)
|
||||
|
||||
describe 'without a doc_id', ->
|
||||
|
||||
beforeEach ->
|
||||
@req.body = {bad: true}
|
||||
|
||||
it 'should produce a 400 response', (done) ->
|
||||
@res.send = (status) =>
|
||||
status.should.equal 400
|
||||
done()
|
||||
@controller.indexFile(@req, @res)
|
||||
|
||||
describe 'when the ProjectLocator cannot find the doc', ->
|
||||
|
||||
beforeEach ->
|
||||
@req.body = {docId: 'some_weird_id'}
|
||||
@ProjectLocator.findElement.callsArgWith(1, new Error('not found'), 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,
|
||||
type: 'doc'
|
||||
@ProjectLocator.findElement.calledWith(arg).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