返回 DeepSeek-Reasonix
balance_test.go
根目录 / internal / billing / balance_test.go
1 package billing
2
3 import "testing"
4
5 func TestBalanceOriginalCurrencyDisplayNeverConverts(t *testing.T) {
6 b := &Balance{Available: true, Infos: []Info{
7 {Currency: "CNY", TotalBalance: "70.16"},
8 {Currency: "USD", TotalBalance: "9.82"},
9 }}
10 if got := b.DisplayForCurrency("USD"); got != "$9.82" {
11 t.Fatalf("USD display = %q", got)
12 }
13 if got := (&Balance{Infos: []Info{{Currency: "CNY", TotalBalance: "70.16"}}}).DisplayForCurrency("USD"); got != "CNY ¥70.16" {
14 t.Fatalf("fallback display = %q", got)
15 }
16 if got := b.PrimaryCurrency(); got != "" || !b.MultiCurrency() {
17 t.Fatalf("wallet currencies = %v primary=%q", b.Currencies(), got)
18 }
19 }
20
21 func TestBalanceSingleWalletCurrencyHint(t *testing.T) {
22 b := &Balance{Infos: []Info{{Currency: "RMB", TotalBalance: "1"}}}
23 if got := b.PrimaryCurrency(); got != "CNY" {
24 t.Fatalf("primary = %q", got)
25 }
26 if got := b.Currencies(); len(got) != 1 || got[0] != "CNY" {
27 t.Fatalf("currencies = %v", got)
28 }
29 }
30
30 lines GO