aboutsummaryrefslogtreecommitdiff
path: root/specs/Specs/KeySequenceSpec.hs
diff options
context:
space:
mode:
Diffstat (limited to 'specs/Specs/KeySequenceSpec.hs')
-rw-r--r--specs/Specs/KeySequenceSpec.hs19
1 files changed, 18 insertions, 1 deletions
diff --git a/specs/Specs/KeySequenceSpec.hs b/specs/Specs/KeySequenceSpec.hs
index 8b820b4..570f1f9 100644
--- a/specs/Specs/KeySequenceSpec.hs
+++ b/specs/Specs/KeySequenceSpec.hs
@@ -1,6 +1,6 @@
module Specs.KeySequenceSpec where
-import Chelleport.KeySequence (nextChars)
+import Chelleport.KeySequence (generateKeyCells, nextChars)
import Test.Hspec
test = do
@@ -20,3 +20,20 @@ test = do
it "returns nothing" $ do
nextChars "FOO" [["XYZ", "ABC"], ["AMK", "BBL", "ABD"]]
`shouldBe` Nothing
+
+ describe "#generateKeyCells" $ do
+ it "generates grid of key sequences" $ do
+ generateKeyCells (4, 4) "ABCDEF"
+ `shouldBe` [ ["HKA", "HKB", "LKA", "LKB"],
+ ["HKC", "HKD", "LKC", "LKD"],
+ ["HJA", "HJB", "LJA", "LJB"],
+ ["HJC", "HJD", "LJC", "LJD"]
+ ]
+ context "when the the keys set is too short" $ do
+ it "cycles back to first character" $ do
+ generateKeyCells (4, 4) "AB"
+ `shouldBe` [ ["HKA", "HKB", "LKA", "LKB"],
+ ["HKA", "HKB", "LKA", "LKB"],
+ ["HJA", "HJB", "LJA", "LJB"],
+ ["HJA", "HJB", "LJA", "LJB"]
+ ]