spur-common
Version:
A Node.JS library of common modules used as a base to most Node.JS applications.
23 lines (16 loc) • 530 B
text/coffeescript
describe "Timer", ->
beforeEach ()->
injector().inject (@Timer, @nodeProcess)=>
@hrtimeStub = sinon.stub(@nodeProcess, "hrtime")
@hrtimeStub.onCall(0).returns([ 7973, 560332779])
@hrtimeStub.onCall(1).returns([ 0, 1065832 ])
afterEach ()->
@hrtimeStub.restore()
it "test timer", ->
timer = new @Timer().start()
duration = timer.stop()
expect(duration).to.equal 1.066
it "mockDuration()", ->
@Timer.mockDuration(22)
expect(new @Timer().start().stop())
.to.equal 22