This repository has been archived by the owner on Aug 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from sharelatex/bg-handle-undefined-logger
handle undefined logger in event loop monitor
- Loading branch information
Showing
3 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
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') | ||
|