From 6ac5f77678cffc0814d1ee1566c8ee73de16b60c Mon Sep 17 00:00:00 2001 From: Volodymyr Kozieiev Date: Fri, 23 Aug 2024 16:59:36 +0100 Subject: [PATCH] component tests fixes --- .../wallet/token_input/component_spec.cljs | 20 ++++++++++------- .../preview/quo/wallet/token_input.cljs | 9 ++++++-- .../send/input_amount/component_spec.cljs | 22 +++++++++---------- .../wallet/send/input_amount/view.cljs | 2 +- 4 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/quo/components/wallet/token_input/component_spec.cljs b/src/quo/components/wallet/token_input/component_spec.cljs index 1aefca789a..856bd81302 100644 --- a/src/quo/components/wallet/token_input/component_spec.cljs +++ b/src/quo/components/wallet/token_input/component_spec.cljs @@ -6,16 +6,20 @@ (h/describe "Wallet: Token Input" (h/test "Token label renders" (h/render-with-theme-provider [token-input/view - {:token :snt - :currency :eur - :crypto? true - :conversion 1}]) + {:token-symbol :snt + :currency-symbol :snt + :on-swap nil + :error? false + :value "1" + :converted-value "10"}]) (h/is-truthy (h/get-by-text "SNT"))) (h/test "Amount renders" (h/render-with-theme-provider [token-input/view - {:token :snt - :currency :eur - :converted-value "€0.00" - :conversion 1}]) + {:token-symbol :snt + :currency-symbol :snt + :on-swap nil + :error? false + :value "1" + :converted-value "€0.00"}]) (h/is-truthy (h/get-by-text "€0.00")))) diff --git a/src/status_im/contexts/preview/quo/wallet/token_input.cljs b/src/status_im/contexts/preview/quo/wallet/token_input.cljs index 0a7cf967e2..fa41c81224 100644 --- a/src/status_im/contexts/preview/quo/wallet/token_input.cljs +++ b/src/status_im/contexts/preview/quo/wallet/token_input.cljs @@ -43,8 +43,13 @@ input-amount (controlled-input/input-value input-state) swap-between-fiat-and-crypto (fn [] (if crypto? - (set-input-state #(controlled-input/->fiat % conversion-rate)) - (set-input-state #(controlled-input/->crypto % conversion-rate)))) + (set-input-state #(controlled-input/->fiat + % + conversion-rate)) + (set-input-state + #(controlled-input/->crypto + % + conversion-rate)))) converted-value (if crypto? (utils/prettify-balance currency (money/crypto->fiat diff --git a/src/status_im/contexts/wallet/send/input_amount/component_spec.cljs b/src/status_im/contexts/wallet/send/input_amount/component_spec.cljs index eb08546af0..0d085f029f 100644 --- a/src/status_im/contexts/wallet/send/input_amount/component_spec.cljs +++ b/src/status_im/contexts/wallet/send/input_amount/component_spec.cljs @@ -110,7 +110,7 @@ (h/setup-subs sub-mocks) (h/render-with-theme-provider [input-amount/view {:crypto-decimals 2 - :limit-crypto 250 + :limit-crypto (money/bignumber 250) :initial-crypto-currency? false}]) (h/is-truthy (h/get-by-text "0")) (h/is-truthy (h/get-by-text "USD")) @@ -124,7 +124,7 @@ (let [on-confirm (h/mock-fn)] (h/render-with-theme-provider [input-amount/view {:crypto-decimals 10 - :limit-crypto 1000 + :limit-crypto (money/bignumber 1000) :on-confirm on-confirm :initial-crypto-currency? true}]) @@ -135,18 +135,19 @@ (h/fire-event :press (h/query-by-label-text :keyboard-key-4)) (h/fire-event :press (h/query-by-label-text :keyboard-key-5)) + (-> (h/wait-for #(h/get-by-text "$1234.50")) (.then (fn [] - (h/is-truthy (h/get-by-label-text :button-one)) - (h/is-truthy (h/get-by-label-text :container)) - (h/fire-event :press (h/get-by-label-text :button-one)) - (h/was-called on-confirm)))))) + (let [btn (h/get-by-label-text :button-one)] + (h/is-truthy btn) + (h/fire-event :press btn) + (h/was-called on-confirm))))))) (h/test "Try to fill more than limit" (h/setup-subs sub-mocks) (h/render-with-theme-provider [input-amount/view {:crypto-decimals 1 - :limit-crypto 1}]) + :limit-crypto (money/bignumber 1)}]) (h/fire-event :press (h/query-by-label-text :keyboard-key-2)) (h/fire-event :press (h/query-by-label-text :keyboard-key-9)) @@ -158,13 +159,12 @@ (h/setup-subs sub-mocks) (h/render-with-theme-provider [input-amount/view {:crypto-decimals 1 - :limit-crypto 1 + :limit-crypto (money/bignumber 10) :on-confirm #()}]) + (h/fire-event :press (h/query-by-label-text :keyboard-key-9)) (h/fire-event :press (h/query-by-label-text :keyboard-key-9)) (h/is-truthy (h/get-by-label-text :container-error)) (h/fire-event :press (h/query-by-label-text :reorder)) + (h/is-truthy #(h/get-by-text "Max: $100.00")))) - (-> (h/wait-for #(h/get-by-text "Max: $1000.00")) - (.then (fn [] - (h/wait-for #(h/is-truthy (h/get-by-label-text :container)))))))) diff --git a/src/status_im/contexts/wallet/send/input_amount/view.cljs b/src/status_im/contexts/wallet/send/input_amount/view.cljs index ebe627b496..ba4dd0f3b8 100644 --- a/src/status_im/contexts/wallet/send/input_amount/view.cljs +++ b/src/status_im/contexts/wallet/send/input_amount/view.cljs @@ -335,7 +335,7 @@ :t/send-limit {:limit (if crypto-currency? (utils/prettify-crypto-balance - token-symbol + (or (clj->js token-symbol) "") (controlled-input/upper-limit input-state) conversion-rate) (utils/prettify-balance currency-symbol