This module provides functions that allow you to create SimulatedEffects
that parallel Elm ports used in your real program.
This is meant to be used
to help you implement the function to provide when using
ProgramTest.withSimulatedEffects
and ProgramTest.withSimulatedSubscriptions.
For a detailed example, see the “Testing programs with ports” guidebook.
Creates a SimulatedSub that parallels using an incoming Elm port.
For example, if your production code uses a port like this:
port activeUsers : (List String -> msg) -> Sub msg
subscriptions : Model -> Sub Msg
subscriptions model =
activeUsers OnActiveUsersLoadedThen the corresponding SimulatedSub would be:
simulatedSubscriptions : Model -> SimulatedSub Msg
simulatedSubscriptions model =
SimulatedEffect.Ports.subscribe
"activeUsers"
(Json.Decode.list Json.Decode.string)
OnActiveUsersLoaded
Creates a
SimulatedEffectthat parallels using an outgoing Elm port.For example, if your production code uses a port like this:
Then the corresponding
SimulatedEffectwould be: