Skip to content

Commit

Permalink
fix: remove-chat-test
Browse files Browse the repository at this point in the history
  • Loading branch information
BalogunofAfrica committed Nov 3, 2023
1 parent 80fed9d commit caa178a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
12 changes: 4 additions & 8 deletions src/status_im2/contexts/chat/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,10 @@

(rf/defn remove-chat
"Removes chat with provided id from the chat list"
[{:keys [db now] :as cofx} chat-id]
(rf/merge
cofx
{:db (-> (if (get-in db [:chats chat-id :muted])
(assoc-in db [:chats chat-id :active] false)
(update db :chats dissoc chat-id))
(update :chats-home-list disj chat-id)
(assoc :current-chat-id nil))}))
[{:keys [db]} chat-id]
{:db (-> db
(update :chats-home-list disj chat-id)
(assoc :current-chat-id nil))})

(rf/defn offload-messages
{:events [:chat/offload-messages]}
Expand Down
10 changes: 4 additions & 6 deletions src/status_im2/contexts/chat/events_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@

(deftest remove-chat-test
(let [chat-id "1"
cofx {:db {:messages {chat-id {"1" {:clock-value 1}
"2" {:clock-value 10}
"3" {:clock-value 2}}}
:chats {chat-id {:last-message {:clock-value 10}}}}}]
(testing "it deletes all the messages"
cofx {:db {:current-chat-id chat-id
:chats-home-list #{chat-id}}}]
(testing "it removes the chat with given id"
(let [actual (chat/close-and-remove-chat cofx chat-id)]
(is (= nil (get-in actual [:db :messages chat-id])))))))
(is (= nil (get-in actual [:db :chats-home-list chat-id])))))))

(deftest multi-user-chat?
(let [chat-id "1"]
Expand Down

0 comments on commit caa178a

Please sign in to comment.