2017-05-27 17:56:31 +00:00
|
|
|
module Tests exposing (..)
|
2016-03-27 01:08:15 +00:00
|
|
|
|
2016-08-17 11:14:17 +00:00
|
|
|
import Test exposing (..)
|
|
|
|
import Expect
|
2016-03-27 01:08:15 +00:00
|
|
|
import Allergies exposing (isAllergicTo, toList)
|
|
|
|
import List
|
|
|
|
|
|
|
|
|
|
|
|
tests : Test
|
|
|
|
tests =
|
2016-08-17 11:14:17 +00:00
|
|
|
describe "Allergies"
|
|
|
|
[ describe "isAllergicTo"
|
|
|
|
[ describe "no allergies means not allergic"
|
|
|
|
[ test "peanuts" <|
|
|
|
|
\() -> Expect.equal False (isAllergicTo "peanuts" 0)
|
2017-07-05 20:35:15 +00:00
|
|
|
, skip <|
|
|
|
|
test "cats" <|
|
|
|
|
\() -> Expect.equal False (isAllergicTo "cats" 0)
|
|
|
|
, skip <|
|
|
|
|
test "strawberries" <|
|
|
|
|
\() -> Expect.equal False (isAllergicTo "strawberries" 0)
|
2016-06-19 21:46:13 +00:00
|
|
|
]
|
2017-07-05 20:35:15 +00:00
|
|
|
, skip <|
|
|
|
|
test "is allergic to eggs" <|
|
|
|
|
\() -> Expect.equal True (isAllergicTo "eggs" 1)
|
2016-08-17 11:14:17 +00:00
|
|
|
, describe "has the right allergies"
|
2017-07-05 20:35:15 +00:00
|
|
|
[ skip <|
|
|
|
|
test "eggs" <|
|
|
|
|
\() -> Expect.equal True (isAllergicTo "eggs" 5)
|
|
|
|
, skip <|
|
|
|
|
test "shellfish" <|
|
|
|
|
\() -> Expect.equal True (isAllergicTo "shellfish" 5)
|
|
|
|
, skip <|
|
|
|
|
test "strawberries" <|
|
|
|
|
\() -> Expect.equal False (isAllergicTo "strawberries" 5)
|
2016-06-19 21:46:13 +00:00
|
|
|
]
|
2016-03-27 01:08:15 +00:00
|
|
|
]
|
2016-08-17 11:14:17 +00:00
|
|
|
, describe "toList"
|
2017-07-05 20:35:15 +00:00
|
|
|
[ skip <|
|
|
|
|
test "no allergies at all" <|
|
|
|
|
\() -> Expect.equal [] (toList (0))
|
|
|
|
, skip <|
|
|
|
|
test "allergic to just peanuts" <|
|
|
|
|
\() -> Expect.equal [ "peanuts" ] (toList (2))
|
|
|
|
, skip <|
|
|
|
|
test "allergic to everything" <|
|
|
|
|
\() ->
|
|
|
|
Expect.equal (List.sort [ "eggs", "peanuts", "shellfish", "strawberries", "tomatoes", "chocolate", "pollen", "cats" ])
|
|
|
|
(255 |> toList |> List.sort)
|
|
|
|
, skip <|
|
|
|
|
test "ignore non allergen score parts" <|
|
|
|
|
\() -> Expect.equal [ "eggs" ] (toList 257)
|
|
|
|
, skip <|
|
|
|
|
test "ignore all non allergen score parts" <|
|
|
|
|
\() ->
|
|
|
|
Expect.equal (List.sort [ "eggs", "shellfish", "strawberries", "tomatoes", "chocolate", "pollen", "cats" ])
|
|
|
|
(509 |> toList |> List.sort)
|
2016-03-27 01:08:15 +00:00
|
|
|
]
|
|
|
|
]
|