mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-23 14:44:24 +00:00
Start testing ReferencesSearch.
This commit is contained in:
parent
3bd52f4aaf
commit
86d69f3275
2 changed files with 35 additions and 2 deletions
|
@ -2,8 +2,6 @@ logger = require('logger-sharelatex')
|
|||
ReferencesSearchHandler = require('./ReferencesSearchHandler')
|
||||
ProjectLocator = require("../Project/ProjectLocator")
|
||||
settings = require('settings-sharelatex')
|
||||
U = require('underscore')
|
||||
|
||||
|
||||
module.exports = ReferencesSearchController =
|
||||
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
SandboxedModule = require('sandboxed-module')
|
||||
should = require('chai').should()
|
||||
sinon = require 'sinon'
|
||||
assert = require("chai").assert
|
||||
modulePath = "../../../../app/js/Features/ReferencesSearch/ReferencesSearchController"
|
||||
MockRequest = require "../helpers/MockRequest"
|
||||
MockResponse = require "../helpers/MockResponse"
|
||||
|
||||
describe "ReferencesSearchController", ->
|
||||
|
||||
beforeEach ->
|
||||
@project_id = '2222'
|
||||
@doc_id = '3333'
|
||||
@controller = SandboxedModule.require modulePath, requires:
|
||||
'logger-sharelatex': {log: ->}
|
||||
'settings-sharelatex': @settings = {
|
||||
apis: {web: {url: 'http://some.url'}}
|
||||
}
|
||||
'../Project/ProjectLocator': @ProjectLocator = {findElement: sinon.stub()}
|
||||
'./ReferencesSearchHandler': @ReferencesSearchHandler = {indexFile: sinon.stub(), getKeys: sinon.stub()}
|
||||
|
||||
describe 'indexFile', ->
|
||||
|
||||
beforeEach ->
|
||||
@req = new MockRequest()
|
||||
@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)
|
Loading…
Reference in a new issue