ktonon/elm-test-extra/2.0.1

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"

An expectation represented as a pattern to match a string.

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

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]