dillonkearns/elm-pages/12.2.0

NOTE: the latest version is 12.3.0

Test.PagesProgram.SimulatedEffect

Simulated effects for testing. These parallel Elm's Cmd type but are inspectable by the test framework.

Use these with Effect.testPerform to decompose your Effect type into something the test framework can process.

import Test.PagesProgram.SimulatedEffect as SimulatedEffect




-- In your Effect module:
testPerform : Effect msg -> SimulatedEffect msg
testPerform effect =
    case effect of
        None ->
            SimulatedEffect.none


        Cmd _ ->
            -- Opaque Cmds cannot be simulated. Use simulateMsg
            -- in your test to inject the message manually.
            SimulatedEffect.none


        Batch list ->
            SimulatedEffect.batch (List.map testPerform list)


        SendMsg msg ->
            SimulatedEffect.dispatchMsg msg
= None
| Batch (List (SimulatedEffect msg))
| DispatchMsg msg
| SetField
{ formId : String
, name : String
, value : String
}
| SubmitFetcher (Fetcher msg)

A simulated effect that the test framework can inspect and execute.

  • None -- no effect
  • Batch -- multiple effects
  • DispatchMsg msg -- dispatch a message through the update cycle
  • SetField -- set a form field value
  • SubmitFetcher -- submit a fetcher (concurrent form submission)

No effect. Parallels Effect.none.

Also use this for opaque Cmd values that cannot be simulated. Use simulateMsg in your test to inject the message that the Cmd would have produced.

Combine multiple simulated effects. Parallels Effect.batch.

Dispatch a message through the program's update cycle. This is the test-simulatable equivalent of Effect.sendMsg.

testPerform effect =
    case effect of
        SendMsg msg ->
            SimulatedEffect.dispatchMsg msg
{ formId : String
, name : String
, value : String
}

Set a form field value. Parallels Effect.setField.

Submit a fetcher for concurrent form submission. Parallels Effect.submitFetcher.

map : (a -> msg) -> SimulatedEffect a -> SimulatedEffect msg

Transform the messages produced by a simulated effect.