Add expectGlobalAndModuleErrors

This commit is contained in:
Jeroen Engels 2021-03-07 16:24:02 +01:00
parent 686e80735d
commit 21ee813aa7

View File

@ -1,7 +1,7 @@
module Review.Test exposing
( ReviewResult, run, runWithProjectData, runOnModules, runOnModulesWithProjectData
, ExpectedError, expectNoErrors, expectErrors, error, atExactly, whenFixed, expectErrorsForModules, expectErrorsForElmJson, expectErrorsForReadme, expectGlobalErrors, globalError
, expectGlobalAndLocalErrors
, expectGlobalAndLocalErrors, expectGlobalAndModuleErrors
)
{-| Module that helps you test your rules, using [`elm-test`](https://package.elm-lang.org/packages/elm-explorations/test/latest/).
@ -764,6 +764,25 @@ expectGlobalAndLocalErrors { global, local } reviewResult =
()
expectGlobalAndModuleErrors : { global : List { message : String, details : List String }, modules : List ( String, List ExpectedError ) } -> ReviewResult -> Expectation
expectGlobalAndModuleErrors { global, modules } reviewResult =
case reviewResult of
FailedRun errorMessage ->
Expect.fail errorMessage
SuccessfulRun globalErrors runResults ->
Expect.all
[ \() ->
if List.isEmpty global then
expectNoGlobalErrors globalErrors
else
Expect.all (checkAllGlobalErrorsMatch { expected = global, actual = globalErrors }) ()
, \() -> expectErrorsForModulesHelp modules runResults
]
()
expectErrorsForModulesHelp : List ( String, List ExpectedError ) -> List SuccessfulRunResult -> Expectation
expectErrorsForModulesHelp expectedErrorsList runResults =
let