event_loop.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * decaffeinate suggestions:
  3. * DS102: Remove unnecessary code created because of implicit returns
  4. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  5. */
  6. const chai = require('chai');
  7. const should = chai.should();
  8. const {
  9. expect
  10. } = chai;
  11. const path = require('path');
  12. const modulePath = path.join(__dirname, '../../../event_loop.js');
  13. const SandboxedModule = require('sandboxed-module');
  14. const sinon = require("sinon");
  15. describe('event_loop', function() {
  16. before(function() {
  17. this.metrics = {
  18. timing: sinon.stub(),
  19. registerDestructor: sinon.stub()
  20. };
  21. this.logger = {
  22. warn: sinon.stub()
  23. };
  24. return this.event_loop = SandboxedModule.require(modulePath, { requires: {
  25. './index': this.metrics
  26. }
  27. }
  28. );
  29. });
  30. describe('with a logger provided', function() {
  31. before(function() {
  32. return this.event_loop.monitor(this.logger);
  33. });
  34. return it('should register a destructor with metrics', function() {
  35. return this.metrics.registerDestructor.called.should.equal(true);
  36. });
  37. });
  38. return describe('without a logger provided', () => it('should throw an exception', function() {
  39. return expect(this.event_loop.monitor).to.throw('logger is undefined');
  40. }));
  41. });