ProjectUpdateHandlerTests.coffee 804 B

123456789101112131415161718192021222324
  1. sinon = require('sinon')
  2. chai = require('chai').should()
  3. modulePath = "../../../../app/js/Features/Project/ProjectUpdateHandler.js"
  4. SandboxedModule = require('sandboxed-module')
  5. describe 'updating a project', ->
  6. beforeEach ->
  7. @ProjectModel = class Project
  8. @ProjectModel.update = sinon.stub().callsArg(3)
  9. @handler = SandboxedModule.require modulePath, requires:
  10. '../../models/Project':{Project:@ProjectModel}
  11. describe 'marking a project as recently updated', ->
  12. it 'should send an update to mongo', (done)->
  13. project_id = "project_id"
  14. @handler.markAsUpdated project_id, (err)=>
  15. args = @ProjectModel.update.args[0]
  16. args[0]._id.should.equal project_id
  17. date = args[1].lastUpdated+""
  18. now = Date.now()+""
  19. date.substring(0,5).should.equal now.substring(0,5)
  20. done()