fix: remove strict equal check on timer in delete for me test (#14159)
fix #14155
This commit is contained in:
parent
a74a44e492
commit
509b8bf3e1
|
@ -13,15 +13,19 @@
|
||||||
(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
|
|
||||||
(+ (datetime/timestamp)
|
|
||||||
1000)}}}}
|
|
||||||
:utils/dispatch-later
|
:utils/dispatch-later
|
||||||
[{:dispatch [:chat.ui/delete-message-for-me-and-sync
|
[{:dispatch [:chat.ui/delete-message-for-me-and-sync
|
||||||
{:chat-id "chat-id" :message-id "message-id"}]
|
{:chat-id "chat-id" :message-id "message-id"}]
|
||||||
:ms 1000}]}]
|
:ms 1000}]}
|
||||||
(is (= (delete-message-for-me/delete {:db db} message 1000) expected))))
|
result (delete-message-for-me/delete {:db db} message 1000)
|
||||||
|
timestamp (+ (datetime/timestamp) 1000)]
|
||||||
|
(is (= (update-in result [:db :messages "chat-id" "message-id"] dissoc :deleted-for-me-undoable-till)
|
||||||
|
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)))))
|
||||||
|
@ -45,24 +49,22 @@
|
||||||
[: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