|
|
|
@ -71,13 +71,47 @@ defmodule BlockScoutWeb.AddressTokenBalanceViewTest do |
|
|
|
|
|
|
|
|
|
describe "sort_by_usd_value_and_name/1" do |
|
|
|
|
test "sorts the given tokens by its name and usd_value" do |
|
|
|
|
token_balance_a = build(:token_balance, token: build(:token, name: "token name") |> Map.put(:usd_value, 2)) |
|
|
|
|
token_balance_b = build(:token_balance, token: build(:token, name: "token") |> Map.put(:usd_value, 3)) |
|
|
|
|
token_balance_c = build(:token_balance, token: build(:token, name: nil) |> Map.put(:usd_value, 2)) |
|
|
|
|
token_balance_d = build(:token_balance, token: build(:token, name: "Atoken") |> Map.put(:usd_value, 1)) |
|
|
|
|
token_balance_e = build(:token_balance, token: build(:token, name: "atoken") |> Map.put(:usd_value, nil)) |
|
|
|
|
token_balance_f = build(:token_balance, token: build(:token, name: "Btoken") |> Map.put(:usd_value, nil)) |
|
|
|
|
token_balance_g = build(:token_balance, token: build(:token, name: "Btoken") |> Map.put(:usd_value, 1)) |
|
|
|
|
token_balance_a = |
|
|
|
|
build(:token_balance, |
|
|
|
|
token: build(:token, name: "token name", decimals: Decimal.new(18)) |> Map.put(:usd_value, Decimal.new(2)), |
|
|
|
|
value: Decimal.new(100_500) |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
token_balance_b = |
|
|
|
|
build(:token_balance, |
|
|
|
|
token: build(:token, name: "token", decimals: Decimal.new(18)) |> Map.put(:usd_value, Decimal.new(3.45)), |
|
|
|
|
value: Decimal.new(100_500) |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
token_balance_c = |
|
|
|
|
build(:token_balance, |
|
|
|
|
token: build(:token, name: nil, decimals: Decimal.new(18)) |> Map.put(:usd_value, Decimal.new(2)), |
|
|
|
|
value: Decimal.new(100_500) |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
token_balance_d = |
|
|
|
|
build(:token_balance, |
|
|
|
|
token: build(:token, name: "Atoken", decimals: Decimal.new(18)) |> Map.put(:usd_value, Decimal.new(1)), |
|
|
|
|
value: Decimal.new(100_500) |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
token_balance_e = |
|
|
|
|
build(:token_balance, |
|
|
|
|
token: build(:token, name: "atoken", decimals: Decimal.new(18)) |> Map.put(:usd_value, nil), |
|
|
|
|
value: Decimal.new(100_500) |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
token_balance_f = |
|
|
|
|
build(:token_balance, |
|
|
|
|
token: build(:token, name: "Btoken", decimals: Decimal.new(18)) |> Map.put(:usd_value, nil), |
|
|
|
|
value: Decimal.new(100_500) |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
token_balance_g = |
|
|
|
|
build(:token_balance, |
|
|
|
|
token: build(:token, name: "Btoken", decimals: Decimal.new(18)) |> Map.put(:usd_value, Decimal.new(1)), |
|
|
|
|
value: Decimal.new(100_500) |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
token_balances = [ |
|
|
|
|
token_balance_a, |
|
|
|
|