mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-04 14:49:01 +02:00
Test failure to wrap method
This commit is contained in:
@@ -77,3 +77,13 @@ describe 'timeAsyncMethod', ->
|
||||
expect(@Timer.done.callCount).to.equal 1
|
||||
expect(@logger.log.callCount).to.equal 1
|
||||
done()
|
||||
|
||||
describe 'when the wrapper cannot be applied', ->
|
||||
beforeEach ->
|
||||
|
||||
it 'should raise an error', ->
|
||||
badWrap = () =>
|
||||
@timeAsyncMethod @testObject, 'DEFINITELY_NOT_A_REAL_METHOD', 'test.nextNumber'
|
||||
expect(badWrap).to.throw(
|
||||
/^.*expected object property 'DEFINITELY_NOT_A_REAL_METHOD' to be a function.*$/
|
||||
)
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
})(this));
|
||||
});
|
||||
});
|
||||
return describe('when a logger is supplied', function() {
|
||||
describe('when a logger is supplied', function() {
|
||||
beforeEach(function() {
|
||||
return this.logger = {
|
||||
log: sinon.stub()
|
||||
@@ -108,6 +108,18 @@
|
||||
})(this));
|
||||
});
|
||||
});
|
||||
return describe('when the wrapper cannot be applied', function() {
|
||||
beforeEach(function() {});
|
||||
return it('should raise an error', function() {
|
||||
var badWrap;
|
||||
badWrap = (function(_this) {
|
||||
return function() {
|
||||
return _this.timeAsyncMethod(_this.testObject, 'DEFINITELY_NOT_A_REAL_METHOD', 'test.nextNumber');
|
||||
};
|
||||
})(this);
|
||||
return expect(badWrap).to["throw"](/^.*expected object property 'DEFINITELY_NOT_A_REAL_METHOD' to be a function.*$/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
|
||||
@@ -3,7 +3,7 @@ module.exports = (obj, methodName, key, logger) ->
|
||||
metrics = require('./metrics')
|
||||
|
||||
if typeof obj[methodName] != 'function'
|
||||
throw new Error("[Metrics] expected object property #{methodName} to be a function")
|
||||
throw new Error("[Metrics] expected object property '#{methodName}' to be a function")
|
||||
|
||||
realMethod = obj[methodName]
|
||||
key = "methods.#{key}"
|
||||
|
||||
Reference in New Issue
Block a user