mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-25 04:43:03 +03:00
Add a toString in the build error decoder for the test assertions.
This commit is contained in:
parent
d04d670669
commit
fbc161c77b
@ -9,6 +9,7 @@ import Json.Encode
|
||||
import Pages.ImagePath as ImagePath
|
||||
import Pages.Manifest as Manifest
|
||||
import Pages.PagePath as PagePath
|
||||
import TerminalText
|
||||
|
||||
|
||||
type ToJsPayload
|
||||
@ -88,20 +89,13 @@ toJsCodec =
|
||||
|
||||
errorCodec : Codec (List BuildError)
|
||||
errorCodec =
|
||||
Codec.object (\_ _ -> [])
|
||||
Codec.object (\errorString _ -> errorString)
|
||||
|> Codec.field "errorString"
|
||||
identity
|
||||
(Codec.string
|
||||
|> Codec.map
|
||||
(\_ ->
|
||||
[ { title = "TODO"
|
||||
, message = []
|
||||
, fatal = True
|
||||
, path = ""
|
||||
}
|
||||
]
|
||||
)
|
||||
BuildError.errorsToString
|
||||
(Codec.build (BuildError.errorsToString >> Json.Encode.string)
|
||||
(Decode.string
|
||||
|> Decode.map (\value -> [ { title = value, path = "Intentionally empty", message = [], fatal = False } ])
|
||||
)
|
||||
)
|
||||
|> Codec.field "errorsJson"
|
||||
identity
|
||||
@ -112,23 +106,6 @@ errorCodec =
|
||||
|> Codec.buildObject
|
||||
|
||||
|
||||
stubManifest : Manifest.Config
|
||||
stubManifest =
|
||||
{ backgroundColor = Nothing
|
||||
, categories = []
|
||||
, displayMode = Manifest.Standalone
|
||||
, orientation = Manifest.Portrait
|
||||
, description = "elm-pages - A statically typed site generator."
|
||||
, iarcRatingId = Nothing
|
||||
, name = "elm-pages docs"
|
||||
, themeColor = Nothing
|
||||
, startUrl = PagePath.external ""
|
||||
, shortName = Just "elm-pages"
|
||||
, sourceIcon = ImagePath.external ""
|
||||
, icons = []
|
||||
}
|
||||
|
||||
|
||||
successCodec : Codec ToJsSuccessPayload
|
||||
successCodec =
|
||||
Codec.object ToJsSuccessPayload
|
||||
|
@ -61,10 +61,10 @@ all =
|
||||
--, StaticHttp.succeed 86
|
||||
)
|
||||
]
|
||||
|> ProgramTest.simulateHttpOk
|
||||
"GET"
|
||||
"https://my-cms.com/posts"
|
||||
"""{ "posts": ["post-1"] }"""
|
||||
--|> ProgramTest.simulateHttpOk
|
||||
-- "GET"
|
||||
-- "https://my-cms.com/posts"
|
||||
-- """{ "posts": ["post-1"] }"""
|
||||
|> ProgramTest.simulateHttpOk
|
||||
"GET"
|
||||
"https://api.github.com/repos/dillonkearns/elm-pages"
|
||||
@ -1008,7 +1008,8 @@ expectErrorsPort expectedPlainString actualPorts =
|
||||
case actualPorts of
|
||||
[ ToJsPayload.Errors actualRichTerminalString ] ->
|
||||
actualRichTerminalString
|
||||
|> BuildError.errorsToString
|
||||
|> List.map .title
|
||||
|> String.join "\n"
|
||||
|> normalizeErrorExpectEqual expectedPlainString
|
||||
|
||||
[] ->
|
||||
@ -1026,7 +1027,17 @@ normalizeErrorExpectEqual expectedPlainString actualRichTerminalString =
|
||||
|> Maybe.withDefault Regex.never
|
||||
)
|
||||
(\_ -> "")
|
||||
|> Expect.equal expectedPlainString
|
||||
|> normalizeNewlines
|
||||
|> Expect.equal
|
||||
(expectedPlainString |> normalizeNewlines)
|
||||
|
||||
|
||||
normalizeNewlines : String -> String
|
||||
normalizeNewlines string =
|
||||
string
|
||||
|> Regex.replace
|
||||
(Regex.fromString "(\n)+" |> Maybe.withDefault Regex.never)
|
||||
(\_ -> "\n")
|
||||
|
||||
|
||||
normalizeErrorsExpectEqual : List String -> List String -> Expect.Expectation
|
||||
|
Loading…
Reference in New Issue
Block a user