diff --git a/libraries/metrics/test/unit/coffee/timeAsyncMethodTests.coffee b/libraries/metrics/test/unit/coffee/timeAsyncMethodTests.coffee index 85af8eb9ee..a7f3a83c94 100644 --- a/libraries/metrics/test/unit/coffee/timeAsyncMethodTests.coffee +++ b/libraries/metrics/test/unit/coffee/timeAsyncMethodTests.coffee @@ -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.*$/ + ) + + diff --git a/libraries/metrics/test/unit/js/timeAsyncMethodTests.js b/libraries/metrics/test/unit/js/timeAsyncMethodTests.js index b37ac84320..528e04c2c4 100644 --- a/libraries/metrics/test/unit/js/timeAsyncMethodTests.js +++ b/libraries/metrics/test/unit/js/timeAsyncMethodTests.js @@ -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);