Closed dotnetspec closed 7 months ago
If you're using Time.every
in your subscriptions
function to update your model as the time changes, you'll need to update the setup of your spec to provide your subscriptions
function -- I don't currently see that in the example code you provided.
So you would do something like:
(given
(Setup.init (Sched.init testFlags)
|> Spec.Time.withTime 1709042943000 -- Date and time (GMT): Tuesday, February 27, 2024 2:09:03 PM
|> Setup.withUpdate Sched.update
|> Setup.withSubscriptions Sched.subscriptions -- <-- ***THIS PART IS NEW***
|> Setup.withView Sched.view
|> Stub.serve
[ successfulAccessTokenStub
, successfulTimeSlotsStub27_Feb_2024_14_09
]
)
)
I've updated the example repo with a spec that uses Spec.Time.tick
to illustrate what I mean:
https://github.com/brian-watkins/elm-spec-example/blob/main/specs/src/TimeSpec.elm
I looked at the documentation and noticed that the example provided on the docs for Spec.Time
is actually missing the line that provides the subscriptions
function during the setup. Apologies for that. Maybe I can correct that and publish a new version so others won't be tripped up by this.
Thanks, that fixed it ...
I'm attempting to pass the following scenario and it appears that Spec.Time.tick is exactly what I need:
However, the console log indicates that the first timeslot is 'clicked', but that the datetime in the model, that represents 'current time', is still the same as at the beginning of the test i.e.
|> Spec.Time.withTime 1709042943000 -- Date and time (GMT): Tuesday, February 27, 2024 2:09:03 PM.
It therefore appears that
hasn't effectively moved the time on by 2 hours in my app.
This is how Tick is defined in the update function:
What else should I be looking into to simulate the passage of 2 hours in the app before clicking on a redundant timeslot?
Thanks ...