ktonon / elm-test-extra / Expect.Extra

Extends Expect with more Expectations.

Strings

match : MatchPattern -> String -> Expectation

Passes if the given pattern matches the actual string.

-- Match with regular expressions
match (regexPattern "^[0-9a-f]+$") "deadbeef"

-- Or just plain strings
match (stringPattern "foo") "foo bar"


type MatchPattern

An expectation represented as a pattern to match a string.

stringPattern : String -> MatchPattern

Matches if the pattern is contained within the actual string value.

regexPattern : String -> MatchPattern

Matches if the regular expression matches the actual string value.

Lists

contain : a -> (a -> String) -> List a -> Expectation

Alias of member.

Reads better with bdd style tests.

expect [0, 1, 2] to contain 1

-- Passes because [0, 1, 2] contains 1

member : (a -> String) -> a -> List a -> Expectation

Passes if value is a member of list.

member 1 [0, 1, 2]

-- Passes because 1 is a member of [0, 1, 2]