elm-review/tests/TestUtil.elm
2018-11-05 15:40:41 +01:00

30 lines
693 B
Elm

module TestUtil exposing (expectErrors, ruleTester)
import Expect
import Lint exposing (parseSource)
import Lint.Types exposing (LintError, LintResult, LintRule)
import Regex
spacesRegex : Regex.Regex
spacesRegex =
Regex.regex "\n "
ruleTester : LintRule -> String -> LintResult
ruleTester rule str =
str
|> Regex.replace Regex.All spacesRegex (\_ -> "\n")
|> parseSource
|> Result.map rule
expectErrors : List LintError -> LintResult -> Expect.Expectation
expectErrors expectedErrors result =
case result of
Err _ ->
Expect.fail "Parsing failure"
Ok errors ->
Expect.equal expectedErrors errors