elm-pages-v3-beta/tests/PagesHttp.elm
2021-04-02 14:44:40 -07:00

27 lines
673 B
Elm

module PagesHttp exposing (..)
import Http exposing (Response(..))
import Pages.Http exposing (..)
import SimulatedEffect.Http as Http
expectString : (Result Error String -> msg) -> Http.Expect msg
expectString toMsg =
Http.expectStringResponse toMsg <|
\response ->
case response of
BadUrl_ url ->
Err (BadUrl url)
Timeout_ ->
Err Timeout
NetworkError_ ->
Err NetworkError
BadStatus_ metadata body ->
Err (BadStatus metadata body)
GoodStatus_ _ body ->
Ok body