|
| 1 | +(ns status-im2.contexts.wallet.send.input-amount.component-spec |
| 2 | + (:require |
| 3 | + [re-frame.core :as re-frame] |
| 4 | + [status-im2.contexts.wallet.send.input-amount.view :as input-amount] |
| 5 | + [test-helpers.component :as h])) |
| 6 | + |
| 7 | +(defn setup-subs |
| 8 | + [subscriptions] |
| 9 | + (doseq [keyval subscriptions] |
| 10 | + (re-frame/reg-sub |
| 11 | + (key keyval) |
| 12 | + (fn [_] (val keyval))))) |
| 13 | + |
| 14 | +(def sub-mocks |
| 15 | + {:profile/profile {:currency :usd} |
| 16 | + :wallet/network-details [{:source 525 |
| 17 | + :short-name "eth" |
| 18 | + :network-name :ethereum |
| 19 | + :chain-id 1 |
| 20 | + :related-chain-id 5}]}) |
| 21 | + |
| 22 | +(h/describe "Send > input amount screen" |
| 23 | + (h/test "Default render" |
| 24 | + (setup-subs sub-mocks) |
| 25 | + (h/render [input-amount/view {}]) |
| 26 | + (h/is-truthy (h/get-by-text "0")) |
| 27 | + (h/is-truthy (h/get-by-text "ETH")) |
| 28 | + (h/is-truthy (h/get-by-text "$0.00")) |
| 29 | + (h/is-disabled (h/get-by-label-text :button-one))) |
| 30 | + |
| 31 | + (h/test "Fill token input and confirm" |
| 32 | + (setup-subs sub-mocks) |
| 33 | + (let [on-confirm (h/mock-fn)] |
| 34 | + (h/render [input-amount/view |
| 35 | + {:on-confirm on-confirm |
| 36 | + :rate 10}]) |
| 37 | + |
| 38 | + (h/fire-event :press (h/query-by-label-text :keyboard-key-1)) |
| 39 | + (h/fire-event :press (h/query-by-label-text :keyboard-key-2)) |
| 40 | + (h/fire-event :press (h/query-by-label-text :keyboard-key-3)) |
| 41 | + (h/fire-event :press (h/query-by-label-text :keyboard-key-.)) |
| 42 | + (h/fire-event :press (h/query-by-label-text :keyboard-key-4)) |
| 43 | + (h/fire-event :press (h/query-by-label-text :keyboard-key-5)) |
| 44 | + |
| 45 | + (h/wait-for #(h/is-truthy (h/get-by-text "$1234.50"))) |
| 46 | + |
| 47 | + (h/is-truthy (h/get-by-label-text :button-one)) |
| 48 | + |
| 49 | + (h/fire-event :press (h/get-by-label-text :button-one)) |
| 50 | + (h/was-called on-confirm))) |
| 51 | + |
| 52 | + (h/test "Try to fill more than limit" |
| 53 | + (setup-subs sub-mocks) |
| 54 | + (h/render [input-amount/view |
| 55 | + {:rate 10 |
| 56 | + :limit 286}]) |
| 57 | + |
| 58 | + (h/fire-event :press (h/query-by-label-text :keyboard-key-2)) |
| 59 | + (h/fire-event :press (h/query-by-label-text :keyboard-key-9)) |
| 60 | + (h/fire-event :press (h/query-by-label-text :keyboard-key-5)) |
| 61 | + |
| 62 | + (h/wait-for #(h/is-truthy (h/get-by-text "$290.00"))) |
| 63 | + |
| 64 | + (h/fire-event :press (h/query-by-label-text :keyboard-key-backspace)) |
| 65 | + (h/fire-event :press (h/query-by-label-text :keyboard-key-8)) |
| 66 | + (h/fire-event :press (h/query-by-label-text :keyboard-key-5)) |
| 67 | + (h/wait-for #(h/is-truthy (h/get-by-text "$2850.00")))) |
| 68 | + |
| 69 | + (h/test "Switch from crypto to fiat and check limit" |
| 70 | + (setup-subs sub-mocks) |
| 71 | + (h/render [input-amount/view |
| 72 | + {:rate 10 |
| 73 | + :limit 250}]) |
| 74 | + |
| 75 | + (h/fire-event :press (h/query-by-label-text :keyboard-key-2)) |
| 76 | + (h/fire-event :press (h/query-by-label-text :keyboard-key-0)) |
| 77 | + (h/wait-for #(h/is-truthy (h/get-by-text "$200.00"))) |
| 78 | + |
| 79 | + (h/fire-event :press (h/query-by-label-text :reorder)) |
| 80 | + |
| 81 | + (h/wait-for #(h/is-truthy (h/get-by-text "2.00 ETH"))) |
| 82 | + |
| 83 | + (h/fire-event :press (h/query-by-label-text :keyboard-key-5)) |
| 84 | + (h/fire-event :press (h/query-by-label-text :keyboard-key-5)) |
| 85 | + |
| 86 | + (h/wait-for #(h/is-truthy (h/get-by-text "205.50 ETH"))) |
| 87 | + (h/fire-event :press (h/query-by-label-text :keyboard-key-5)) |
| 88 | + (h/wait-for #(h/is-truthy (h/get-by-text "205.50 ETH"))))) |
0 commit comments