refactor
This commit is contained in:
@@ -152,26 +152,27 @@
|
||||
;; The current implementation only looks at first char
|
||||
(is (input/key-match? [:key {:char \q}] "quit")))
|
||||
|
||||
(testing "nil message returns nil"
|
||||
(is (nil? (input/key-match? nil "q")))
|
||||
(is (nil? (input/key-match? nil :enter))))
|
||||
(testing "nil message returns false"
|
||||
(is (not (input/key-match? nil "q")))
|
||||
(is (not (input/key-match? nil :enter))))
|
||||
|
||||
(testing "non-key message returns nil"
|
||||
(is (nil? (input/key-match? [:tick 123] "q")))
|
||||
(is (nil? (input/key-match? [:http-success 200] :enter)))
|
||||
(is (nil? (input/key-match? "not a vector" "q"))))
|
||||
(testing "non-key message returns false"
|
||||
(is (not (input/key-match? [:tick 123] "q")))
|
||||
(is (not (input/key-match? [:http-success 200] :enter)))
|
||||
(is (not (input/key-match? "not a vector" "q"))))
|
||||
|
||||
(testing "unknown key message structure"
|
||||
(is (not (input/key-match? [:key {:unknown true}] "q")))
|
||||
(is (not (input/key-match? [:key {}] "q")))))
|
||||
|
||||
(deftest key-str-edge-cases-test
|
||||
(testing "nil message returns nil"
|
||||
(is (nil? (input/key->str nil))))
|
||||
(testing "nil message returns empty string"
|
||||
(is (= "" (input/key->str nil))))
|
||||
|
||||
(testing "non-key message returns nil"
|
||||
(is (nil? (input/key->str [:tick 123])))
|
||||
(is (nil? (input/key->str [:custom :message]))))
|
||||
(testing "non-key message returns string representation"
|
||||
;; Legacy format returns the second element as string
|
||||
(is (string? (input/key->str [:tick 123])))
|
||||
(is (string? (input/key->str [:custom :message]))))
|
||||
|
||||
(testing "key message with empty map"
|
||||
(is (= "" (input/key->str [:key {}]))))
|
||||
|
||||
Reference in New Issue
Block a user