diff --git a/src/Mtlstats/Types.hs b/src/Mtlstats/Types.hs index 6e1c3a9..c150902 100644 --- a/src/Mtlstats/Types.hs +++ b/src/Mtlstats/Types.hs @@ -653,7 +653,11 @@ editPlayerStateL = lens (\_ eps -> EditPlayer eps) editGoalieStateL :: Lens' ProgMode EditGoalieState -editGoalieStateL = undefined +editGoalieStateL = lens + (\case + EditGoalie egs -> egs + _ -> newEditGoalieState) + (\_ egs -> EditGoalie egs) -- | Constructor for a 'ProgState' newProgState :: ProgState diff --git a/test/TypesSpec.hs b/test/TypesSpec.hs index e3527f9..06b8e2d 100644 --- a/test/TypesSpec.hs +++ b/test/TypesSpec.hs @@ -56,6 +56,7 @@ spec = describe "Mtlstats.Types" $ do createPlayerStateLSpec createGoalieStateLSpec editPlayerStateLSpec + editGoalieStateLSpec teamScoreSpec otherScoreSpec homeTeamSpec @@ -169,6 +170,24 @@ editPlayerStateLSpec = describe "editPlayerStateL" $ eps2 = newEditPlayerState & epsSelectedPlayer ?~ 2 +editGoalieStateLSpec :: Spec +editGoalieStateLSpec = describe "editGoalieStateL" $ + lensSpec editGoalieStateL + -- getters + [ ( "missing state", MainMenu, newEditGoalieState ) + , ( "with state", EditGoalie egs1, egs1 ) + ] + -- setters + [ ( "set state", MainMenu, egs1 ) + , ( "change state", EditGoalie egs1, egs2 ) + , ( "clear state", EditGoalie egs1, newEditGoalieState ) + ] + where + egs1 = newEditGoalieState + & egsSelectedGoalie ?~ 1 + egs2 = newEditGoalieState + & egsSelectedGoalie ?~ 2 + teamScoreSpec :: Spec teamScoreSpec = describe "teamScore" $ do let @@ -858,6 +877,17 @@ instance Comparable EditPlayerState where it ("should be " ++ show (expected^.epsMode)) $ actual^.epsMode `shouldBe` expected^.epsMode +instance Comparable EditGoalieState where + compareTest actual expected = do + + describe "egsSelectedGoalie" $ + it ("should be " ++ show (expected^.egsSelectedGoalie)) $ + actual^.egsSelectedGoalie `shouldBe` expected^.egsSelectedGoalie + + describe "egsMode" $ + it ("should be " ++ show (expected^.egsMode)) $ + actual^.egsMode `shouldBe` expected^.egsMode + instance Comparable CreateGoalieState where compareTest actual expected = do