implemented awayScoreL
This commit is contained in:
parent
2c2f9f5fc7
commit
ef7d34110a
|
@ -43,6 +43,7 @@ module Mtlstats.Types (
|
|||
-- ** ProgMode Lenses
|
||||
gameTypeL,
|
||||
homeScoreL,
|
||||
awayScoreL,
|
||||
-- ** Database Lenses
|
||||
dbPlayers,
|
||||
dbGoalies,
|
||||
|
@ -322,6 +323,15 @@ homeScoreL = lens
|
|||
NewGame gs -> NewGame $ gs & homeScore .~ hs
|
||||
_ -> NewGame $ newGameState & homeScore .~ hs)
|
||||
|
||||
awayScoreL :: Lens' ProgMode (Maybe Int)
|
||||
awayScoreL = lens
|
||||
(\case
|
||||
NewGame gs -> gs ^. awayScore
|
||||
_ -> Nothing)
|
||||
(\m as -> case m of
|
||||
NewGame gs -> NewGame $ gs & awayScore .~ as
|
||||
_ -> NewGame $ newGameState & awayScore .~ as)
|
||||
|
||||
-- | Constructor for a 'ProgState'
|
||||
newProgState :: ProgState
|
||||
newProgState = ProgState
|
||||
|
|
|
@ -41,6 +41,7 @@ spec = describe "Mtlstats.Types" $ do
|
|||
databaseSpec
|
||||
gameTypeLSpec
|
||||
homeScoreLSpec
|
||||
awayScoreLSpec
|
||||
Menu.spec
|
||||
|
||||
pPointsSpec :: Spec
|
||||
|
@ -168,15 +169,42 @@ homeScoreLSpec = describe "homeScoreL" $ do
|
|||
context "setter" $ do
|
||||
|
||||
context "unexpected mode" $
|
||||
it "should set the points" $ let
|
||||
it "should set home score" $ let
|
||||
m = MainMenu & homeScoreL ?~ 0
|
||||
in m ^. homeScoreL `shouldBe` Just 0
|
||||
|
||||
context "expected mode" $
|
||||
it "should set the points" $ let
|
||||
it "should set home score" $ let
|
||||
m = NewGame newGameState & homeScoreL ?~ 0
|
||||
in m ^. homeScoreL `shouldBe` Just 0
|
||||
|
||||
awayScoreLSpec :: Spec
|
||||
awayScoreLSpec = describe "awayScoreL" $ do
|
||||
|
||||
context "getter" $ do
|
||||
|
||||
context "unexpected mode" $
|
||||
it "should return Nothing" $
|
||||
MainMenu ^. awayScoreL `shouldBe` Nothing
|
||||
|
||||
context "expected mode" $
|
||||
it "should return 0" $ let
|
||||
gs = newGameState & awayScore ?~ 0
|
||||
m = NewGame gs
|
||||
in m ^. awayScoreL `shouldBe` Just 0
|
||||
|
||||
context "setter" $ do
|
||||
|
||||
context "unexpected mode" $
|
||||
it "should set the away score" $ let
|
||||
m = MainMenu & awayScoreL ?~ 0
|
||||
in m ^. awayScoreL `shouldBe` Just 0
|
||||
|
||||
context "expected mode" $
|
||||
it "should set the away score" $ let
|
||||
m = NewGame newGameState & awayScoreL ?~ 0
|
||||
in m ^. awayScoreL `shouldBe` Just 0
|
||||
|
||||
player :: Player
|
||||
player = newPlayer 1 "Joe" "centre"
|
||||
& pYtd . psGoals .~ 2
|
||||
|
|
Loading…
Reference in New Issue
Block a user