elm-pages-v3-beta/tests/PagesHttp.elm

27 lines
691 B
Elm
Raw Normal View History

module PagesHttp exposing (..)
2021-04-02 23:59:07 +03:00
import Http exposing (Response(..))
import Pages.Http exposing (..)
import SimulatedEffect.Http as Http
expectString : (Result Pages.Http.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_ metadata body ->
Ok body