mirror of
https://github.com/mdgriffith/elm-animator.git
synced 2024-09-11 12:47:52 +03:00
Add more tests for Timeline.arrived
This commit is contained in:
parent
b56c292de8
commit
b44a075341
@ -169,6 +169,7 @@ timelines =
|
||||
|> Animator.Timeline.to (Animator.ms 1000) One
|
||||
|> Timeline.update (Time.millisToPosix 500)
|
||||
|> Animator.Timeline.to (Animator.ms 1000) Two
|
||||
|> Timeline.update (Time.millisToPosix 750)
|
||||
|> Timeline.update (Time.millisToPosix 1000)
|
||||
, twoDuring =
|
||||
Animator.Timeline.init Starting
|
||||
@ -229,8 +230,10 @@ timelines =
|
||||
|> Animator.Timeline.to (Animator.ms 1000) One
|
||||
|> Timeline.update (Time.millisToPosix 500)
|
||||
|> Animator.Timeline.to (Animator.ms 1000) Two
|
||||
-- Two starts at 1000, ending at 2000
|
||||
|> Timeline.update (Time.millisToPosix 1000)
|
||||
|> Animator.Timeline.to (Animator.ms 1000) Three
|
||||
-- Three starts at 1500, ending at 2500
|
||||
|> Timeline.update (Time.millisToPosix 1500)
|
||||
|> Timeline.update (Time.millisToPosix 2501)
|
||||
}
|
||||
@ -471,6 +474,18 @@ arrived =
|
||||
in
|
||||
Expect.equal (Animator.Timeline.arrived timeline)
|
||||
One
|
||||
, test "In transit, arrived value is still previous value" <|
|
||||
\_ ->
|
||||
let
|
||||
timeline =
|
||||
Animator.Timeline.init Starting
|
||||
|> Timeline.update (Time.millisToPosix 0)
|
||||
|> Animator.Timeline.to (Animator.ms 1000) One
|
||||
|> Timeline.update (Time.millisToPosix 0)
|
||||
|> Timeline.update (Time.millisToPosix 500)
|
||||
in
|
||||
Expect.equal (Animator.Timeline.arrived timeline)
|
||||
Starting
|
||||
, test "at value after an interruption" <|
|
||||
\_ ->
|
||||
let
|
||||
@ -515,6 +530,73 @@ arrived =
|
||||
(Animator.Timeline.arrived timelines.double.after)
|
||||
One
|
||||
]
|
||||
, describe "chained updates"
|
||||
[ test "Arrived value is the last value that we've successfully arrived at" <|
|
||||
\_ ->
|
||||
let
|
||||
timeline =
|
||||
Animator.Timeline.init Starting
|
||||
|> Timeline.update (Time.millisToPosix 0)
|
||||
|> Animator.Timeline.to (Animator.ms 1000) One
|
||||
|> Timeline.update (Time.millisToPosix 1)
|
||||
|> Timeline.update (Time.millisToPosix 1020)
|
||||
|> Animator.Timeline.to (Animator.ms 1000) Two
|
||||
|> Timeline.update (Time.millisToPosix 1100)
|
||||
|> Timeline.update (Time.millisToPosix 2210)
|
||||
|> Animator.Timeline.to (Animator.ms 1000) Three
|
||||
|> Timeline.update (Time.millisToPosix 2210)
|
||||
in
|
||||
Expect.equal (Animator.Timeline.arrived timeline)
|
||||
Two
|
||||
, test "Previous value is the *previous* value that we've successfully arrived at, when transitioning to a new thng" <|
|
||||
\_ ->
|
||||
let
|
||||
-- We have arrived at One, and then Arrived at Two
|
||||
-- We are enroute to Three
|
||||
-- So, previous value should be Two
|
||||
timeline =
|
||||
Animator.Timeline.init Starting
|
||||
|> Timeline.update (Time.millisToPosix 0)
|
||||
|> Animator.Timeline.to (Animator.ms 1000) One
|
||||
|> Timeline.update (Time.millisToPosix 1)
|
||||
|> Timeline.update (Time.millisToPosix 1020)
|
||||
|> Animator.Timeline.to (Animator.ms 1000) Two
|
||||
|> Timeline.update (Time.millisToPosix 1100)
|
||||
|> Timeline.update (Time.millisToPosix 2210)
|
||||
|> Animator.Timeline.to (Animator.ms 1000) Three
|
||||
|> Timeline.update (Time.millisToPosix 2211)
|
||||
|> Timeline.update (Time.millisToPosix 2220)
|
||||
in
|
||||
Expect.equal (Animator.Timeline.previous timeline)
|
||||
Two
|
||||
, test "Previous value is the *previous* value when we're dwelling on a value" <|
|
||||
\_ ->
|
||||
let
|
||||
-- We have arrived at One, and then Arrived at Two
|
||||
-- So, previous value should be One
|
||||
timeline =
|
||||
Animator.Timeline.init Starting
|
||||
|> Timeline.update (Time.millisToPosix 0)
|
||||
|> Animator.Timeline.to (Animator.ms 1000) One
|
||||
|> Timeline.update (Time.millisToPosix 1)
|
||||
|> Timeline.update (Time.millisToPosix 1020)
|
||||
|> Animator.Timeline.to (Animator.ms 1000) Two
|
||||
|> Timeline.update (Time.millisToPosix 1100)
|
||||
|> Timeline.update (Time.millisToPosix 2210)
|
||||
|
||||
_ =
|
||||
Debug.log "timeline"
|
||||
{ current = Animator.Timeline.current timeline
|
||||
, previous = Animator.Timeline.previous timeline
|
||||
, arrived = Animator.Timeline.arrived timeline
|
||||
}
|
||||
in
|
||||
Expect.equal
|
||||
(Animator.Timeline.previous
|
||||
timeline
|
||||
)
|
||||
One
|
||||
]
|
||||
, describe "queued"
|
||||
-- queued
|
||||
[ test "begin" <|
|
||||
@ -942,3 +1024,19 @@ arrivedAt =
|
||||
Expect.equal (Animator.Timeline.arrivedAt Two (Time.millisToPosix 2001) timeline)
|
||||
True
|
||||
]
|
||||
|
||||
|
||||
logBounds fn one =
|
||||
let
|
||||
_ =
|
||||
Debug.log " Start --->" "<--"
|
||||
in
|
||||
logMarker " -> end" (fn one)
|
||||
|
||||
|
||||
logMarker label val =
|
||||
let
|
||||
_ =
|
||||
Debug.log label "---"
|
||||
in
|
||||
val
|
||||
|
Loading…
Reference in New Issue
Block a user