Add response function with tests to list games
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
This commit is contained in:
parent
083d51a879
commit
f891299236
|
@ -41,6 +41,12 @@
|
|||
game
|
||||
"!"))
|
||||
|
||||
(defn list-games-string [state _ _]
|
||||
(str "Games with a list of players: "
|
||||
(str/join
|
||||
", "
|
||||
(sort (map name (game/get-games state))))))
|
||||
|
||||
(defn split-message [message]
|
||||
(let [message-parts (str/split message #"\s")
|
||||
command (if-let [x (first message-parts)] (str/lower-case x) "")
|
||||
|
|
|
@ -25,6 +25,10 @@
|
|||
(is (= "Removed abc from the list of players for hypothetical-shooter!"
|
||||
(remove-player-string nil "hypothetical-shooter" "abc"))))
|
||||
|
||||
(deftest list-games-string-test
|
||||
(is (= "Games with a list of players: hypothetical-shooter, imaginary-rpg, quasi-rts"
|
||||
(list-games-string test-state nil nil))))
|
||||
|
||||
(deftest split-message-test
|
||||
(is (= {:command "!match" :game "Quasi-Rts" :game-keyword :quasi-rts}
|
||||
(split-message "!match Quasi-Rts "))))
|
||||
|
|
Loading…
Reference in New Issue