enable scrolling of report
This commit is contained in:
@@ -19,6 +19,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
-}
|
||||
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
|
||||
module ActionsSpec (spec) where
|
||||
|
||||
import Control.Monad (replicateM)
|
||||
@@ -26,7 +28,16 @@ import qualified Data.Map as M
|
||||
import Data.Maybe (fromJust)
|
||||
import Lens.Micro ((^.), (&), (.~), (?~), (%~))
|
||||
import System.Random (randomRIO)
|
||||
import Test.Hspec (Spec, context, describe, it, runIO, shouldBe, shouldNotBe)
|
||||
import Test.Hspec
|
||||
( Spec
|
||||
, context
|
||||
, describe
|
||||
, it
|
||||
, runIO
|
||||
, shouldBe
|
||||
, shouldNotBe
|
||||
, shouldSatisfy
|
||||
)
|
||||
|
||||
import Mtlstats.Actions
|
||||
import Mtlstats.Types
|
||||
@@ -49,6 +60,7 @@ spec = describe "Mtlstats.Actions" $ do
|
||||
awardAssistSpec
|
||||
resetGoalDataSpec
|
||||
assignPMinsSpec
|
||||
backHomeSpec
|
||||
|
||||
startNewSeasonSpec :: Spec
|
||||
startNewSeasonSpec = describe "startNewSeason" $ do
|
||||
@@ -640,3 +652,23 @@ makeNum = randomRIO (1, 10)
|
||||
|
||||
makeName :: IO String
|
||||
makeName = replicateM 10 $ randomRIO ('A', 'Z')
|
||||
|
||||
backHomeSpec :: Spec
|
||||
backHomeSpec = describe "backHome" $ do
|
||||
let
|
||||
input = newProgState
|
||||
& progMode.gameStateL .~ newGameState
|
||||
& inputBuffer .~ "foo"
|
||||
& scrollOffset .~ 123
|
||||
result = backHome input
|
||||
|
||||
it "should set the program mode back to MainMenu" $
|
||||
result^.progMode `shouldSatisfy` \case
|
||||
MainMenu -> True
|
||||
_ -> False
|
||||
|
||||
it "should clear the input buffer" $
|
||||
result^.inputBuffer `shouldBe` ""
|
||||
|
||||
it "should reset the scroll offset" $
|
||||
result^.scrollOffset `shouldBe` 0
|
||||
|
||||
@@ -31,6 +31,7 @@ spec = describe "Mtlstats.Util" $ do
|
||||
nthSpec
|
||||
modifyNthSpec
|
||||
updateMapSpec
|
||||
sliceSpec
|
||||
|
||||
nthSpec :: Spec
|
||||
nthSpec = describe "nth" $ mapM_
|
||||
@@ -75,3 +76,19 @@ updateMapSpec = describe "updateMap" $ do
|
||||
expected = M.fromList [(1, 2), (3, 5), (10, 11)]
|
||||
in it "should create a new value and update the default" $
|
||||
updateMap 10 10 succ input `shouldBe` expected
|
||||
|
||||
sliceSpec :: Spec
|
||||
sliceSpec = describe "slice" $ do
|
||||
let list = [2, 4, 6, 8]
|
||||
|
||||
context "sublist" $
|
||||
it "should return the sublist" $
|
||||
slice 1 2 list `shouldBe` [4, 6]
|
||||
|
||||
context "too large" $
|
||||
it "should return as much of the list as possible" $
|
||||
slice 1 100 list `shouldBe` [4, 6, 8]
|
||||
|
||||
context "negative offset" $
|
||||
it "should return the correct number of elements from the beginning" $
|
||||
slice (-10) 2 list `shouldBe` [2, 4]
|
||||
|
||||
Reference in New Issue
Block a user