added EditPlayerMode

This commit is contained in:
Jonathan Lamothe 2019-11-01 04:25:25 -04:00
parent 5fd67f3802
commit c26c0f54d1
2 changed files with 26 additions and 2 deletions

View File

@ -32,6 +32,7 @@ module Mtlstats.Types (
CreatePlayerState (..),
CreateGoalieState (..),
EditPlayerState (..),
EditPlayerMode (..),
Database (..),
Player (..),
PlayerStats (..),
@ -86,6 +87,7 @@ module Mtlstats.Types (
cgsFailureCallback,
-- ** EditPlayerState Lenses
epsSelectedPlayer,
epsMode,
-- ** Database Lenses
dbPlayers,
dbGoalies,
@ -306,11 +308,27 @@ data CreateGoalieState = CreateGoalieState
}
-- | Player edit status
newtype EditPlayerState = EditPlayerState
data EditPlayerState = EditPlayerState
{ _epsSelectedPlayer :: Maybe Int
-- ^ The index number of the player being edited
, _epsMode :: EditPlayerMode
-- ^ The editing mode
}
-- | Player editing mode
data EditPlayerMode
= EPMenu
| EPNumber
| EPName
| EPPosition
| EPYtdGoals
| EPYtdAssists
| EPYtdPMin
| EPLtGoals
| EPLtAssists
| EPLtPMin
deriving (Eq, Show)
-- | Represents the database
data Database = Database
{ _dbPlayers :: [Player]
@ -651,6 +669,7 @@ newCreateGoalieState = CreateGoalieState
newEditPlayerState :: EditPlayerState
newEditPlayerState = EditPlayerState
{ _epsSelectedPlayer = Nothing
, _epsMode = EPMenu
}
-- | Constructor for a 'Database'

View File

@ -754,11 +754,16 @@ instance Comparable CreatePlayerState where
actual^.cpsPosition `shouldBe` expected^.cpsPosition
instance Comparable EditPlayerState where
compareTest actual expected =
compareTest actual expected = do
describe "epsSelectedPlayer" $
it ("should be " ++ show (expected^.epsSelectedPlayer)) $
actual^.epsSelectedPlayer `shouldBe` expected^.epsSelectedPlayer
describe "epsMode" $
it ("should be " ++ show (expected^.epsMode)) $
actual^.epsMode `shouldBe` expected^.epsMode
instance Comparable CreateGoalieState where
compareTest actual expected = do