57 lines
1.7 KiB
Haskell
57 lines
1.7 KiB
Haskell
{-
|
|
|
|
mtlstats
|
|
Copyright (C) Rhéal Lamothe
|
|
<rheal.lamothe@gmail.com>
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU 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
|
|
General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
-}
|
|
|
|
module HandlersSpec (spec) where
|
|
|
|
import Test.Hspec (Spec, context, describe, it, shouldBe)
|
|
|
|
import Brick.Types (BrickEvent (VtyEvent))
|
|
import Graphics.Vty.Input.Events (Event (EvKey, EvResize), Key (KChar))
|
|
|
|
import Mtlstats.Handlers
|
|
|
|
spec :: Spec
|
|
spec = describe "Mtlstats.Handlers"
|
|
ynHandlerSpec
|
|
|
|
ynHandlerSpec :: Spec
|
|
ynHandlerSpec = describe "ynHandler" $ mapM_
|
|
(\(desc, event, expected) ->
|
|
context desc $
|
|
it ("should be " ++ show expected) $
|
|
ynHandler event `shouldBe` expected)
|
|
-- description, event, expected
|
|
[ ( "Y pressed", capitalY, Just True )
|
|
, ( "y pressed", lowerY, Just True )
|
|
, ( "N pressed", capitalN, Just False )
|
|
, ( "n pressed", lowerN, Just False )
|
|
, ( "x pressed", lowerX, Nothing )
|
|
, ( "other event", otherEvent, Nothing )
|
|
]
|
|
where
|
|
capitalY = chE 'Y'
|
|
lowerY = chE 'y'
|
|
capitalN = chE 'N'
|
|
lowerN = chE 'n'
|
|
lowerX = chE 'x'
|
|
otherEvent = VtyEvent $ EvResize 0 0
|
|
chE c = VtyEvent $ EvKey (KChar c) []
|