implemented homeScoreL
This commit is contained in:
parent
7b7529339a
commit
2c2f9f5fc7
|
@ -42,6 +42,7 @@ module Mtlstats.Types (
|
||||||
awayScore,
|
awayScore,
|
||||||
-- ** ProgMode Lenses
|
-- ** ProgMode Lenses
|
||||||
gameTypeL,
|
gameTypeL,
|
||||||
|
homeScoreL,
|
||||||
-- ** Database Lenses
|
-- ** Database Lenses
|
||||||
dbPlayers,
|
dbPlayers,
|
||||||
dbGoalies,
|
dbGoalies,
|
||||||
|
@ -312,6 +313,15 @@ gameTypeL = lens
|
||||||
NewGame gs -> NewGame $ gs & gameType .~ gt
|
NewGame gs -> NewGame $ gs & gameType .~ gt
|
||||||
_ -> NewGame $ newGameState & gameType .~ gt)
|
_ -> NewGame $ newGameState & gameType .~ gt)
|
||||||
|
|
||||||
|
homeScoreL :: Lens' ProgMode (Maybe Int)
|
||||||
|
homeScoreL = lens
|
||||||
|
(\case
|
||||||
|
NewGame gs -> gs ^. homeScore
|
||||||
|
_ -> Nothing)
|
||||||
|
(\m hs -> case m of
|
||||||
|
NewGame gs -> NewGame $ gs & homeScore .~ hs
|
||||||
|
_ -> NewGame $ newGameState & homeScore .~ hs)
|
||||||
|
|
||||||
-- | Constructor for a 'ProgState'
|
-- | Constructor for a 'ProgState'
|
||||||
newProgState :: ProgState
|
newProgState :: ProgState
|
||||||
newProgState = ProgState
|
newProgState = ProgState
|
||||||
|
|
|
@ -40,6 +40,7 @@ spec = describe "Mtlstats.Types" $ do
|
||||||
goalieSpec
|
goalieSpec
|
||||||
databaseSpec
|
databaseSpec
|
||||||
gameTypeLSpec
|
gameTypeLSpec
|
||||||
|
homeScoreLSpec
|
||||||
Menu.spec
|
Menu.spec
|
||||||
|
|
||||||
pPointsSpec :: Spec
|
pPointsSpec :: Spec
|
||||||
|
@ -150,6 +151,32 @@ gameTypeLSpec = describe "gameTypeL" $ do
|
||||||
in m ^. gameTypeL `shouldBe` Just t)
|
in m ^. gameTypeL `shouldBe` Just t)
|
||||||
[HomeGame, AwayGame]
|
[HomeGame, AwayGame]
|
||||||
|
|
||||||
|
homeScoreLSpec = describe "homeScoreL" $ do
|
||||||
|
|
||||||
|
context "getter" $ do
|
||||||
|
|
||||||
|
context "unexpected mode" $
|
||||||
|
it "should return Nothing" $
|
||||||
|
MainMenu ^. homeScoreL `shouldBe` Nothing
|
||||||
|
|
||||||
|
context "expected mode" $
|
||||||
|
it "should return 0" $ let
|
||||||
|
gs = newGameState & homeScore ?~ 0
|
||||||
|
m = NewGame gs
|
||||||
|
in m ^. homeScoreL `shouldBe` Just 0
|
||||||
|
|
||||||
|
context "setter" $ do
|
||||||
|
|
||||||
|
context "unexpected mode" $
|
||||||
|
it "should set the points" $ let
|
||||||
|
m = MainMenu & homeScoreL ?~ 0
|
||||||
|
in m ^. homeScoreL `shouldBe` Just 0
|
||||||
|
|
||||||
|
context "expected mode" $
|
||||||
|
it "should set the points" $ let
|
||||||
|
m = NewGame newGameState & homeScoreL ?~ 0
|
||||||
|
in m ^. homeScoreL `shouldBe` Just 0
|
||||||
|
|
||||||
player :: Player
|
player :: Player
|
||||||
player = newPlayer 1 "Joe" "centre"
|
player = newPlayer 1 "Joe" "centre"
|
||||||
& pYtd . psGoals .~ 2
|
& pYtd . psGoals .~ 2
|
||||||
|
|
Loading…
Reference in New Issue
Block a user