Sha256: 54d197e019d6a338ed3689da6fbf891b9a506433337a58fe39674914d53a57a4

Contents?: true

Size: 1.99 KB

Versions: 29

Compression:

Stored size: 1.99 KB

Contents

module Tests exposing (..)

import Test exposing (..)
import Expect
import Allergies exposing (isAllergicTo, toList)
import List


tests : Test
tests =
    describe "Allergies"
        [ describe "isAllergicTo"
            [ describe "no allergies means not allergic"
                [ test "peanuts" <|
                    \() -> Expect.equal False (isAllergicTo "peanuts" 0)
                , test "cats" <|
                    \() -> Expect.equal False (isAllergicTo "cats" 0)
                , test "strawberries" <|
                    \() -> Expect.equal False (isAllergicTo "strawberries" 0)
                ]
            , test "is allergic to eggs" <|
                \() -> Expect.equal True (isAllergicTo "eggs" 1)
            , describe "has the right allergies"
                [ test "eggs" <|
                    \() -> Expect.equal True (isAllergicTo "eggs" 5)
                , test "shellfish" <|
                    \() -> Expect.equal True (isAllergicTo "shellfish" 5)
                , test "strawberries" <|
                    \() -> Expect.equal False (isAllergicTo "strawberries" 5)
                ]
            ]
        , describe "toList"
            [ test "no allergies at all" <|
                \() -> Expect.equal [] (toList (0))
            , test "allergic to just peanuts" <|
                \() -> Expect.equal [ "peanuts" ] (toList (2))
            , test "allergic to everything" <|
                \() ->
                    Expect.equal (List.sort [ "eggs", "peanuts", "shellfish", "strawberries", "tomatoes", "chocolate", "pollen", "cats" ])
                        (255 |> toList |> List.sort)
            , test "ignore non allergen score parts" <|
                \() -> Expect.equal [ "eggs" ] (toList 257)
            , test "ignore all non allergen score parts" <|
                \() ->
                    Expect.equal (List.sort [ "eggs", "shellfish", "strawberries", "tomatoes", "chocolate", "pollen", "cats" ])
                        (509 |> toList |> List.sort)
            ]
        ]

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
trackler-2.1.0.53 tracks/elm/exercises/allergies/tests/Tests.elm
trackler-2.1.0.52 tracks/elm/exercises/allergies/tests/Tests.elm
trackler-2.1.0.51 tracks/elm/exercises/allergies/tests/Tests.elm
trackler-2.1.0.50 tracks/elm/exercises/allergies/tests/Tests.elm
trackler-2.1.0.49 tracks/elm/exercises/allergies/tests/Tests.elm
trackler-2.1.0.48 tracks/elm/exercises/allergies/tests/Tests.elm
trackler-2.1.0.47 tracks/elm/exercises/allergies/tests/Tests.elm
trackler-2.1.0.46 tracks/elm/exercises/allergies/tests/Tests.elm
trackler-2.1.0.45 tracks/elm/exercises/allergies/tests/Tests.elm
trackler-2.1.0.44 tracks/elm/exercises/allergies/tests/Tests.elm
trackler-2.1.0.43 tracks/elm/exercises/allergies/tests/Tests.elm
trackler-2.1.0.42 tracks/elm/exercises/allergies/tests/Tests.elm
trackler-2.1.0.41 tracks/elm/exercises/allergies/tests/Tests.elm
trackler-2.1.0.40 tracks/elm/exercises/allergies/tests/Tests.elm
trackler-2.1.0.39 tracks/elm/exercises/allergies/tests/Tests.elm
trackler-2.1.0.38 tracks/elm/exercises/allergies/tests/Tests.elm
trackler-2.1.0.37 tracks/elm/exercises/allergies/tests/Tests.elm
trackler-2.1.0.36 tracks/elm/exercises/allergies/tests/Tests.elm
trackler-2.1.0.34 tracks/elm/exercises/allergies/tests/Tests.elm
trackler-2.1.0.33 tracks/elm/exercises/allergies/tests/Tests.elm