mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-12-26 11:13:39 +03:00
27 lines
593 B
Elm
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
|