Files
Verso/services/web/test/unit/src/Project/ProjectApiControllerTests.js
T
Eric Mc Sween 9ddaa8c9f6 Merge pull request #3830 from overleaf/em-upgrade-node-12
Upgrade to Node 12

GitOrigin-RevId: 19870922884b7c98e7e5f2c94df21829672d2db5
2021-04-01 02:05:52 +00:00

63 lines
1.9 KiB
JavaScript

/* eslint-disable
max-len,
no-return-assign,
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const modulePath = '../../../../app/src/Features/Project/ProjectApiController'
const SandboxedModule = require('sandboxed-module')
const sinon = require('sinon')
describe('Project api controller', function() {
beforeEach(function() {
this.ProjectDetailsHandler = { getDetails: sinon.stub() }
this.controller = SandboxedModule.require(modulePath, {
requires: {
'./ProjectDetailsHandler': this.ProjectDetailsHandler
}
})
this.project_id = '321l3j1kjkjl'
this.req = {
params: {
project_id: this.project_id
},
session: {
destroy: sinon.stub()
}
}
this.res = {}
this.next = sinon.stub()
return (this.projDetails = { name: 'something' })
})
describe('getProjectDetails', function() {
it('should ask the project details handler for proj details', function(done) {
this.ProjectDetailsHandler.getDetails.callsArgWith(
1,
null,
this.projDetails
)
this.res.json = data => {
this.ProjectDetailsHandler.getDetails
.calledWith(this.project_id)
.should.equal(true)
data.should.deep.equal(this.projDetails)
return done()
}
return this.controller.getProjectDetails(this.req, this.res)
})
it('should send a 500 if there is an error', function() {
this.ProjectDetailsHandler.getDetails.callsArgWith(1, 'error')
this.controller.getProjectDetails(this.req, this.res, this.next)
return this.next.calledWith('error').should.equal(true)
})
})
})