implemented startNewSeason

This commit is contained in:
Jonathan Lamothe 2019-08-20 12:26:24 -04:00
parent 25034f0c48
commit 76b4b85a0f
2 changed files with 24 additions and 8 deletions

View File

@ -21,11 +21,13 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
module Mtlstats.Actions (startNewSeason, startNewGame) where module Mtlstats.Actions (startNewSeason, startNewGame) where
import Lens.Micro ((.~))
import Mtlstats.Types import Mtlstats.Types
-- | Starts a new season -- | Starts a new season
startNewSeason :: ProgState -> ProgState startNewSeason :: ProgState -> ProgState
startNewSeason = undefined startNewSeason = (progMode .~ NewSeason) . (database . dbGames .~ 0)
-- | Starts a new game -- | Starts a new game
startNewGame :: ProgState -> ProgState startNewGame :: ProgState -> ProgState

View File

@ -21,15 +21,29 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
module ActionsSpec (spec) where module ActionsSpec (spec) where
import Test.Hspec (Spec, describe) import Lens.Micro ((&), (.~), (^.))
import Test.Hspec (Spec, describe, it, shouldBe)
import Mtlstats.Actions
import Mtlstats.Types
spec :: Spec spec :: Spec
spec = describe "Mtlstats.Actions" $ do spec = describe "Mtlstats.Actions" $ do
startSeasonSpec startNewSeasonSpec
startGameSpec startNewGameSpec
startSeasonSpec :: Spec startNewSeasonSpec :: Spec
startSeasonSpec = describe "startSeason" $ return () startNewSeasonSpec = describe "startNewSeason" $ do
let
s = newProgState
& database . dbGames .~ 1
& startNewSeason
startGameSpec :: Spec it "should set the progState to NewSeason" $
startGameSpec = describe "startGame" $ return () s ^. progMode `shouldBe` NewSeason
it "should set the number of games to 0" $
s ^. database . dbGames `shouldBe` 0
startNewGameSpec :: Spec
startNewGameSpec = describe "startGame" $ return ()