Start testing ReferencesSearch.

This commit is contained in:
Shane Kilkelly 2015-12-30 15:08:12 +00:00
parent 3bd52f4aaf
commit 86d69f3275
2 changed files with 35 additions and 2 deletions

View file

@ -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 =

View file

@ -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)