Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrkhalil committed Mar 19, 2024
1 parent b88e7ee commit cb335a2
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions src/status_im/contexts/communities/events_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -144,38 +144,6 @@
nil
(events/spectate-community-success {} []))))))

(deftest handle-community
(let [community {:id community-id :clock 2}]
(testing "given a unjoined community"
(let [effects (events/handle-community {} [community])]
(is (match? community-id
(-> effects :db :communities (get community-id) :id)))
(is (match?
[[:dispatch [:chat.ui/spectate-community community-id]]
[:dispatch [:communities/check-permissions-to-join-community community-id]]]
(filter some? (:fx effects))))))

(testing "given a joined community"
(let [community (assoc community :joined true)
effects (events/handle-community {} [community])]
(is (match?
[[:dispatch [:communities/check-permissions-to-join-community community-id]]]
(filter some? (:fx effects))))))

(testing "given a community with token-permissions-check"
(let [community (assoc community :token-permissions-check :fake-token-permissions-check)
effects (events/handle-community {} [community])]
(is (match?
[[:dispatch [:chat.ui/spectate-community community-id]]]
(filter some? (:fx effects))))))
(testing "given a community with lower clock"
(let [effects (events/handle-community {:db {:communities {community-id {:clock 3}}}} [community])]
(is (nil? effects))))
(testing "given a community without clock"
(let [community (dissoc community :clock)
effects (events/handle-community {} [community])]
(is (nil? effects))))))

(deftest get-revealed-accounts
(let [community {:id community-id}]
(testing "given a unjoined community"
Expand Down Expand Up @@ -219,3 +187,35 @@
community-id on-success]
:on-error fn?}]}]
(is (match? expected actual))))))

(deftest handle-community
(let [community {:id community-id :clock 2}]
(testing "given a unjoined community"
(let [effects (events/handle-community {} [community])]
(is (match? community-id
(-> effects :db :communities (get community-id) :id)))
(is (match?
[[:dispatch [:chat.ui/spectate-community community-id]]
[:dispatch [:communities/check-permissions-to-join-community community-id]]]
(filter some? (:fx effects))))))

(testing "given a joined community"
(let [community (assoc community :joined true)
effects (events/handle-community {} [community])]
(is (match?
[[:dispatch [:communities/check-permissions-to-join-community community-id]]]
(filter some? (:fx effects))))))

(testing "given a community with token-permissions-check"
(let [community (assoc community :token-permissions-check :fake-token-permissions-check)
effects (events/handle-community {} [community])]
(is (match?
[[:dispatch [:chat.ui/spectate-community community-id]]]
(filter some? (:fx effects))))))
(testing "given a community with lower clock"
(let [effects (events/handle-community {:db {:communities {community-id {:clock 3}}}} [community])]
(is (nil? effects))))
(testing "given a community without clock"
(let [community (dissoc community :clock)
effects (events/handle-community {} [community])]
(is (nil? effects))))))

0 comments on commit cb335a2

Please sign in to comment.