mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-25 17:01:28 +00:00
35 lines
836 B
CoffeeScript
35 lines
836 B
CoffeeScript
|
require('coffee-script')
|
||
|
chai = require('chai')
|
||
|
should = chai.should()
|
||
|
expect = chai.expect
|
||
|
path = require('path')
|
||
|
modulePath = path.join __dirname, '../../../event_loop.coffee'
|
||
|
SandboxedModule = require('sandboxed-module')
|
||
|
sinon = require("sinon")
|
||
|
|
||
|
describe 'event_loop', ->
|
||
|
|
||
|
before ->
|
||
|
@metrics = {
|
||
|
timing: sinon.stub()
|
||
|
registerDestructor: sinon.stub()
|
||
|
}
|
||
|
@logger = {
|
||
|
warn: sinon.stub()
|
||
|
}
|
||
|
@event_loop = SandboxedModule.require modulePath, requires:
|
||
|
'./metrics': @metrics
|
||
|
|
||
|
describe 'with a logger provided', ->
|
||
|
before ->
|
||
|
@event_loop.monitor(@logger)
|
||
|
|
||
|
it 'should register a destructor with metrics', ->
|
||
|
@metrics.registerDestructor.called.should.equal true
|
||
|
|
||
|
describe 'without a logger provided', ->
|
||
|
|
||
|
it 'should throw an exception', ->
|
||
|
expect(@event_loop.monitor).to.throw('logger is undefined')
|
||
|
|