This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.

Testable.Cmd

Testable.Cmd is a replacement for the core Cmd module. You can use it to create components that can be tested with Testable.TestContext. You can convert Testable.Cmd into a core Cmd with the Testable module.

type alias Cmd msg = Internal.Cmd msg
map : (a -> b) -> Cmd a -> Cmd b
batch : List (Cmd msg) -> Cmd msg
none : Cmd never
module Testable.Cmd exposing (Cmd, none, batch, map)

{-|
`Testable.Cmd` is a replacement for the core `Cmd` module.  You can use it
to create components that can be tested with `Testable.TestContext`.  You can
convert `Testable.Cmd` into a core `Cmd` with the `Testable` module.

@docs Cmd, map, batch, none
-}

import Testable.Internal as Internal
import Testable.Task as Task exposing (Task)


{-| -}
type alias Cmd msg =
    Internal.Cmd msg


{-| -}
none : Cmd never
none =
    Internal.None


{-| -}
batch : List (Cmd msg) -> Cmd msg
batch effectsList =
    Internal.Batch effectsList


{-| -}
map : (a -> b) -> Cmd a -> Cmd b
map f source =
    case source of
        Internal.None ->
            Internal.None

        Internal.TaskCmd wrapped ->
            wrapped
                |> Task.map f
                |> Task.mapError f
                |> Internal.TaskCmd

        Internal.Batch list ->
            Internal.Batch (List.map (map f) list)