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

27 lines
697 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 (..)
2021-04-03 07:43:57 +03:00
import SimulatedEffect.Http
2021-04-03 07:43:57 +03:00
expectString : (Result Error String -> msg) -> SimulatedEffect.Http.Expect msg
expectString toMsg =
2021-04-03 07:43:57 +03:00
SimulatedEffect.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)
2021-04-03 00:44:40 +03:00
GoodStatus_ _ body ->
Ok body