From 80add34b15855932e9201d7426d9df01aa82c845 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 14 Dec 2024 11:23:35 +0530 Subject: Add key sequence filtering and rendering matched keys --- specs/Specs/KeySequenceSpec.hs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 specs/Specs/KeySequenceSpec.hs (limited to 'specs/Specs') 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 -- cgit v1.3.1