From 8c87da2d04282e8d33bca17ded69c24286fa4204 Mon Sep 17 00:00:00 2001 From: Dillon Kearns Date: Wed, 9 Mar 2022 09:50:34 -0800 Subject: [PATCH] Fix tests. --- src/Server/Request.elm | 7 ++++++- tests/ServerRequestTest.elm | 13 ++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Server/Request.elm b/src/Server/Request.elm index 57b25631..bbb3c680 100644 --- a/src/Server/Request.elm +++ b/src/Server/Request.elm @@ -888,7 +888,12 @@ expectFormPost toForm = (matchesContentType "application/x-www-form-urlencoded") (matchesMethod ( Post, [] )) (rawBody - |> andThen (\maybeBody -> maybeBody |> Result.fromMaybe "Not a form POST because there is no body." |> fromResult) + |> andThen + (\maybeBody -> + maybeBody + |> Result.fromMaybe "Expected a form POST but this HTTP request has no body." + |> fromResult + ) ) |> andThen (\( validContentType, validMethod, justBody ) -> diff --git a/tests/ServerRequestTest.elm b/tests/ServerRequestTest.elm index 62cfba6b..c041714c 100644 --- a/tests/ServerRequestTest.elm +++ b/tests/ServerRequestTest.elm @@ -54,9 +54,7 @@ all = ] , body = Nothing } - """Did not match formPost because -- Form post must have method POST, but the method was GET -- Forms must have Content-Type application/x-www-form-urlencoded, but the Content-Type was TODO""" + """Expected a form POST but this HTTP request has no body.""" , test "tries multiple form post formats" <| \() -> Request.oneOf @@ -105,16 +103,13 @@ all = } """Server.Request.oneOf failed in the following 4 ways: -(1) Did not match formPost because -- Form post must have method POST, but the method was GET -- Forms must have Content-Type application/x-www-form-urlencoded, but the Content-Type was TODO +(1) Expected a form POST but this HTTP request has no body. -(2) Tried to parse JSON body but the request had no body. +(2) Expected content-type to be application/json but it was application/x-www-form-urlencoded (3) Internal error - expected rawUrl field but the adapter script didn't provide one. -(4) Missing form field 'first' -Expected content-type to be multipart/form-data but it was application/x-www-form-urlencoded +(4) Expected content-type to be multipart/form-data but it was application/x-www-form-urlencoded Expected HTTP method POST but was GET""" ]