Skip to content

Commit

Permalink
Add some more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrkhalil committed May 13, 2024
1 parent 6e0b8ae commit 26b26f8
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/status_im/subs/wallet/wallet_test.cljs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(ns status-im.subs.wallet.wallet-test
(:require
[cljs.test :refer [is testing use-fixtures]]
[clojure.string :as string]
[re-frame.db :as rf-db]
[status-im.constants :as constants]
[status-im.contexts.wallet.db :as db]
Expand Down Expand Up @@ -179,6 +180,20 @@
:chain-id 10
:layer 2}]})

(def saved-addresses
{"0x1A" {:address "0x1A"
:wallet false
:name "Account One"
:color :blue}
"0x2B" {:address "0x2B"
:wallet false
:name "Account One"
:color :blue}
"0x3C" {:address "0x3C"
:wallet false
:name "Account One"
:color :blue}})

(h/deftest-sub :wallet/balances-in-selected-networks
[sub-name]
(testing "a map: address->balance"
Expand Down Expand Up @@ -801,3 +816,24 @@
(is (match? (:title result) (:title sample-added-address)))
(is (match? (:description result) (:description sample-added-address)))
(is (match? (:adding-address-purpose result) (:adding-address-purpose sample-added-address))))))

(h/deftest-sub :wallet/lowercased-saved-addresses
[sub-name]
(testing "Testing fetching of lowercased saved addresses"
(swap! rf-db/app-db #(assoc-in % [:wallet :saved-addresses] saved-addresses))
(let [result (rf/sub [sub-name])
expected (map string/lower-case (keys saved-addresses))]
(is (match? result expected)))))

(h/deftest-sub :wallet/saved-addresses?
[sub-name]
(testing "Testing existance of saved addresses"
(swap! rf-db/app-db #(assoc-in % [:wallet :saved-addresses] saved-addresses))
(let [result (rf/sub [sub-name])
expected true]
(is (match? result expected))))
(testing "Testing fetching of lowercased saved addresses"
(swap! rf-db/app-db #(assoc-in % [:wallet :saved-addresses] nil))
(let [result (rf/sub [sub-name])
expected false]
(is (match? result expected)))))

0 comments on commit 26b26f8

Please sign in to comment.