Skip to content

Commit

Permalink
Clear interval during tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelvillar committed Aug 27, 2016
1 parent c2d53fb commit bf1753f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/dynamics.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,15 @@ describe 'dynamics.animate', ->
duration: 100,
type: dynamics.easeInOut
})
setInterval ->
interval = setInterval ->
current = { left: parseFloat(el.style.left), top: parseFloat(el.style.top), transform: el.style.transform }
assert(current.left >= previous.left, "Left should increment")
assert(current.top >= previous.top, "Top should increment")
assert(current.transform != previous.transform or (current.transform == previous.transform && current.transform != "none"), "Transform should change")
previous = current
, 20
setTimeout ->
clearInterval(interval)
done()
, 150

Expand Down Expand Up @@ -239,7 +240,7 @@ describe 'dynamics.animate', ->
}, {
duration: 100
})
setInterval ->
interval = setInterval ->
current = el.getAttribute("points").match(regex)
assert(current?)
expect(parseFloat(current[1])).to.at.most(parseFloat(previous[1]))
Expand All @@ -249,6 +250,7 @@ describe 'dynamics.animate', ->
previous = current
, 20
setTimeout ->
clearInterval(interval)
expect(el.getAttribute("points")).to.be.equal("M50,10 C88.11,20.45")
done()
, 150
Expand Down Expand Up @@ -373,14 +375,15 @@ describe 'dynamics.animate', ->

previousProp = object.prop

setInterval ->
interval = setInterval ->
assert(object.prop >= 0 && object.prop <= 1, "prop is between 0 and 1")
assert(object.prop < previousProp || object.prop == 0, "prop should be decreasing or equal 0")

previousProp = object.prop
, 20

setTimeout ->
clearInterval(interval)
expect(object.prop).to.be.equal(0, 'object.prop has the wrong end value')

done()
Expand Down

0 comments on commit bf1753f

Please sign in to comment.