brian-watkins/elm-spec/3.0.0

NOTE: the latest version is 3.3.2

Spec.Time

Functions for working with time during a spec.

Suppose you use Time.every to increment a count in your model after each second. Here's a spec you could use to describe that behavior:

Spec.describe "seconds counter"
[ Spec.scenario "some seconds pass" (
    Spec.given (
      Spec.Setup.init (App.init testFlags)
        |> Spec.Setup.withView App.view
        |> Spec.Setup.withUpdate App.update
    )
    |> when "some time passes"
      [ Spec.Time.tick 3000
      ]
    |> it "increments the counter" (
      Spec.Observer.observeModel .seconds
        |> Spec.expect (Spec.Claim.isEqual Debug.toString 3)
    )
  )
]

Set Up at a Time

withTime : Int -> Setup model msg -> Setup model msg

Set up the scenario at a particular time.

Provide the number of milliseconds since the UNIX epoch.

withTimezoneOffset : Int -> Setup model msg -> Setup model msg

Set up the scenario at a particular timezone offset.

Provide the timezone offste in minutes.

Pass the Time

tick : Int -> Step model msg

A step that simulates waiting for some number of milliseconds to pass.

Any subscriptions that depend on the passage of time will be triggered as expected.

nextAnimationFrame : Step model msg

A step that simulates waiting for the next animation frame.

Any subscriptions that depend on animation frame updates will be triggered as expected.