implemented resetGoalData
This commit is contained in:
parent
4f70c84c6b
commit
7da4c54e65
|
@ -199,4 +199,7 @@ awardAssist n ps = ps
|
||||||
|
|
||||||
-- | Resets the entered data for the current goal
|
-- | Resets the entered data for the current goal
|
||||||
resetGoalData :: ProgState -> ProgState
|
resetGoalData :: ProgState -> ProgState
|
||||||
resetGoalData = undefined
|
resetGoalData ps = ps & progMode.gameStateL
|
||||||
|
%~ (goalBy .~ Nothing)
|
||||||
|
. (assistsBy .~ [])
|
||||||
|
. (confirmGoalDataFlag .~ False)
|
||||||
|
|
|
@ -24,7 +24,7 @@ module ActionsSpec (spec) where
|
||||||
import Control.Monad (replicateM)
|
import Control.Monad (replicateM)
|
||||||
import Lens.Micro ((^.), (&), (.~), (?~), (%~))
|
import Lens.Micro ((^.), (&), (.~), (?~), (%~))
|
||||||
import System.Random (randomRIO)
|
import System.Random (randomRIO)
|
||||||
import Test.Hspec (Spec, context, describe, it, shouldBe, shouldNotBe)
|
import Test.Hspec (Spec, context, describe, it, runIO, shouldBe, shouldNotBe)
|
||||||
|
|
||||||
import Mtlstats.Actions
|
import Mtlstats.Actions
|
||||||
import Mtlstats.Types
|
import Mtlstats.Types
|
||||||
|
@ -44,6 +44,7 @@ spec = describe "Mtlstats.Actions" $ do
|
||||||
recordGoalAssistsSpec
|
recordGoalAssistsSpec
|
||||||
awardGoalSpec
|
awardGoalSpec
|
||||||
awardAssistSpec
|
awardAssistSpec
|
||||||
|
resetGoalDataSpec
|
||||||
|
|
||||||
startNewSeasonSpec :: Spec
|
startNewSeasonSpec :: Spec
|
||||||
startNewSeasonSpec = describe "startNewSeason" $ do
|
startNewSeasonSpec = describe "startNewSeason" $ do
|
||||||
|
@ -517,6 +518,30 @@ awardAssistSpec = describe "awardAssist" $ do
|
||||||
in it "should not change anything" $
|
in it "should not change anything" $
|
||||||
ps'^.database.dbPlayers `shouldBe` ps^.database.dbPlayers
|
ps'^.database.dbPlayers `shouldBe` ps^.database.dbPlayers
|
||||||
|
|
||||||
|
resetGoalDataSpec :: Spec
|
||||||
|
resetGoalDataSpec = describe "resetGoalData" $ do
|
||||||
|
players <- runIO $ replicateM 5 makePlayer
|
||||||
|
let
|
||||||
|
gs
|
||||||
|
= newGameState
|
||||||
|
& goalBy ?~ 1
|
||||||
|
& assistsBy .~ [2, 3]
|
||||||
|
& confirmGoalDataFlag .~ True
|
||||||
|
ps
|
||||||
|
= newProgState
|
||||||
|
& database.dbPlayers .~ players
|
||||||
|
& progMode.gameStateL .~ gs
|
||||||
|
& resetGoalData
|
||||||
|
|
||||||
|
it "should clear the goalBy value" $
|
||||||
|
ps^.progMode.gameStateL.goalBy `shouldBe` Nothing
|
||||||
|
|
||||||
|
it "should clear the assists by list" $
|
||||||
|
ps^.progMode.gameStateL.assistsBy `shouldBe` []
|
||||||
|
|
||||||
|
it "should clear confirmGoalDataFlag" $
|
||||||
|
ps^.progMode.gameStateL.confirmGoalDataFlag `shouldBe` False
|
||||||
|
|
||||||
makePlayer :: IO Player
|
makePlayer :: IO Player
|
||||||
makePlayer = Player
|
makePlayer = Player
|
||||||
<$> makeNum
|
<$> makeNum
|
||||||
|
|
Loading…
Reference in New Issue
Block a user