From afdb7653cda877595e8df6ce56b426e60dadb146 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 02:17:13 -0500 Subject: [PATCH] implemented editGoalieLtGames --- 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 b22002a..63fd6ed 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -108,7 +108,7 @@ editGoalieLtGames -- ^ The number of games -> ProgState -> ProgState -editGoalieLtGames = undefined +editGoalieLtGames games = editGoalie (gLifetime.gsGames .~ games) 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 ac92d2e..e3eabfe 100644 --- a/test/Actions/EditGoalieSpec.hs +++ b/test/Actions/EditGoalieSpec.hs @@ -39,6 +39,7 @@ spec = describe "EditGoalie" $ do editGoalieYtdWinsSpec editGoalieYtdLossesSpec editGoalieYtdTiesSpec + editGoalieLtGamesSpec editGoalieNumberSpec :: Spec editGoalieNumberSpec = describe "editGoalieNumber" $ editTest @@ -288,6 +289,37 @@ editGoalieYtdTiesSpec = describe "editGoalieYtdTies" $ editTest ) ] +editGoalieLtGamesSpec :: Spec +editGoalieLtGamesSpec = describe "editGoalieLtGames" $ editTest + (editGoalieLtGames 1) + EGLtGames + (\(num, name, games) -> newGoalie num name & gLifetime.gsGames .~ games) + [ ( "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 ) + , EGLtGames + ) + , ( "no goalie selected" + , Nothing + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGLtGames + ) + ] + editTest :: (ProgState -> ProgState) -> EditGoalieMode