diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index 1cd8364..c1599b2 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -153,7 +153,7 @@ editGoalieLtTies -- ^ The number of ties -> ProgState -> ProgState -editGoalieLtTies = undefined +editGoalieLtTies ties = editGoalie (gLifetime.gsTies .~ ties) EGLifetime editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do diff --git a/test/Actions/EditGoalieSpec.hs b/test/Actions/EditGoalieSpec.hs index 97e710d..af8c4bb 100644 --- a/test/Actions/EditGoalieSpec.hs +++ b/test/Actions/EditGoalieSpec.hs @@ -44,6 +44,7 @@ spec = describe "EditGoalie" $ do editGoalieLtGoalsSpec editGoalieLtWinsSpec editGoalieLtLossesSpec + editGoalieLtTiesSpec editGoalieNumberSpec :: Spec editGoalieNumberSpec = describe "editGoalieNumber" $ editTest @@ -448,6 +449,37 @@ editGoalieLtLossesSpec = describe "editGoalieLtLosses" $ editTest ) ] +editGoalieLtTiesSpec :: Spec +editGoalieLtTiesSpec = describe "editGoalieLtTies" $ editTest + (editGoalieLtTies 1) + EGLtTies + (\(num, name, ties) -> newGoalie num name & gLifetime.gsTies .~ ties) + [ ( "set Joe" + , Just 0 + , ( 2, "Joe", 1 ) + , ( 3, "Bob", 0 ) + , EGLifetime + ) + , ( "set Bob" + , Just 1 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 1 ) + , EGLifetime + ) + , ( "out of bounds" + , Just 2 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGLtTies + ) + , ( "no goalie selected" + , Nothing + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGLtTies + ) + ] + editTest :: (ProgState -> ProgState) -> EditGoalieMode