aboutsummaryrefslogtreecommitdiff
path: root/specs/Specs
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2024-12-14 11:23:35 +0530
committerAkshay Nair <phenax5@gmail.com>2024-12-14 11:23:35 +0530
commit80add34b15855932e9201d7426d9df01aa82c845 (patch)
tree1a5ce02bf169da0dd49c3bf907da129d5c5f4118 /specs/Specs
parent8fb21cb43b610c5a04268637155d3efb07217040 (diff)
downloadchelleport-80add34b15855932e9201d7426d9df01aa82c845.tar.gz
chelleport-80add34b15855932e9201d7426d9df01aa82c845.zip
Add key sequence filtering and rendering matched keys
Diffstat (limited to 'specs/Specs')
-rw-r--r--specs/Specs/KeySequenceSpec.hs22
1 files changed, 22 insertions, 0 deletions
diff --git a/specs/Specs/KeySequenceSpec.hs b/specs/Specs/KeySequenceSpec.hs
new file mode 100644
index 0000000..8b820b4
--- /dev/null
+++ b/specs/Specs/KeySequenceSpec.hs
@@ -0,0 +1,22 @@
+module Specs.KeySequenceSpec where
+
+import Chelleport.KeySequence (nextChars)
+import Test.Hspec
+
+test = do
+ describe "#nextChars" $ do
+ it "filters key sequence and returns next characters" $ do
+ nextChars "AB" [["XYZ", "ABC"], ["AMK", "BBL", "ABD"]]
+ `shouldBe` Just "CD"
+ nextChars "A" [["XYZ", "ABC"], ["AMK", "BBL", "ABD"]]
+ `shouldBe` Just "BM"
+
+ context "when exact match is present" $ do
+ it "returns next characters" $ do
+ nextChars "ABD" [["XYZ", "ABC"], ["AMK", "BBL", "ABD"]]
+ `shouldBe` Just ""
+
+ context "when there are no matches" $ do
+ it "returns nothing" $ do
+ nextChars "FOO" [["XYZ", "ABC"], ["AMK", "BBL", "ABD"]]
+ `shouldBe` Nothing