mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-26 05:13:24 +03:00
Fix some test cases.
This commit is contained in:
parent
fc4d470405
commit
00edf1cd6e
@ -46,10 +46,7 @@ all =
|
|||||||
(get "https://api.github.com/repos/dillonkearns/elm-pages")
|
(get "https://api.github.com/repos/dillonkearns/elm-pages")
|
||||||
"""{ "stargazer_count": 86 }"""
|
"""{ "stargazer_count": 86 }"""
|
||||||
|> expectSuccess
|
|> expectSuccess
|
||||||
[ ( get "https://api.github.com/repos/dillonkearns/elm-pages"
|
[]
|
||||||
, """{"stargazer_count":86}"""
|
|
||||||
)
|
|
||||||
]
|
|
||||||
, test "StaticHttp request for initial are resolved" <|
|
, test "StaticHttp request for initial are resolved" <|
|
||||||
\() ->
|
\() ->
|
||||||
startSimple
|
startSimple
|
||||||
@ -58,11 +55,7 @@ all =
|
|||||||
|> simulateHttp
|
|> simulateHttp
|
||||||
(get "https://api.github.com/repos/dillonkearns/elm-pages")
|
(get "https://api.github.com/repos/dillonkearns/elm-pages")
|
||||||
"""{ "stargazer_count": 86 }"""
|
"""{ "stargazer_count": 86 }"""
|
||||||
|> expectSuccess
|
|> expectSuccess []
|
||||||
[ ( get "https://api.github.com/repos/dillonkearns/elm-pages"
|
|
||||||
, """{"stargazer_count":86}"""
|
|
||||||
)
|
|
||||||
]
|
|
||||||
, describe "single page renders"
|
, describe "single page renders"
|
||||||
[ test "single pages that are pre-rendered" <|
|
[ test "single pages that are pre-rendered" <|
|
||||||
\() ->
|
\() ->
|
||||||
@ -121,11 +114,7 @@ all =
|
|||||||
|> simulateHttp
|
|> simulateHttp
|
||||||
(get "https://api.github.com/repos/dillonkearns/elm-pages")
|
(get "https://api.github.com/repos/dillonkearns/elm-pages")
|
||||||
"""{ "stargazer_count": 86, "language": "Elm" }"""
|
"""{ "stargazer_count": 86, "language": "Elm" }"""
|
||||||
|> expectSuccess
|
|> expectSuccess []
|
||||||
[ ( get "https://api.github.com/repos/dillonkearns/elm-pages"
|
|
||||||
, """{"stargazer_count":86,"language":"Elm"}"""
|
|
||||||
)
|
|
||||||
]
|
|
||||||
, test "andThen" <|
|
, test "andThen" <|
|
||||||
\() ->
|
\() ->
|
||||||
startSimple
|
startSimple
|
||||||
@ -142,14 +131,7 @@ all =
|
|||||||
|> simulateHttp
|
|> simulateHttp
|
||||||
(get "NEXT-REQUEST")
|
(get "NEXT-REQUEST")
|
||||||
"""null"""
|
"""null"""
|
||||||
|> expectSuccess
|
|> expectSuccess []
|
||||||
[ ( get "https://api.github.com/repos/dillonkearns/elm-pages"
|
|
||||||
, """null"""
|
|
||||||
)
|
|
||||||
, ( get "NEXT-REQUEST"
|
|
||||||
, """null"""
|
|
||||||
)
|
|
||||||
]
|
|
||||||
, skip <|
|
, skip <|
|
||||||
test "andThen chain avoids repeat requests" <|
|
test "andThen chain avoids repeat requests" <|
|
||||||
\() ->
|
\() ->
|
||||||
@ -293,41 +275,31 @@ all =
|
|||||||
-- ]
|
-- ]
|
||||||
-- )
|
-- )
|
||||||
-- ]
|
-- ]
|
||||||
, skip <|
|
, test "reduced JSON is sent out" <|
|
||||||
test "reduced JSON is sent out" <|
|
\() ->
|
||||||
\() ->
|
startSimple []
|
||||||
startSimple []
|
(DataSource.Http.get "https://api.github.com/repos/dillonkearns/elm-pages" (JD.field "stargazer_count" JD.int))
|
||||||
(DataSource.Http.get "https://api.github.com/repos/dillonkearns/elm-pages" (JD.field "stargazer_count" JD.int))
|
|> simulateHttp
|
||||||
|> simulateHttp
|
(get "https://api.github.com/repos/dillonkearns/elm-pages")
|
||||||
(get "https://api.github.com/repos/dillonkearns/elm-pages")
|
"""{ "stargazer_count": 86, "unused_field": 123 }"""
|
||||||
"""{ "stargazer_count": 86, "unused_field": 123 }"""
|
|> expectSuccess []
|
||||||
|> expectSuccess
|
, test "you can use elm/json decoders with StaticHttp.unoptimizedRequest" <|
|
||||||
[ ( get "https://api.github.com/repos/dillonkearns/elm-pages"
|
\() ->
|
||||||
, """{"stargazer_count":86}"""
|
startSimple []
|
||||||
)
|
(DataSource.Http.request
|
||||||
]
|
{ url = "https://api.github.com/repos/dillonkearns/elm-pages"
|
||||||
, skip <|
|
, method = "GET"
|
||||||
test "you can use elm/json decoders with StaticHttp.unoptimizedRequest" <|
|
, headers = []
|
||||||
\() ->
|
, body = DataSource.Http.emptyBody
|
||||||
startSimple []
|
}
|
||||||
(DataSource.Http.request
|
(DataSource.Http.expectJson
|
||||||
{ url = "https://api.github.com/repos/dillonkearns/elm-pages"
|
(JD.field "stargazer_count" JD.int)
|
||||||
, method = "GET"
|
|
||||||
, headers = []
|
|
||||||
, body = DataSource.Http.emptyBody
|
|
||||||
}
|
|
||||||
(DataSource.Http.expectJson
|
|
||||||
(JD.field "stargazer_count" JD.int)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|> simulateHttp
|
)
|
||||||
(get "https://api.github.com/repos/dillonkearns/elm-pages")
|
|> simulateHttp
|
||||||
"""{ "stargazer_count": 86, "unused_field": 123 }"""
|
(get "https://api.github.com/repos/dillonkearns/elm-pages")
|
||||||
|> expectSuccess
|
"""{ "stargazer_count": 86, "unused_field": 123 }"""
|
||||||
[ ( get "https://api.github.com/repos/dillonkearns/elm-pages"
|
|> expectSuccess []
|
||||||
, """{ "stargazer_count": 86, "unused_field": 123 }"""
|
|
||||||
)
|
|
||||||
]
|
|
||||||
, skip <|
|
, skip <|
|
||||||
test "plain string" <|
|
test "plain string" <|
|
||||||
\() ->
|
\() ->
|
||||||
@ -407,30 +379,22 @@ String was not uppercased"""
|
|||||||
, """{"stargazer_count":86}"""
|
, """{"stargazer_count":86}"""
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
, skip <|
|
, test "json is reduced from andThen chains" <|
|
||||||
test "json is reduced from andThen chains" <|
|
\() ->
|
||||||
\() ->
|
startSimple []
|
||||||
startSimple []
|
(DataSource.Http.get "https://api.github.com/repos/dillonkearns/elm-pages" (JD.field "stargazer_count" JD.int)
|
||||||
(DataSource.Http.get "https://api.github.com/repos/dillonkearns/elm-pages" (JD.field "stargazer_count" JD.int)
|
|> DataSource.andThen
|
||||||
|> DataSource.andThen
|
(\_ ->
|
||||||
(\_ ->
|
DataSource.Http.get "https://api.github.com/repos/dillonkearns/elm-pages-starter" (JD.field "stargazer_count" JD.int)
|
||||||
DataSource.Http.get "https://api.github.com/repos/dillonkearns/elm-pages-starter" (JD.field "stargazer_count" JD.int)
|
)
|
||||||
)
|
)
|
||||||
)
|
|> simulateHttp
|
||||||
|> simulateHttp
|
(get "https://api.github.com/repos/dillonkearns/elm-pages")
|
||||||
(get "https://api.github.com/repos/dillonkearns/elm-pages")
|
"""{ "stargazer_count": 100, "unused_field": 123 }"""
|
||||||
"""{ "stargazer_count": 100, "unused_field": 123 }"""
|
|> simulateHttp
|
||||||
|> simulateHttp
|
(get "https://api.github.com/repos/dillonkearns/elm-pages-starter")
|
||||||
(get "https://api.github.com/repos/dillonkearns/elm-pages-starter")
|
"""{ "stargazer_count": 50, "unused_field": 456 }"""
|
||||||
"""{ "stargazer_count": 50, "unused_field": 456 }"""
|
|> expectSuccess []
|
||||||
|> expectSuccess
|
|
||||||
[ ( get "https://api.github.com/repos/dillonkearns/elm-pages"
|
|
||||||
, """{"stargazer_count":100}"""
|
|
||||||
)
|
|
||||||
, ( get "https://api.github.com/repos/dillonkearns/elm-pages-starter"
|
|
||||||
, """{"stargazer_count":50}"""
|
|
||||||
)
|
|
||||||
]
|
|
||||||
, skip <|
|
, skip <|
|
||||||
test "reduced json is preserved by StaticHttp.map2" <|
|
test "reduced json is preserved by StaticHttp.map2" <|
|
||||||
\() ->
|
\() ->
|
||||||
@ -447,14 +411,7 @@ String was not uppercased"""
|
|||||||
, """{ "stargazer_count": 50, "unused_field": 456 }"""
|
, """{ "stargazer_count": 50, "unused_field": 456 }"""
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|> expectSuccess
|
|> expectSuccess []
|
||||||
[ ( get "https://api.github.com/repos/dillonkearns/elm-pages"
|
|
||||||
, """{"stargazer_count":100}"""
|
|
||||||
)
|
|
||||||
, ( get "https://api.github.com/repos/dillonkearns/elm-pages-starter"
|
|
||||||
, """{"stargazer_count":50}"""
|
|
||||||
)
|
|
||||||
]
|
|
||||||
, skip <|
|
, skip <|
|
||||||
test "the port sends out even if there are no http requests" <|
|
test "the port sends out even if there are no http requests" <|
|
||||||
\() ->
|
\() ->
|
||||||
@ -1184,7 +1141,7 @@ simulateHttp request response program =
|
|||||||
, ( "response"
|
, ( "response"
|
||||||
, Encode.object
|
, Encode.object
|
||||||
[ ( "bodyKind", Encode.string "json" )
|
[ ( "bodyKind", Encode.string "json" )
|
||||||
, ( "body", Encode.string response )
|
, ( "body", JD.decodeString JD.value response |> Result.withDefault Encode.null )
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user