aboutsummaryrefslogtreecommitdiff
path: root/specs/Specs
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2024-12-20 19:51:08 +0530
committerAkshay Nair <phenax5@gmail.com>2024-12-20 19:54:25 +0530
commit496c7d048df6a9a3650c0a0b996888decb4ea9d1 (patch)
treebdd74d3678dff626249a14f9682e8d3b798d4d05 /specs/Specs
parentf96b1395518b2941b2746398094c06d3d40d18f1 (diff)
downloadchelleport-496c7d048df6a9a3650c0a0b996888decb4ea9d1.tar.gz
chelleport-496c7d048df6a9a3650c0a0b996888decb4ea9d1.zip
Add shift+click to chain clicks in sequence
Diffstat (limited to 'specs/Specs')
-rw-r--r--specs/Specs/AppEventSpec.hs7
-rw-r--r--specs/Specs/AppStateUpdateSpec.hs26
2 files changed, 20 insertions, 13 deletions
diff --git a/specs/Specs/AppEventSpec.hs b/specs/Specs/AppEventSpec.hs
index 9ac9d4c..18e685b 100644
--- a/specs/Specs/AppEventSpec.hs
+++ b/specs/Specs/AppEventSpec.hs
@@ -31,11 +31,6 @@ test = do
let action = eventHandler $ mkEvent SDL.QuitEvent
action `shouldBe` Just ShutdownApp
- context "when q key is pressed" $ do
- it "shuts down app" $ do
- let action = eventHandler $ mkKeyboardEvent SDL.KeycodeQ SDL.Pressed
- action `shouldBe` Just ShutdownApp
-
context "when escape key is pressed" $ do
it "shuts down app" $ do
let action = eventHandler $ mkKeyboardEvent SDL.KeycodeEscape SDL.Pressed
@@ -54,7 +49,7 @@ test = do
context "when an alphanumeric key (excluding Q) is pressed" $ do
it "calls key input handler" $ do
eventHandler (mkKeyboardEvent SDL.KeycodeA SDL.Pressed) `shouldBe` Just (HandleKeyInput SDL.KeycodeA)
- eventHandler (mkKeyboardEvent SDL.KeycodeB SDL.Pressed) `shouldBe` Just (HandleKeyInput SDL.KeycodeB)
+ eventHandler (mkKeyboardEvent SDL.KeycodeQ SDL.Pressed) `shouldBe` Just (HandleKeyInput SDL.KeycodeQ)
eventHandler (mkKeyboardEvent SDL.Keycode9 SDL.Pressed) `shouldBe` Just (HandleKeyInput SDL.Keycode9)
context "when shift key is pressed" $ do
diff --git a/specs/Specs/AppStateUpdateSpec.hs b/specs/Specs/AppStateUpdateSpec.hs
index 169cd8b..d8502db 100644
--- a/specs/Specs/AppStateUpdateSpec.hs
+++ b/specs/Specs/AppStateUpdateSpec.hs
@@ -58,25 +58,37 @@ test = do
context "with action TriggerLeftClick" $ do
let currentState = defaultState
- it "hides window and triggers left clicks" $ do
+ it "hides window and triggers left click" $ do
(_, mock) <- runWithMocks $ update currentState TriggerLeftClick
calls mock `shouldContain` [CallHideWindow, CallPressMouseButton LeftClick]
it "continues with action ShutdownApp without updating state" $ do
((nextState, action), _) <- runWithMocks $ update currentState TriggerLeftClick
- -- handleMocks
- -- [ CallPressMouseButton LeftClick `returns` (1, 2),
- -- CallHideWindow `returns` ()
- -- ]
action `shouldBe` Just ShutdownApp
nextState `shouldBe` currentState
+ context "with action ChainLeftClick" $ do
+ let currentState = defaultState
+
+ it "hides window, triggers left click and shows the window again" $ do
+ (_, mock) <- runWithMocks $ update currentState ChainLeftClick
+ calls mock `shouldBe` [CallHideWindow, CallPressMouseButton LeftClick, CallShowWindow]
+
+ it "continues with action ResetKeys without updating state" $ do
+ ((nextState, action), _) <- runWithMocks $ update currentState ChainLeftClick
+ action `shouldBe` Just ResetKeys
+ nextState `shouldBe` currentState
+
context "with action MoveMousePosition" $ do
let currentState = defaultState
-- TODO: Test with inline mocked values
it "moves mouse pointer to center of cell of given coordinates" $ do
(_, mock) <- runWithMocks $ update currentState $ MoveMousePosition (0, 0)
+ -- handleMocks
+ -- [ CallPressMouseButton LeftClick `returns` (1, 2),
+ -- CallHideWindow `returns` ()
+ -- ]
mock `shouldHaveCalled` CallMoveMousePosition 25 25
it "does not continue or update state" $ do
@@ -95,7 +107,7 @@ test = do
let currentState = defaultState
-- TODO: Test with inline mocked values
- it "hides window and triggers left clicks" $ do
+ it "increments mouse position relative to current position" $ do
(_, mock) <- runWithMocks $ update currentState $ IncrementMouseCursor (10, -20)
mock `shouldHaveCalled` CallMoveMousePosition 52 22
@@ -106,7 +118,7 @@ test = do
context "with action ShutdownApp" $ do
let currentState = defaultState
- it "hides window and triggers left clicks" $ do
+ it "shuts down app" $ do
(_, mock) <- runWithMocks $ update currentState ShutdownApp
mock `shouldHaveCalled` CallShutdownApp