added callbacks to CreatePlayerState
This commit is contained in:
@@ -83,21 +83,32 @@ gameStateLSpec = describe "gameStateL" $ lensSpec gameStateL
|
||||
where gs t = newGameState & gameType ?~ t
|
||||
|
||||
createPlayerStateLSpec :: Spec
|
||||
createPlayerStateLSpec = describe "createPlayerStateL" $
|
||||
lensSpec createPlayerStateL
|
||||
-- getters
|
||||
[ ( MainMenu, newCreatePlayerState )
|
||||
, ( CreatePlayer $ cps 1 , cps 1 )
|
||||
]
|
||||
-- setters
|
||||
[ ( MainMenu, cps 1 )
|
||||
, ( CreatePlayer $ cps 1, cps 2 )
|
||||
]
|
||||
where
|
||||
cps n = newCreatePlayerState
|
||||
& cpsNumber ?~ n
|
||||
& cpsName .~ "foo"
|
||||
& cpsPosition .~ "bar"
|
||||
createPlayerStateLSpec = describe "createPlayerStateL" $ do
|
||||
context "getters" $ do
|
||||
context "state missing" $ let
|
||||
pm = MainMenu
|
||||
cps = pm^.createPlayerStateL
|
||||
in it "should not have a number" $
|
||||
cps^.cpsNumber `shouldBe` Nothing
|
||||
|
||||
context "existing state" $ let
|
||||
pm = CreatePlayer $ newCreatePlayerState & cpsNumber ?~ 1
|
||||
cps = pm^.createPlayerStateL
|
||||
in it "should have a number of 1" $
|
||||
cps^.cpsNumber `shouldBe` Just 1
|
||||
|
||||
context "setters" $ do
|
||||
context "state missing" $ let
|
||||
pm = MainMenu
|
||||
pm' = pm & createPlayerStateL.cpsNumber ?~ 1
|
||||
in it "should set the player number to 1" $
|
||||
pm'^.createPlayerStateL.cpsNumber `shouldBe` Just 1
|
||||
|
||||
context "existing state" $ let
|
||||
pm = CreatePlayer $ newCreatePlayerState & cpsNumber ?~ 1
|
||||
pm' = pm & createPlayerStateL.cpsNumber ?~ 2
|
||||
in it "should set the player number to 2" $
|
||||
pm'^.createPlayerStateL.cpsNumber `shouldBe` Just 2
|
||||
|
||||
teamScoreSpec :: Spec
|
||||
teamScoreSpec = describe "teamScore" $ do
|
||||
|
||||
Reference in New Issue
Block a user