elm-review/tests/TestUtil.elm
2017-06-13 01:31:10 +02:00

27 lines
593 B
Elm

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