fix: remove strict equal check on timer in delete for me test (#14159)
fix #14155
This commit is contained in:
parent
a74a44e492
commit
509b8bf3e1
|
@ -11,17 +11,21 @@
|
||||||
(let [db {:messages {cid {mid {:id mid}}}}
|
(let [db {:messages {cid {mid {:id mid}}}}
|
||||||
message {:message-id mid :chat-id cid}]
|
message {:message-id mid :chat-id cid}]
|
||||||
(testing "delete for me"
|
(testing "delete for me"
|
||||||
(let [expected {:db {:messages {"chat-id" {"message-id"
|
(let [expected {:db {:messages {"chat-id" {"message-id"
|
||||||
{:id "message-id"
|
{:id "message-id"
|
||||||
:deleted-for-me? true
|
:deleted-for-me? true}}}}
|
||||||
:deleted-for-me-undoable-till
|
:utils/dispatch-later
|
||||||
(+ (datetime/timestamp)
|
[{:dispatch [:chat.ui/delete-message-for-me-and-sync
|
||||||
1000)}}}}
|
{:chat-id "chat-id" :message-id "message-id"}]
|
||||||
:utils/dispatch-later
|
:ms 1000}]}
|
||||||
[{:dispatch [:chat.ui/delete-message-for-me-and-sync
|
result (delete-message-for-me/delete {:db db} message 1000)
|
||||||
{:chat-id "chat-id" :message-id "message-id"}]
|
timestamp (+ (datetime/timestamp) 1000)]
|
||||||
:ms 1000}]}]
|
(is (= (update-in result [:db :messages "chat-id" "message-id"] dissoc :deleted-for-me-undoable-till)
|
||||||
(is (= (delete-message-for-me/delete {:db db} message 1000) expected))))
|
expected))
|
||||||
|
(is (-> (get-in result [:db :messages "chat-id" "message-id" :deleted-for-me-undoable-till])
|
||||||
|
(- timestamp)
|
||||||
|
js/Math.abs
|
||||||
|
(< 10)))))
|
||||||
(testing "should return nil if message in db"
|
(testing "should return nil if message in db"
|
||||||
(is (= (delete-message-for-me/delete {:db {:messages []}} message 1000)
|
(is (= (delete-message-for-me/delete {:db {:messages []}} message 1000)
|
||||||
nil)))))
|
nil)))))
|
||||||
|
@ -30,39 +34,37 @@
|
||||||
(let [db {:messages {cid {mid {:id mid}}}}
|
(let [db {:messages {cid {mid {:id mid}}}}
|
||||||
message {:message-id mid :chat-id cid}]
|
message {:message-id mid :chat-id cid}]
|
||||||
(testing "undo delete for me in time"
|
(testing "undo delete for me in time"
|
||||||
(let [db (update-in db
|
(let [db (update-in db
|
||||||
[:messages cid mid]
|
[:messages cid mid]
|
||||||
assoc
|
assoc
|
||||||
:deleted-for-me? true
|
:deleted-for-me? true
|
||||||
:deleted-for-me-undoable-till
|
:deleted-for-me-undoable-till
|
||||||
(+ (datetime/timestamp) 1000))
|
(+ (datetime/timestamp) 1000))
|
||||||
|
|
||||||
expected {:db {:messages {"chat-id" {"message-id"
|
expected {:db {:messages {"chat-id" {"message-id"
|
||||||
{:id "message-id"}}}}}]
|
{:id "message-id"}}}}}]
|
||||||
(is (= (delete-message-for-me/undo {:db db} message) expected))))
|
(is (= (delete-message-for-me/undo {:db db} message) expected))))
|
||||||
(testing "remain deleted for me when undo delete for me late"
|
(testing "remain deleted for me when undo delete for me late"
|
||||||
(let [db (update-in db
|
(let [db (update-in db
|
||||||
[:messages cid mid]
|
[:messages cid mid]
|
||||||
assoc
|
assoc
|
||||||
:deleted-for-me? true
|
:deleted-for-me? true
|
||||||
:deleted-for-me-undoable-till
|
:deleted-for-me-undoable-till (- (datetime/timestamp) 1000))
|
||||||
(- (datetime/timestamp) 1000))
|
|
||||||
|
|
||||||
expected {:db {:messages {"chat-id" {"message-id" {:id "message-id"
|
expected {:db {:messages {"chat-id" {"message-id"
|
||||||
:deleted-for-me?
|
{:id "message-id"
|
||||||
true}}}}}]
|
:deleted-for-me? true}}}}}]
|
||||||
(is (= (delete-message-for-me/undo {:db db} message) expected))))
|
(is (= (delete-message-for-me/undo {:db db} message) expected))))
|
||||||
(testing "remain deleted for me when undo delete for me late"
|
(testing "remain deleted for me when undo delete for me late"
|
||||||
(let [db (update-in db
|
(let [db (update-in db
|
||||||
[:messages cid mid]
|
[:messages cid mid]
|
||||||
assoc
|
assoc
|
||||||
:deleted-for-me? true
|
:deleted-for-me? true
|
||||||
:deleted-for-me-undoable-till
|
:deleted-for-me-undoable-till (- (datetime/timestamp) 1000))
|
||||||
(- (datetime/timestamp) 1000))
|
|
||||||
|
|
||||||
expected {:db {:messages {"chat-id" {"message-id" {:id "message-id"
|
expected {:db {:messages {"chat-id" {"message-id"
|
||||||
:deleted-for-me?
|
{:id "message-id"
|
||||||
true}}}}}]
|
:deleted-for-me? true}}}}}]
|
||||||
(is (= (delete-message-for-me/undo {:db db} message) expected))))
|
(is (= (delete-message-for-me/undo {:db db} message) expected))))
|
||||||
(testing "should return nil if message in db"
|
(testing "should return nil if message in db"
|
||||||
(is (= (delete-message-for-me/undo {:db {:messages []}} message)
|
(is (= (delete-message-for-me/undo {:db {:messages []}} message)
|
||||||
|
|
Loading…
Reference in New Issue