implemented editStateL
This commit is contained in:
66
test/Hamming/App/Types/AppModeSpec.hs
Normal file
66
test/Hamming/App/Types/AppModeSpec.hs
Normal file
@@ -0,0 +1,66 @@
|
||||
{-
|
||||
|
||||
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.Types.AppModeSpec (spec) where
|
||||
|
||||
import Lens.Micro ((^.), (&), (.~))
|
||||
import Test.Hspec (Spec, context, describe, it, shouldBe)
|
||||
|
||||
import Hamming.App.Types
|
||||
|
||||
spec :: Spec
|
||||
spec = describe "AppMode"
|
||||
editStateLSpec
|
||||
|
||||
editStateLSpec :: Spec
|
||||
editStateLSpec = describe "editStateL" $ do
|
||||
eslSetterSpec
|
||||
eslGetterSpec
|
||||
|
||||
eslSetterSpec :: Spec
|
||||
eslSetterSpec = context "setter" $ mapM_
|
||||
( \(desc, mode, val, expected) -> context desc $ let
|
||||
actual = mode & editStateL .~ val
|
||||
in it ("should be " ++ show expected) $
|
||||
actual `shouldBe` expected
|
||||
)
|
||||
[ ( "set from display", DisplayMode, Just s1, EditMode s1 )
|
||||
, ( "clear from display", DisplayMode, Nothing, DisplayMode )
|
||||
, ( "set from edit", EditMode s1, Just s2, EditMode s2 )
|
||||
, ( "clear from edit", EditMode s1, Nothing, DisplayMode )
|
||||
]
|
||||
where
|
||||
s1 = EditState 2 3
|
||||
s2 = EditState 3 5
|
||||
|
||||
eslGetterSpec :: Spec
|
||||
eslGetterSpec = context "getter" $ mapM_
|
||||
( \(desc, mode, expected) -> context desc $ let
|
||||
actual = mode^.editStateL
|
||||
in it ("should be " ++ show expected) $
|
||||
actual `shouldBe` expected
|
||||
)
|
||||
[ ( "no editor", DisplayMode, Nothing )
|
||||
, ( "with editor", EditMode s, Just s )
|
||||
]
|
||||
where s = EditState 2 3
|
||||
|
||||
--jl
|
||||
32
test/Hamming/App/TypesSpec.hs
Normal file
32
test/Hamming/App/TypesSpec.hs
Normal file
@@ -0,0 +1,32 @@
|
||||
{-
|
||||
|
||||
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.TypesSpec (spec) where
|
||||
|
||||
import Test.Hspec (Spec, describe)
|
||||
|
||||
import qualified Hamming.App.Types.AppModeSpec as AppMode
|
||||
|
||||
spec :: Spec
|
||||
spec = describe "Types"
|
||||
AppMode.spec
|
||||
|
||||
--jl
|
||||
Reference in New Issue
Block a user