diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index 94495a4..3a16443 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -117,7 +117,7 @@ editGoalieLtMins -- ^ The number of minutes -> ProgState -> ProgState -editGoalieLtMins = undefined +editGoalieLtMins mins = editGoalie (gLifetime.gsMinsPlayed .~ mins) 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 e3eabfe..bee64b3 100644 --- a/test/Actions/EditGoalieSpec.hs +++ b/test/Actions/EditGoalieSpec.hs @@ -40,6 +40,7 @@ spec = describe "EditGoalie" $ do editGoalieYtdLossesSpec editGoalieYtdTiesSpec editGoalieLtGamesSpec + editGoalieLtMinsSpec editGoalieNumberSpec :: Spec editGoalieNumberSpec = describe "editGoalieNumber" $ editTest @@ -320,6 +321,37 @@ editGoalieLtGamesSpec = describe "editGoalieLtGames" $ editTest ) ] +editGoalieLtMinsSpec :: Spec +editGoalieLtMinsSpec = describe "editGoalieLtMins" $ editTest + (editGoalieLtMins 1) + EGLtMins + (\(num, name, mins) -> newGoalie num name & gLifetime.gsMinsPlayed .~ mins) + [ ( "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 ) + , EGLtMins + ) + , ( "no goalie selected" + , Nothing + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGLtMins + ) + ] + editTest :: (ProgState -> ProgState) -> EditGoalieMode