MongoManagerTests.coffee 823 B

123456789101112131415161718192021222324252627
  1. SandboxedModule = require('sandboxed-module')
  2. sinon = require('sinon')
  3. require('chai').should()
  4. modulePath = require('path').join __dirname, '../../../app/js/MongoManager'
  5. ObjectId = require("mongojs").ObjectId
  6. describe "MongoManager", ->
  7. beforeEach ->
  8. @MongoManager = SandboxedModule.require modulePath, requires:
  9. "./mongojs":
  10. db: @db = { projects: {} }
  11. ObjectId: ObjectId
  12. @project_id = ObjectId().toString()
  13. @callback = sinon.stub()
  14. describe "findProject", ->
  15. beforeEach ->
  16. @project = { name: "mock-project" }
  17. @db.projects.find = sinon.stub().callsArgWith(2, null, [@project])
  18. @MongoManager.findProject @project_id, @callback
  19. it "should find the project without the doc lines", ->
  20. @db.projects.find
  21. .calledWith({
  22. _id: ObjectId(@project_id)
  23. }, {})
  24. .should.equal true