Split into category packages; module github.com/ZacharyZhang-NY/MujicaUI

This commit is contained in:
ZacharyZhang-NY committed 2026-10-05 16:18:48 -04:00
1 parent 5a7e921c7e
commit 22b53e9e9e
1822 files changed
+24568 -21314

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
package finance
import (
"testing"
"github.com/egoist/mygo/ui"
"github.com/ZacharyZhang-NY/MujicaUI/core"
)
func TestPnLDisplaySignsAndMask(t *testing.T) {
hidden, n := false, 0
tt := tradingTester(core.GreenUp, 520, 160, func(c *ui.Context) {
if PnLDisplay(c, PnL{Realized: 1200.5, Unrealized: -340, Today: 0}, &hidden, PnLDisplayOptions{Currency: "$"}).Changed() {
n++
}
})
for _, want := range []string{"+$1,200.50", "−$340.00", "$0.00"} {
if !tt.HasText(want) {
t.Fatalf("missing %q in %q", want, tt.Texts())
}
}
if err := tt.Click("Hide amounts"); err != nil {
t.Fatal(err)
}
if !hidden || n != 1 || tt.HasText("+$1,200.50") {
t.Fatalf("mask: hidden %v changes %d texts %q", hidden, n, tt.Texts())
}
if _, ok := tt.Find("Realized, hidden"); !ok {
t.Fatal("masked amount still spoken")
}
tt.Key(0, ui.KeySpace)
if hidden || n != 2 {
t.Fatalf("keyboard toggle: hidden %v", hidden)
}
}
func TestPnLDisplaySnapshot(t *testing.T) {
hidden := false
snapshot(t, "pnl_display", 460, 100, func(c *ui.Context) {
ui.Column(c).Padding(20).Children(func() {
PnLDisplay(c, PnL{Realized: 1200.5, Unrealized: -340.2, Today: 88}, &hidden, PnLDisplayOptions{Currency: "$"})
})
})
}