Simulated subscriptions for testing. These parallel Elm's Sub type
but are inspectable by the test framework.
Use these with PagesProgram.withSimulatedSubscriptions
to register subscriptions, then send data through them with
PagesProgram.simulateIncomingPort.
import Test.PagesProgram.SimulatedSub as SimulatedSub
-- In your test setup:
|> PagesProgram.withSimulatedSubscriptions
(\model ->
if model.isConnected then
SimulatedSub.port_ "websocketData"
(Decode.string |> Decode.map GotMessage)
else
SimulatedSub.none
)No subscription. Parallels Sub.none.
Combine multiple subscriptions. Parallels Sub.batch.
Subscribe to an incoming port. Provide the port name and a decoder that produces your message type.
SimulatedSub.port_ "websocketData"
(Decode.string |> Decode.map GotMessage)Transform the messages produced by a subscription.
A simulated subscription that the test framework can inspect and trigger.