mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-23 13:51:11 +00:00
add err and null project test for locating project element
This commit is contained in:
parent
455d78773e
commit
a9660a3a07
2 changed files with 21 additions and 2 deletions
|
@ -92,6 +92,8 @@ module.exports =
|
|||
|
||||
|
||||
Project.getProject project_or_id, "", (err, project)->
|
||||
if err? or !project?
|
||||
return callback("project could not be found for finding a element #{project_or_id}")
|
||||
if needlePath == '' || needlePath == '/'
|
||||
return callback(null, project.rootFolder[0])
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ modulePath = "../../../../app/js/Features/Project/ProjectLocator"
|
|||
SandboxedModule = require('sandboxed-module')
|
||||
sinon = require('sinon')
|
||||
Errors = require "../../../../app/js/errors"
|
||||
|
||||
expect = require("chai").expect
|
||||
Project = class Project
|
||||
|
||||
project = _id : "1234566", rootFolder:[]
|
||||
|
@ -221,6 +221,7 @@ describe 'project model', ->
|
|||
assert.equal element, undefined
|
||||
done()
|
||||
|
||||
|
||||
describe "where duplicate folder exists", ->
|
||||
|
||||
beforeEach ->
|
||||
|
@ -266,7 +267,23 @@ describe 'project model', ->
|
|||
element.name.should.equal "other.tex"
|
||||
done()
|
||||
|
||||
|
||||
|
||||
describe "with a null project", ->
|
||||
beforeEach ->
|
||||
@project =
|
||||
rootFolder:[
|
||||
folders: []
|
||||
fileRefs: []
|
||||
docs: [{name:"main.tex"}, null, {name:"other.tex"}]
|
||||
]
|
||||
Project.getProject = sinon.stub()
|
||||
Project.getProject.callsArgWith(2, null)
|
||||
|
||||
it "should not crash with a null", (done)->
|
||||
callback = sinon.stub()
|
||||
@locator.findElementByPath project._id, "/other.tex", (err, element)->
|
||||
expect(err).to.exist
|
||||
done()
|
||||
|
||||
|
||||
describe 'finding a project by user_id and project name', ()->
|
||||
|
|
Loading…
Reference in a new issue