event_loop.coffee 836 B

12345678910111213141516171819202122232425262728293031323334
  1. require('coffee-script')
  2. chai = require('chai')
  3. should = chai.should()
  4. expect = chai.expect
  5. path = require('path')
  6. modulePath = path.join __dirname, '../../../event_loop.coffee'
  7. SandboxedModule = require('sandboxed-module')
  8. sinon = require("sinon")
  9. describe 'event_loop', ->
  10. before ->
  11. @metrics = {
  12. timing: sinon.stub()
  13. registerDestructor: sinon.stub()
  14. }
  15. @logger = {
  16. warn: sinon.stub()
  17. }
  18. @event_loop = SandboxedModule.require modulePath, requires:
  19. './metrics': @metrics
  20. describe 'with a logger provided', ->
  21. before ->
  22. @event_loop.monitor(@logger)
  23. it 'should register a destructor with metrics', ->
  24. @metrics.registerDestructor.called.should.equal true
  25. describe 'without a logger provided', ->
  26. it 'should throw an exception', ->
  27. expect(@event_loop.monitor).to.throw('logger is undefined')