move cursor in edit mode
This commit is contained in:
105
test/Hamming/App/ActionsSpec.hs
Normal file
105
test/Hamming/App/ActionsSpec.hs
Normal file
@@ -0,0 +1,105 @@
|
||||
{-
|
||||
|
||||
hamming
|
||||
Copyright (C) Jonathan Lamothe <jonathan@jlamothe.net>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public
|
||||
License along with this program. If not, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
-}
|
||||
|
||||
module Hamming.App.ActionsSpec (spec) where
|
||||
|
||||
import Lens.Micro ((&), (.~))
|
||||
import Test.Hspec (Spec, context, describe, it, shouldBe)
|
||||
|
||||
import Hamming.App.Actions
|
||||
import Hamming.App.Types
|
||||
|
||||
spec :: Spec
|
||||
spec = describe "Actions" $ do
|
||||
moveUpSpec
|
||||
moveDownSpec
|
||||
moveLeftSpec
|
||||
moveRightSpec
|
||||
|
||||
moveUpSpec :: Spec
|
||||
moveUpSpec = describe "moveUp" $ mapM_
|
||||
( \(desc, state, expected) -> context desc $ let
|
||||
actual = moveUp state
|
||||
in it ("should be " ++ show expected) $
|
||||
actual `shouldBe` expected
|
||||
)
|
||||
[ ( "at the top", atTop, atTop )
|
||||
, ( "elsewhere", elsewhere, movedUp )
|
||||
] where
|
||||
atTop = initialEditor & colNum .~ 1
|
||||
elsewhere = atTop & rowNum .~ 2
|
||||
movedUp = atTop & rowNum .~ 1
|
||||
|
||||
moveDownSpec :: Spec
|
||||
moveDownSpec = describe "moveDown" $ mapM_
|
||||
( \(desc, state, expected) -> context desc $ let
|
||||
actual = moveDown state
|
||||
in it ("should be " ++ show expected) $
|
||||
actual `shouldBe` expected
|
||||
)
|
||||
[ ( "at the bottom", atBottom, atBottom )
|
||||
, ( "elsewhere", elsewhere, movedDown )
|
||||
] where
|
||||
atBottom = initialEditor
|
||||
& colNum .~ 1
|
||||
& rowNum .~ 3
|
||||
elsewhere = initialEditor
|
||||
& colNum .~ 1
|
||||
& rowNum .~ 1
|
||||
movedDown = initialEditor
|
||||
& colNum .~ 1
|
||||
& rowNum .~ 2
|
||||
|
||||
moveLeftSpec :: Spec
|
||||
moveLeftSpec = describe "moveLeft" $ mapM_
|
||||
( \(desc, state, expected) -> context desc $ let
|
||||
actual = moveLeft state
|
||||
in it ("should be " ++ show expected) $
|
||||
actual `shouldBe` expected
|
||||
)
|
||||
[ ( "at left", atLeft, atLeft )
|
||||
, ( "elsewhere", elsewhere, movedLeft )
|
||||
] where
|
||||
atLeft = initialEditor & rowNum .~ 1
|
||||
elsewhere = atLeft & colNum .~ 2
|
||||
movedLeft = atLeft & colNum .~ 1
|
||||
|
||||
moveRightSpec :: Spec
|
||||
moveRightSpec = describe "moveRight" $ mapM_
|
||||
( \(desc, state, expected) -> context desc $ let
|
||||
actual = moveRight state
|
||||
in it ("should be " ++ show expected) $
|
||||
actual `shouldBe` expected
|
||||
)
|
||||
[ ( "at right", atRight, atRight )
|
||||
, ( "elsewhere", elsewhere, movedRight )
|
||||
] where
|
||||
atRight = initialEditor
|
||||
& rowNum .~ 1
|
||||
& colNum .~ 3
|
||||
elsewhere = initialEditor
|
||||
& rowNum .~ 1
|
||||
& colNum .~ 1
|
||||
movedRight = initialEditor
|
||||
& rowNum .~ 1
|
||||
& colNum .~ 2
|
||||
|
||||
--jl
|
||||
@@ -23,11 +23,13 @@ module Hamming.AppSpec (spec) where
|
||||
|
||||
import Test.Hspec (Spec, describe)
|
||||
|
||||
import qualified Hamming.App.ActionsSpec as Actions
|
||||
import qualified Hamming.App.UtilSpec as Util
|
||||
import qualified Hamming.App.WidgetsSpec as Widgets
|
||||
|
||||
spec :: Spec
|
||||
spec = describe "App" $ do
|
||||
Actions.spec
|
||||
Util.spec
|
||||
Widgets.spec
|
||||
|
||||
|
||||
Reference in New Issue
Block a user