From 9368c616e202fc67c15d6128a2110d05998f4290 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 14 Dec 2024 13:04:36 +0530 Subject: Move the mouse to the cell position after key sequence match --- specs/Specs/KeySequenceSpec.hs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'specs') diff --git a/specs/Specs/KeySequenceSpec.hs b/specs/Specs/KeySequenceSpec.hs index 570f1f9..d094741 100644 --- a/specs/Specs/KeySequenceSpec.hs +++ b/specs/Specs/KeySequenceSpec.hs @@ -1,6 +1,6 @@ module Specs.KeySequenceSpec where -import Chelleport.KeySequence (generateKeyCells, nextChars) +import Chelleport.KeySequence (findMatchPosition, generateKeyCells, nextChars) import Test.Hspec test = do @@ -37,3 +37,18 @@ test = do ["HJA", "HJB", "LJA", "LJB"], ["HJA", "HJB", "LJA", "LJB"] ] + + describe "#findMatchPosition" $ do + it "returns the position of the matching key sequence" $ do + findMatchPosition "ABD" [["XYZ", "ABC"], ["AMK", "BBL", "ABD"]] + `shouldBe` Just (1, 2) + + context "when sequence is incomplete" $ do + it "returns nothing" $ do + findMatchPosition "AB" [["XYZ", "ABC"], ["AMK", "BBL", "ABD"]] + `shouldBe` Nothing + + context "when there are no matches" $ do + it "returns nothing" $ do + findMatchPosition "FOO" [["XYZ", "ABC"], ["AMK", "BBL", "ABD"]] + `shouldBe` Nothing -- cgit v1.3.1