component tests fixes

This commit is contained in:
Volodymyr Kozieiev 2024-08-23 16:59:36 +01:00
parent 895a8b9588
commit 6ac5f77678
No known key found for this signature in database
GPG Key ID: 82B04968DF4C0535
4 changed files with 31 additions and 22 deletions

View File

@ -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"))))

View File

@ -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

View File

@ -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))))))))

View File

@ -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