From 905c6ada4cb34d82df665d53b0e64e101d247bc7 Mon Sep 17 00:00:00 2001 From: Sebastian Crane Date: Mon, 3 Jan 2022 14:27:19 +0000 Subject: [PATCH] Add function with tests to get list of games Signed-off-by: Sebastian Crane --- src/game.clj | 3 +++ test/game_test.clj | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/game.clj b/src/game.clj index 52e0b1c..5d21e82 100644 --- a/src/game.clj +++ b/src/game.clj @@ -12,5 +12,8 @@ (defn remove-player-of-game [state game player] (update-in state [:games game] #(disj % player))) +(defn get-games [state] + (keys (:games state))) + (defn remove-game [state game] (update-in state [:games] dissoc game)) diff --git a/test/game_test.clj b/test/game_test.clj index eda30f5..7edb743 100644 --- a/test/game_test.clj +++ b/test/game_test.clj @@ -24,6 +24,11 @@ '#{"player-one" "player-three"} (get-in (remove-player-of-game test-state :imaginary-rpg "player-four") [:games :imaginary-rpg])))) +(deftest get-games-test + (is (= + '#{:hypothetical-shooter :quasi-rts :imaginary-rpg} + (set (get-games test-state))))) + (deftest remove-game-test (is (= '#{:hypothetical-shooter :imaginary-rpg}