|
@@ -90,8 +90,8 @@ describe 'timeAsyncMethod', ->
|
|
|
|
|
|
|
|
describe 'when the wrapped function is not using a callback', ->
|
|
describe 'when the wrapped function is not using a callback', ->
|
|
|
beforeEach ->
|
|
beforeEach ->
|
|
|
- @testObject.nextNumber = (n) ->
|
|
|
|
|
- return n+1
|
|
|
|
|
|
|
+ @realMethod = sinon.stub().returns(42)
|
|
|
|
|
+ @testObject.nextNumber = @realMethod
|
|
|
|
|
|
|
|
it 'should not throw an error', ->
|
|
it 'should not throw an error', ->
|
|
|
@timeAsyncMethod @testObject, 'nextNumber', 'test.nextNumber'
|
|
@timeAsyncMethod @testObject, 'nextNumber', 'test.nextNumber'
|
|
@@ -99,4 +99,11 @@ describe 'timeAsyncMethod', ->
|
|
|
@testObject.nextNumber 2
|
|
@testObject.nextNumber 2
|
|
|
expect(badCall).to.not.throw(Error)
|
|
expect(badCall).to.not.throw(Error)
|
|
|
|
|
|
|
|
|
|
+ it 'should call the underlying method', ->
|
|
|
|
|
+ @timeAsyncMethod @testObject, 'nextNumber', 'test.nextNumber'
|
|
|
|
|
+ result = @testObject.nextNumber(12)
|
|
|
|
|
+ expect(@realMethod.callCount).to.equal 1
|
|
|
|
|
+ expect(@realMethod.calledWith(12)).to.equal true
|
|
|
|
|
+ expect(result).to.equal 42
|
|
|
|
|
+
|
|
|
|
|
|