Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarBasem committed May 6, 2024
1 parent cabe5ab commit ef18079
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/status_im/subs/wallet/activities.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
:<- [:wallet/current-viewing-account-address]
(fn [[activities current-viewing-account-address]]
(let [account-activities (filter (fn [{:keys [sender recipient]}]
(or (= sender current-viewing-account-address)
(= recipient current-viewing-account-address)))
activities)
grouped-by-day (group-by (fn [{:keys [timestamp]}]
(datetime/timestamp->relative-short-date (* timestamp 1000)))
account-activities)]
(or (= sender current-viewing-account-address)
(= recipient current-viewing-account-address)))
activities)
grouped-by-day (group-by (fn [{:keys [timestamp]}]
(datetime/timestamp->relative-short-date (* timestamp 1000)))
account-activities)]
(map (fn [[date acts]] {:title date :data acts}) grouped-by-day))))
33 changes: 33 additions & 0 deletions src/status_im/subs/wallet/activities_test.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
(ns status-im.subs.wallet.activities-test
(:require
[cljs.test :refer [is testing]]
[re-frame.db :as rf-db]
status-im.subs.root
status-im.subs.wallet.collectibles
[test-helpers.unit :as h]
[utils.re-frame :as rf]))

(h/deftest-sub :wallet/all-activities
[sub-name]
(testing "It should correctly return the activities list from wallet data"
(swap! rf-db/app-db assoc-in
[:wallet :activities]
[{:id 1 :name "Transaction1"}
{:id 2 :name "Transaction2"}])
(let [result (rf/sub [sub-name])]
(is (= [{:id 1 :name "Transaction1"} {:id 2 :name "Transaction2"}] @result)))))

(h/deftest-sub :wallet/activities-for-current-viewing-account
[sub-name]
(testing "Activities should be filtered and grouped by account and dates"
(swap! rf-db/app-db assoc
{:wallet/all-activities [{:sender "acc1" :recipient "acc2" :timestamp 1588291200}
{:sender "acc2" :recipient "acc1" :timestamp 1588377600}]
:wallet/current-viewing-account-address "acc1"})
(let [result (rf/sub [sub-name])]
(is (= [{:title "May 1" :data [{:sender "acc1" :recipient "acc2" :timestamp 1588291200}]}
{:title "May 2" :data [{:sender "acc2" :recipient "acc1" :timestamp 1588377600}]}]
@result)))))



0 comments on commit ef18079

Please sign in to comment.