implemented editPlayerStateL

This commit is contained in:
Jonathan Lamothe 2019-11-01 03:42:51 -04:00
parent e754d887c5
commit 8b1e93386a
2 changed files with 33 additions and 0 deletions

View File

@ -50,6 +50,7 @@ module Mtlstats.Types (
gameStateL, gameStateL,
createPlayerStateL, createPlayerStateL,
createGoalieStateL, createGoalieStateL,
editPlayerStateL,
-- ** GameState Lenses -- ** GameState Lenses
gameYear, gameYear,
gameMonth, gameMonth,
@ -584,6 +585,13 @@ createGoalieStateL = lens
_ -> newCreateGoalieState) _ -> newCreateGoalieState)
(\_ cgs -> CreateGoalie cgs) (\_ cgs -> CreateGoalie cgs)
editPlayerStateL :: Lens' ProgMode EditPlayerState
editPlayerStateL = lens
(\case
EditPlayer eps -> eps
_ -> newEditPlayerState)
(\_ eps -> EditPlayer eps)
-- | Constructor for a 'ProgState' -- | Constructor for a 'ProgState'
newProgState :: ProgState newProgState :: ProgState
newProgState = ProgState newProgState = ProgState

View File

@ -47,6 +47,7 @@ spec = describe "Mtlstats.Types" $ do
gameStateLSpec gameStateLSpec
createPlayerStateLSpec createPlayerStateLSpec
createGoalieStateLSpec createGoalieStateLSpec
editPlayerStateLSpec
teamScoreSpec teamScoreSpec
otherScoreSpec otherScoreSpec
homeTeamSpec homeTeamSpec
@ -141,6 +142,24 @@ createGoalieStateLSpec = describe "createGoalieStateL" $
& cgsNumber ?~ 2 & cgsNumber ?~ 2
& cgsName .~ "Bob" & cgsName .~ "Bob"
editPlayerStateLSpec :: Spec
editPlayerStateLSpec = describe "editPlayerStateL" $
lensSpec editPlayerStateL
-- getters
[ ( "missing state", MainMenu, newEditPlayerState )
, ( "withState", EditPlayer eps1, eps1 )
]
-- setters
[ ( "set state", MainMenu, eps1 )
, ( "change state", EditPlayer eps1, eps2 )
, ( "clear state", EditPlayer eps1, newEditPlayerState )
]
where
eps1 = newEditPlayerState
& epsSelectedPlayer ?~ 1
eps2 = newEditPlayerState
& epsSelectedPlayer ?~ 2
teamScoreSpec :: Spec teamScoreSpec :: Spec
teamScoreSpec = describe "teamScore" $ do teamScoreSpec = describe "teamScore" $ do
let let
@ -734,6 +753,12 @@ instance Comparable CreatePlayerState where
it ("should be " ++ expected^.cpsPosition) $ it ("should be " ++ expected^.cpsPosition) $
actual^.cpsPosition `shouldBe` expected^.cpsPosition actual^.cpsPosition `shouldBe` expected^.cpsPosition
instance Comparable EditPlayerState where
compareTest actual expected =
describe "epsSelectedPlayer" $
it ("should be " ++ show (expected^.epsSelectedPlayer)) $
actual^.epsSelectedPlayer `shouldBe` expected^.epsSelectedPlayer
instance Comparable CreateGoalieState where instance Comparable CreateGoalieState where
compareTest actual expected = do compareTest actual expected = do