implemented addGoalie
This commit is contained in:
parent
667cf34475
commit
66a2a70bbe
|
@ -172,7 +172,14 @@ addPlayer s = fromMaybe s $ do
|
||||||
|
|
||||||
-- | Adds the entered goalie to the roster
|
-- | Adds the entered goalie to the roster
|
||||||
addGoalie :: ProgState -> ProgState
|
addGoalie :: ProgState -> ProgState
|
||||||
addGoalie = undefined
|
addGoalie s = fromMaybe s $ do
|
||||||
|
let cgs = s^.progMode.createGoalieStateL
|
||||||
|
num <- cgs^.cgsNumber
|
||||||
|
let
|
||||||
|
name = cgs^.cgsName
|
||||||
|
goalie = newGoalie num name
|
||||||
|
Just $ s & database.dbGoalies
|
||||||
|
%~ (++[goalie])
|
||||||
|
|
||||||
-- | Resets the 'CreatePlayerState' value
|
-- | Resets the 'CreatePlayerState' value
|
||||||
resetCreatePlayerState :: ProgState -> ProgState
|
resetCreatePlayerState :: ProgState -> ProgState
|
||||||
|
|
|
@ -58,6 +58,7 @@ spec = describe "Mtlstats.Actions" $ do
|
||||||
createPlayerSpec
|
createPlayerSpec
|
||||||
createGoalieSpec
|
createGoalieSpec
|
||||||
addPlayerSpec
|
addPlayerSpec
|
||||||
|
addGoalieSpec
|
||||||
resetCreatePlayerStateSpec
|
resetCreatePlayerStateSpec
|
||||||
resetCreateGoalieStateSpec
|
resetCreateGoalieStateSpec
|
||||||
recordGoalAssistsSpec
|
recordGoalAssistsSpec
|
||||||
|
@ -388,6 +389,29 @@ addPlayerSpec = describe "addPlayer" $ do
|
||||||
s' = addPlayer $ s MainMenu
|
s' = addPlayer $ s MainMenu
|
||||||
in s'^.database.dbPlayers `shouldBe` [p1]
|
in s'^.database.dbPlayers `shouldBe` [p1]
|
||||||
|
|
||||||
|
addGoalieSpec :: Spec
|
||||||
|
addGoalieSpec = describe "addGoalie" $ do
|
||||||
|
let
|
||||||
|
g1 = newGoalie 2 "Joe"
|
||||||
|
g2 = newGoalie 3 "Bob"
|
||||||
|
db = newDatabase
|
||||||
|
& dbGoalies .~ [g1]
|
||||||
|
s pm = newProgState
|
||||||
|
& database .~ db
|
||||||
|
& progMode .~ pm
|
||||||
|
|
||||||
|
context "data available" $
|
||||||
|
it "should create the goalie" $ let
|
||||||
|
s' = addGoalie $ s $ CreateGoalie $ newCreateGoalieState
|
||||||
|
& cgsNumber ?~ 3
|
||||||
|
& cgsName .~ "Bob"
|
||||||
|
in s'^.database.dbGoalies `shouldBe` [g1, g2]
|
||||||
|
|
||||||
|
context "data unavailable" $
|
||||||
|
it "should not create the goalie" $ let
|
||||||
|
s' = addGoalie $ s MainMenu
|
||||||
|
in s'^.database.dbGoalies `shouldBe` [g1]
|
||||||
|
|
||||||
resetCreatePlayerStateSpec :: Spec
|
resetCreatePlayerStateSpec :: Spec
|
||||||
resetCreatePlayerStateSpec = describe "resetCreatePlayerState" $ let
|
resetCreatePlayerStateSpec = describe "resetCreatePlayerState" $ let
|
||||||
cps = newCreatePlayerState
|
cps = newCreatePlayerState
|
||||||
|
|
Loading…
Reference in New Issue
Block a user