mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
41 lines
1.2 KiB
CoffeeScript
41 lines
1.2 KiB
CoffeeScript
should = require('chai').should()
|
|
modulePath = "../../../../app/js/Features/Project/ProjectApiController"
|
|
SandboxedModule = require('sandboxed-module')
|
|
sinon = require('sinon')
|
|
require('chai').should()
|
|
|
|
describe 'Project api controller', ->
|
|
|
|
beforeEach ->
|
|
@ProjectDetailsHandler =
|
|
getDetails : sinon.stub()
|
|
@controller = SandboxedModule.require modulePath, requires:
|
|
"./ProjectDetailsHandler":@ProjectDetailsHandler
|
|
'logger-sharelatex':
|
|
log:->
|
|
@project_id = "321l3j1kjkjl"
|
|
@req =
|
|
params:
|
|
project_id:@project_id
|
|
session:
|
|
destroy:sinon.stub()
|
|
@res = {}
|
|
@next = sinon.stub()
|
|
@projDetails = {name:"something"}
|
|
|
|
|
|
describe "getProjectDetails", ->
|
|
|
|
it "should ask the project details handler for proj details", (done)->
|
|
@ProjectDetailsHandler.getDetails.callsArgWith(1, null, @projDetails)
|
|
@res.json = (data)=>
|
|
@ProjectDetailsHandler.getDetails.calledWith(@project_id).should.equal true
|
|
data.should.deep.equal @projDetails
|
|
done()
|
|
@controller.getProjectDetails @req, @res
|
|
|
|
|
|
it "should send a 500 if there is an error", ()->
|
|
@ProjectDetailsHandler.getDetails.callsArgWith(1, "error")
|
|
@controller.getProjectDetails @req, @res, @next
|
|
@next.calledWith("error").should.equal true
|