Add function with tests to get list of games
Signed-off-by: Sebastian Crane <seabass-labrax@gmx.com>
This commit is contained in:
parent
242873a713
commit
905c6ada4c
|
@ -12,5 +12,8 @@
|
||||||
(defn remove-player-of-game [state game player]
|
(defn remove-player-of-game [state game player]
|
||||||
(update-in state [:games game] #(disj % player)))
|
(update-in state [:games game] #(disj % player)))
|
||||||
|
|
||||||
|
(defn get-games [state]
|
||||||
|
(keys (:games state)))
|
||||||
|
|
||||||
(defn remove-game [state game]
|
(defn remove-game [state game]
|
||||||
(update-in state [:games] dissoc game))
|
(update-in state [:games] dissoc game))
|
||||||
|
|
|
@ -24,6 +24,11 @@
|
||||||
'#{"player-one" "player-three"}
|
'#{"player-one" "player-three"}
|
||||||
(get-in (remove-player-of-game test-state :imaginary-rpg "player-four") [:games :imaginary-rpg]))))
|
(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
|
(deftest remove-game-test
|
||||||
(is (=
|
(is (=
|
||||||
'#{:hypothetical-shooter :imaginary-rpg}
|
'#{:hypothetical-shooter :imaginary-rpg}
|
||||||
|
|
Loading…
Reference in New Issue