diff options
| author | Akshay Nair <phenax5@gmail.com> | 2024-12-28 14:53:58 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2024-12-28 14:53:58 +0530 |
| commit | 568923344f0941b2771459dd8dbe935ac971a968 (patch) | |
| tree | 54a07e8a3c25c85b299fe9d9273620972f03b508 /specs/Specs/AppEventSpec.hs | |
| parent | b8c389eac5f875fc7ae9a5ab9ac446d24a079448 (diff) | |
| download | chelleport-568923344f0941b2771459dd8dbe935ac971a968.tar.gz chelleport-568923344f0941b2771459dd8dbe935ac971a968.zip | |
Allow clicking with enter
Diffstat (limited to 'specs/Specs/AppEventSpec.hs')
| -rw-r--r-- | specs/Specs/AppEventSpec.hs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/specs/Specs/AppEventSpec.hs b/specs/Specs/AppEventSpec.hs index e643958..98509de 100644 --- a/specs/Specs/AppEventSpec.hs +++ b/specs/Specs/AppEventSpec.hs @@ -2,6 +2,7 @@ module Specs.AppEventSpec where import Chelleport (eventHandler) import Chelleport.Types +import Data.Default (Default (def)) import qualified SDL import SDL.Internal.Numbered (FromNumber (fromNumber)) import Test.Hspec @@ -26,7 +27,7 @@ test = do SDL.keyboardEventKeyMotion = motion } let defaultMod = fromNumber 0 - let currentState = defaultAppState + let currentState = def context "when window quit event is triggered" $ do it "shuts down app" $ do @@ -58,6 +59,21 @@ test = do let action = eventHandler currentState $ mkKeyboardEvent SDL.KeycodeSpace SDL.Pressed (defaultMod {SDL.keyModifierLeftShift = True}) action `shouldBe` Just (ChainMouseClick LeftClick) + context "when enter key is pressed" $ do + it "triggers left mouse button click" $ do + let action = eventHandler currentState $ mkKeyboardEvent SDL.KeycodeReturn SDL.Pressed defaultMod + action `shouldBe` Just (TriggerMouseClick LeftClick) + + context "when pressed with right shift" $ do + it "chains left mouse button click" $ do + let action = eventHandler currentState $ mkKeyboardEvent SDL.KeycodeReturn SDL.Pressed (defaultMod {SDL.keyModifierRightShift = True}) + action `shouldBe` Just (ChainMouseClick LeftClick) + + context "when pressed with left shift" $ do + it "chains left mouse button click" $ do + let action = eventHandler currentState $ mkKeyboardEvent SDL.KeycodeReturn SDL.Pressed (defaultMod {SDL.keyModifierLeftShift = True}) + action `shouldBe` Just (ChainMouseClick LeftClick) + context "when minus key is pressed" $ do it "triggers left mouse button click" $ do let action = eventHandler currentState $ mkKeyboardEvent SDL.KeycodeMinus SDL.Pressed defaultMod |
