diff --git a/test/Hamming/App/Widgets/InternalSpec.hs b/test/Hamming/App/Widgets/InternalSpec.hs index bd7c0d6..a86b6ea 100644 --- a/test/Hamming/App/Widgets/InternalSpec.hs +++ b/test/Hamming/App/Widgets/InternalSpec.hs @@ -21,8 +21,8 @@ License along with this program. If not, see module Hamming.App.Widgets.InternalSpec (spec) where +import Brick.Types (Location (..)) import Lens.Micro ((&), (.~)) - import Test.Hspec (Spec, context, describe, it, shouldBe) import Hamming.App @@ -35,11 +35,14 @@ spec = describe "Internal" hammingW'Spec :: Spec hammingW'Spec = describe "hammingW'" $ mapM_ - ( \(desc, state, expRes) -> context desc $ do + ( \(desc, state, expRes, expLoc) -> context desc $ do let - (actRes, _) = hammingW' state + (actRes, actLoc) = hammingW' state numActRows = length actRes numExpRows = length expRes + context "location" $ + it ("should be " ++ show expLoc) $ + actLoc `shouldBe` expLoc context "number of rows" $ it ("should be " ++ show numExpRows) $ numActRows `shouldBe` numExpRows @@ -59,11 +62,14 @@ hammingW'Spec = describe "hammingW'" $ mapM_ ) $ zip3 [(0 :: Int)..] actRow expRow ) $ zip3 [(0 :: Int)..] actRes expRes ) - [ ( "all zero", mkState 0, allZero ) - , ( "all one", mkState 0xffff, allOne ) - , ( "arbitrary", mkState 0x3c5a, arbitrary ) + [ ( "all zero", mkState 0, allZero, Nothing ) + , ( "all one", mkState 0xffff, allOne, Nothing ) + , ( "arbitrary", mkState 0x3c5a, arbitrary, Nothing ) + , ( "edit", es, allZero, Just eLoc ) ] where mkState c = initialState & hammingCode .~ c + es = mkState 0 & appMode .~ EditMode initialEditor + eLoc = Location (1, 1) allZero = [ [ ( hammingAttr, ' ' ) , ( marginAttr, '0' )