diff options
| author | Akshay Nair <phenax5@gmail.com> | 2024-12-20 19:51:08 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2024-12-20 19:54:25 +0530 |
| commit | 496c7d048df6a9a3650c0a0b996888decb4ea9d1 (patch) | |
| tree | bdd74d3678dff626249a14f9682e8d3b798d4d05 /specs/Specs/AppStateUpdateSpec.hs | |
| parent | f96b1395518b2941b2746398094c06d3d40d18f1 (diff) | |
| download | chelleport-496c7d048df6a9a3650c0a0b996888decb4ea9d1.tar.gz chelleport-496c7d048df6a9a3650c0a0b996888decb4ea9d1.zip | |
Add shift+click to chain clicks in sequence
Diffstat (limited to '')
| -rw-r--r-- | specs/Specs/AppStateUpdateSpec.hs | 26 |
1 files changed, 19 insertions, 7 deletions
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 |
