Test failure when wrapped method is not async/callback

This commit is contained in:
Shane Kilkelly 2017-03-16 10:07:52 +00:00
parent a5aec5b812
commit 772f950d7c
2 changed files with 33 additions and 1 deletions

View file

@ -87,3 +87,18 @@ describe 'timeAsyncMethod', ->
expect(badWrap).to.throw(
/^.*expected object property 'DEFINITELY_NOT_A_REAL_METHOD' to be a function.*$/
)
describe 'when the wrapped function is not using a callback', ->
beforeEach ->
@testObject.nextNumber = (n) ->
return n+1
it 'should throw an error', ->
@timeAsyncMethod @testObject, 'nextNumber', 'test.nextNumber'
badCall = () =>
@testObject.nextNumber 2
expect(badCall).to.throw(
/^.*expected wrapped method 'nextNumber' to be invoked with a callback.*$/
)

View file

@ -108,7 +108,7 @@
})(this));
});
});
return describe('when the wrapper cannot be applied', function() {
describe('when the wrapper cannot be applied', function() {
beforeEach(function() {});
return it('should raise an error', function() {
var badWrap;
@ -120,6 +120,23 @@
return expect(badWrap).to["throw"](/^.*expected object property 'DEFINITELY_NOT_A_REAL_METHOD' to be a function.*$/);
});
});
return describe('when the wrapped function is not using a callback', function() {
beforeEach(function() {
return this.testObject.nextNumber = function(n) {
return n + 1;
};
});
return it('should throw an error', function() {
var badCall;
this.timeAsyncMethod(this.testObject, 'nextNumber', 'test.nextNumber');
badCall = (function(_this) {
return function() {
return _this.testObject.nextNumber(2);
};
})(this);
return expect(badCall).to["throw"](/^.*expected wrapped method 'nextNumber' to be invoked with a callback.*$/);
});
});
});
}).call(this);