implemented player confirmation/addition

This commit is contained in:
Jonathan Lamothe
2019-09-09 23:35:28 -04:00
parent 0ee0451496
commit 375e87a49e
3 changed files with 58 additions and 0 deletions

View File

@@ -40,6 +40,7 @@ spec = describe "Mtlstats.Actions" $ do
updateGameStatsSpec
validateGameDateSpec
createPlayerSpec
addPlayerSpec
startNewSeasonSpec :: Spec
startNewSeasonSpec = describe "startNewSeason" $ do
@@ -322,6 +323,30 @@ createPlayerSpec = describe "createPlayer" $
s = createPlayer newProgState
in s^.progMode `shouldBe` CreatePlayer newCreatePlayerState
addPlayerSpec :: Spec
addPlayerSpec = describe "addPlayer" $ do
let
p1 = newPlayer 1 "Joe" "centre"
p2 = newPlayer 2 "Bob" "defense"
db = newDatabase
& dbPlayers .~ [p2]
s pm = newProgState
& progMode .~ pm
& database .~ db
context "data available" $
it "should create the player" $ let
s' = addPlayer $ s $ CreatePlayer $ newCreatePlayerState
& cpsNumber ?~ 1
& cpsName .~ "Joe"
& cpsPosition .~ "centre"
in s'^.database.dbPlayers `shouldBe` [p1, p2]
context "data unavailable" $
it "should not create the player" $ let
s' = addPlayer $ s MainMenu
in s'^.database.dbPlayers `shouldBe` [p2]
makePlayer :: IO Player
makePlayer = Player
<$> makeNum