implemented row selection

This commit is contained in:
2024-08-22 16:14:23 -04:00
parent 6a4a1fda82
commit 014ca39103
7 changed files with 142 additions and 3 deletions

View File

@@ -0,0 +1,65 @@
{-
abacus
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 Abacus.App.ActionsSpec (spec) where
import Lens.Micro.Platform ((&), (.~))
import Test.Hspec (Spec, context, describe, it, shouldBe)
import Abacus.App.Actions
import Abacus.App.Types
spec :: Spec
spec = describe "Actions" $ do
moveUpSpec
moveDownSpec
moveUpSpec :: Spec
moveUpSpec = describe "moveUp" $ mapM_
( \(desc, state, expected) -> context desc $
it ("should be " ++ show expected) $
moveUp state `shouldBe` expected
)
[ ( "at the top", initialState, initialState )
, ( "at the bottom", atBottom, movedUp )
, ( "somewhere else", elsewhere, initialState )
]
where
atBottom = initialState & rungNum .~ 9
elsewhere = initialState & rungNum .~ 1
movedUp = initialState & rungNum .~ 8
moveDownSpec :: Spec
moveDownSpec = describe "moveDown" $ mapM_
( \(desc, state, expected) -> context desc $
it ("should be " ++ show expected) $
moveDown state `shouldBe` expected
)
[ ( "at the top", initialState, movedDown )
, ( "at the bottom", atBottom, atBottom )
, ( "somewhere else", elsewhere, atBottom )
]
where
atBottom = initialState & rungNum .~ 9
elsewhere = initialState & rungNum .~ 8
movedDown = initialState & rungNum .~ 1
--jl

View File

@@ -23,10 +23,12 @@ module Abacus.AppSpec (spec) where
import Test.Hspec (Spec, describe)
import qualified Abacus.App.ActionsSpec as Actions
import qualified Abacus.App.WidgetsSpec as Widgets
spec :: Spec
spec = describe "App"
spec = describe "App" $ do
Widgets.spec
Actions.spec
--jl