From 3a1480115d0caf07ea16a9f6b8b69d51f4aebb49 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 02:26:55 -0500 Subject: [PATCH] implemented editGoalieLtMins --- src/Mtlstats/Actions/EditGoalie.hs | 2 +- test/Actions/EditGoalieSpec.hs | 32 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) 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