javascript - Testing CSS Transition finished in Jasmine -
i'm trying test bit of javascript using jasmine & jasmine-jquery
so have bit of javascript in function
tracktransition = ()-> $("#test").on "transitionend mstransitionend webkittransitionend otransitionend", ()-> console.log "trans end"
i've applied styes in spec.css add css transition , added html fixture, added in jasmine specs so:
describe "checks when animation finished", -> beforeeach -> @trans = spyonevent('#test', 'transitionend mstransitionend webkittransitionend otransitionend') jasmine.clock.usemock() tracktransition() "should check when transition ended", -> expect(@trans).not.tohavebeentriggered() jasmine.clock.tick(1001) expect(@trans).tohavebeentriggered()
now have tested on page , fires fine, on runner fails , console.log doesn't run. can test transitions?
this cant work cause jasmine.clock
doesn't change time or make test wait 1000ms. overwrites window.settimeout
. whenever call settimeout(somefunction, 1000)
saved passed functions , times. when call tick
calls saved functions time lower passed tick
call.
so way test transitionend event trigger event manually. makes not sense test event fired after specific time, browser behavior rely on.
Comments
Post a Comment