mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
More tests.
This commit is contained in:
parent
86d69f3275
commit
5d80ce9ca5
1 changed files with 30 additions and 6 deletions
|
@ -23,13 +23,37 @@ describe "ReferencesSearchController", ->
|
|||
|
||||
beforeEach ->
|
||||
@req = new MockRequest()
|
||||
@req.params.Project_id = @project_id
|
||||
@res = new MockResponse()
|
||||
@ProjectLocator.findElement.callsArgWith(1, null, {})
|
||||
@ReferencesSearchHandler.indexFile.callsArgWith(2, null)
|
||||
|
||||
it 'should index the file', (done) ->
|
||||
@req.body = {docId: @doc_id}
|
||||
@res.send = (status) =>
|
||||
status.should.equal 200
|
||||
done()
|
||||
@controller.indexFile(@req, @res)
|
||||
describe 'with a valid doc_id', ->
|
||||
|
||||
beforeEach ->
|
||||
@req.body = {docId: @doc_id}
|
||||
|
||||
it 'should produce a 200 response', (done) ->
|
||||
@res.send = (status) =>
|
||||
status.should.equal 200
|
||||
done()
|
||||
@controller.indexFile(@req, @res)
|
||||
|
||||
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 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)
|
||||
|
|
Loading…
Reference in a new issue