|
@@ -30,16 +30,16 @@ describe "ProjectGetter", ->
|
|
|
beforeEach ->
|
|
beforeEach ->
|
|
|
@project =
|
|
@project =
|
|
|
_id: @project_id = "56d46b0a1d3422b87c5ebcb1"
|
|
_id: @project_id = "56d46b0a1d3422b87c5ebcb1"
|
|
|
- @db.projects.find = sinon.stub().callsArgWith(2, null, [@project])
|
|
|
|
|
|
|
+ @ProjectGetter.getProject = sinon.stub().yields()
|
|
|
|
|
|
|
|
describe "passing an id", ->
|
|
describe "passing an id", ->
|
|
|
beforeEach ->
|
|
beforeEach ->
|
|
|
@ProjectGetter.getProjectWithoutDocLines @project_id, @callback
|
|
@ProjectGetter.getProjectWithoutDocLines @project_id, @callback
|
|
|
|
|
|
|
|
it "should call find with the project id", ->
|
|
it "should call find with the project id", ->
|
|
|
- expect(@db.projects.find.lastCall.args[0]).to.deep.equal {
|
|
|
|
|
- _id: ObjectId(@project_id)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ @ProjectGetter.getProject
|
|
|
|
|
+ .calledWith(@project_id)
|
|
|
|
|
+ .should.equal true
|
|
|
|
|
|
|
|
it "should exclude the doc lines", ->
|
|
it "should exclude the doc lines", ->
|
|
|
excludes =
|
|
excludes =
|
|
@@ -51,11 +51,13 @@ describe "ProjectGetter", ->
|
|
|
"rootFolder.folders.folders.folders.folders.folders.docs.lines": 0
|
|
"rootFolder.folders.folders.folders.folders.folders.docs.lines": 0
|
|
|
"rootFolder.folders.folders.folders.folders.folders.folders.docs.lines": 0
|
|
"rootFolder.folders.folders.folders.folders.folders.folders.docs.lines": 0
|
|
|
"rootFolder.folders.folders.folders.folders.folders.folders.folders.docs.lines": 0
|
|
"rootFolder.folders.folders.folders.folders.folders.folders.folders.docs.lines": 0
|
|
|
- @db.projects.find.calledWith(sinon.match.any, excludes)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ @ProjectGetter.getProject
|
|
|
|
|
+ .calledWith(@project_id, excludes)
|
|
|
.should.equal true
|
|
.should.equal true
|
|
|
|
|
|
|
|
- it "should call the callback with the project", ->
|
|
|
|
|
- @callback.calledWith(null, @project).should.equal true
|
|
|
|
|
|
|
+ it "should call the callback", ->
|
|
|
|
|
+ @callback.called.should.equal true
|
|
|
|
|
|
|
|
|
|
|
|
|
describe "getProjectWithOnlyFolders", ->
|
|
describe "getProjectWithOnlyFolders", ->
|
|
@@ -63,16 +65,16 @@ describe "ProjectGetter", ->
|
|
|
beforeEach ()->
|
|
beforeEach ()->
|
|
|
@project =
|
|
@project =
|
|
|
_id: @project_id = "56d46b0a1d3422b87c5ebcb1"
|
|
_id: @project_id = "56d46b0a1d3422b87c5ebcb1"
|
|
|
- @db.projects.find = sinon.stub().callsArgWith(2, null, [@project])
|
|
|
|
|
|
|
+ @ProjectGetter.getProject = sinon.stub().yields()
|
|
|
|
|
|
|
|
describe "passing an id", ->
|
|
describe "passing an id", ->
|
|
|
beforeEach ->
|
|
beforeEach ->
|
|
|
@ProjectGetter.getProjectWithOnlyFolders @project_id, @callback
|
|
@ProjectGetter.getProjectWithOnlyFolders @project_id, @callback
|
|
|
|
|
|
|
|
it "should call find with the project id", ->
|
|
it "should call find with the project id", ->
|
|
|
- expect(@db.projects.find.lastCall.args[0]).to.deep.equal {
|
|
|
|
|
- _id: ObjectId(@project_id)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ @ProjectGetter.getProject
|
|
|
|
|
+ .calledWith(@project_id)
|
|
|
|
|
+ .should.equal true
|
|
|
|
|
|
|
|
it "should exclude the docs and files linesaaaa", ->
|
|
it "should exclude the docs and files linesaaaa", ->
|
|
|
excludes =
|
|
excludes =
|
|
@@ -92,11 +94,12 @@ describe "ProjectGetter", ->
|
|
|
"rootFolder.folders.folders.folders.folders.folders.folders.fileRefs": 0
|
|
"rootFolder.folders.folders.folders.folders.folders.folders.fileRefs": 0
|
|
|
"rootFolder.folders.folders.folders.folders.folders.folders.folders.docs": 0
|
|
"rootFolder.folders.folders.folders.folders.folders.folders.folders.docs": 0
|
|
|
"rootFolder.folders.folders.folders.folders.folders.folders.folders.fileRefs": 0
|
|
"rootFolder.folders.folders.folders.folders.folders.folders.folders.fileRefs": 0
|
|
|
- @db.projects.find.calledWith(sinon.match.any, excludes).should.equal true
|
|
|
|
|
|
|
+ @ProjectGetter.getProject
|
|
|
|
|
+ .calledWith(@project_id, excludes)
|
|
|
|
|
+ .should.equal true
|
|
|
|
|
|
|
|
it "should call the callback with the project", ->
|
|
it "should call the callback with the project", ->
|
|
|
- @callback.calledWith(null, @project).should.equal true
|
|
|
|
|
-
|
|
|
|
|
|
|
+ @callback.called.should.equal true
|
|
|
|
|
|
|
|
|
|
|
|
|
describe "getProject", ->
|
|
describe "getProject", ->
|