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

+57
View File
@@ -0,0 +1,57 @@
package chat
import (
"testing"
"github.com/egoist/mygo/ui"
"github.com/ZacharyZhang-NY/MujicaUI/core"
)
func TestTokenCounterLevels(t *testing.T) {
for _, tc := range []struct {
used int
text string
label string
}{
{1234, "≈ 1,234 / 8,000", "About 1,234 of 8,000 tokens"},
{7500, "≈ 7,500 / 8,000", "About 7,500 of 8,000 tokens"},
{9100, "≈ 9,100 / 8,000", "About 9,100 of 8,000 tokens, 1,100 over the limit"},
} {
tt := ui.NewTester(func(c *ui.Context) {
core.Use(c, core.Settings{})
TokenCounter(c, tc.used, 8000)
}, 300, 60)
if !tt.HasText(tc.text) {
t.Errorf("%d: texts %q", tc.used, tt.Texts())
}
if _, ok := tt.Find(tc.label); !ok {
t.Errorf("%d: no %q", tc.used, tc.label)
}
}
if tokenThousands(1234567) != "1,234,567" || tokenThousands(12) != "12" {
t.Fatal("thousands separators")
}
}
func TestTokenCounterBadLimit(t *testing.T) {
defer func() {
if recover() == nil {
t.Fatal("no panic for a zero limit")
}
}()
ui.NewTester(func(c *ui.Context) {
core.Use(c, core.Settings{})
TokenCounter(c, 1, 0)
}, 100, 100)
}
func TestTokenCounterSnapshot(t *testing.T) {
snapshot(t, "token_counter", 240, 110, func(c *ui.Context) {
ui.Column(c).Padding(12).Gap(8).Children(func() {
TokenCounter(c, 1234, 8000)
TokenCounter(c, 7500, 8000)
TokenCounter(c, 9100, 8000)
})
})
}