diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index 99598fc..18b0597 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -126,7 +126,7 @@ editGoalieLtGoals -- ^ The number of goals -> ProgState -> ProgState -editGoalieLtGoals = undefined +editGoalieLtGoals goals = editGoalie (gLifetime.gsGoalsAllowed .~ goals) 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 bee64b3..dc63adf 100644 --- a/test/Actions/EditGoalieSpec.hs +++ b/test/Actions/EditGoalieSpec.hs @@ -41,6 +41,7 @@ spec = describe "EditGoalie" $ do editGoalieYtdTiesSpec editGoalieLtGamesSpec editGoalieLtMinsSpec + editGoalieLtGoalsSpec editGoalieNumberSpec :: Spec editGoalieNumberSpec = describe "editGoalieNumber" $ editTest @@ -352,6 +353,37 @@ editGoalieLtMinsSpec = describe "editGoalieLtMins" $ editTest ) ] +editGoalieLtGoalsSpec :: Spec +editGoalieLtGoalsSpec = describe "editGoalieLtGoals" $ editTest + (editGoalieLtGoals 1) + EGLtGoals + (\(num, name, goals) -> newGoalie num name & gLifetime.gsGoalsAllowed .~ goals) + [ ( "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 ) + , EGLtGoals + ) + , ( "no goalie selected" + , Nothing + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGLtGoals + ) + ] + editTest :: (ProgState -> ProgState) -> EditGoalieMode